Skip to content

Commit 78eb3a8

Browse files
committed
update: 更新检查项目更新
1.增加检查链接 2.更新输出格式
1 parent 0b45b1b commit 78eb3a8

File tree

5 files changed

+35
-13
lines changed

5 files changed

+35
-13
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# mys_exch_goods
1+
# Mys-Exchange-Goods
22
用于兑换米游社商品
33

44
## 使用说明

com_tool.py

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
import global_var as gl
1717

18-
MAIN_VERSION = '1.1.1'
18+
MAIN_VERSION = '1.1.2'
1919
MYS_SALT = "PVeGWIZACpxXZ1ibMVJPi9inCY4Nd4y2"
2020
MYS_SALT_TWO = "t0qEgfub6cvueAPgR5m9aQWWVciEer7v"
2121
MYS_SALT_WEB = "yUZ3s0Sna1IrSNfk29Vo6vRapdOyqyhB"
@@ -122,37 +122,49 @@ def check_update():
122122
if MAIN_VERSION == config_version:
123123
print(f"当前程序版本为v{MAIN_VERSION}, 配置文件版本为v{config_version}")
124124
# 远程检查更新
125-
check_url = "https://fastly.jsdelivr.net/gh/GOOD-AN/mys_exch_goods@latest/update_log.json"
126-
check_info = requests.get(check_url, timeout=15).json()
125+
check_info = ''
126+
for check_update_url in gl.CHECK_UPDATE_URL_LIST:
127+
check_url = check_update_url + "/update_log.json"
128+
try:
129+
check_info = requests.get(check_url, timeout=15).json()
130+
break
131+
except requests.exceptions.ConnectionError:
132+
continue
133+
if not check_info:
134+
print("检查更新失败")
135+
return False
127136
remote_least_version = check_info['least_version'].split('.')
128137
local_version = MAIN_VERSION.split('.')
129138
if compare_version(remote_least_version, local_version) == 1:
130139
print("版本过低, 程序将停止运行")
140+
print("项目地址: https://github.com/GOOD-AN/mys_exch_goods")
131141
time.sleep(3)
132142
sys.exit()
133143
remote_last_vesion = check_info['last_vesion'].split('.')
134144
if compare_version(local_version, remote_last_vesion) == -1:
135145
remote_update_log_list = check_info['update_log']
136146
print(f"当前程序版本为v{MAIN_VERSION}, 最新程序版本为v{check_info['last_vesion']}")
137-
print("当前非最新版本,建议更新")
147+
print("当前非最新版本,建议更新\n")
138148
print("更新概览: ")
149+
print("=" * 50)
139150
for update_log in remote_update_log_list:
140151
if compare_version(update_log['version'].split('.'), local_version) == 1:
141-
print(f"版本: {update_log['version']}")
152+
print("版本: ", f"{update_log['version']}".center(12))
142153
print(f"更新时间: {update_log['update_time']}")
143-
print(f"更新说明: {update_log['update_content']}")
154+
print(f"更新说明: {update_log['update_content'][0]}")
155+
for content in update_log['update_content'][1:]:
156+
print(content.rjust(20))
157+
print("=" * 50)
144158
print("项目地址: https://github.com/GOOD-AN/mys_exch_goods")
145159
else:
146160
print(f"当前程序版本为v{MAIN_VERSION}, 配置文件版本为v{config_version}, 版本不匹配可能带来运行问题, 建议更新")
147161
print("项目地址: https://github.com/GOOD-AN/mys_exch_goods")
148-
input("按回车键继续")
149162
return None
150163
except KeyboardInterrupt:
151164
print("强制退出")
152165
sys.exit()
153166
except Exception as err:
154167
print(f"检查更新失败, 原因为{err}, 错误行数为: {err.__traceback__.tb_lineno}")
155-
input("按回车键继续")
156168
return None
157169

158170

config.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
name = Mys_Exch_Goods
33
env = local
44
branch = main
5-
version = 1.1.1
5+
version = 1.1.2
66

77
[user_info]
88
cookie =

global_var.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,8 @@
1010
INI_CONFIG = ConfigParser()
1111
CLEAR_TYPE = ''
1212
MI_COOKIE = ''
13+
CHECK_UPDATE_URL_LIST = [
14+
'https://cdn.jsdelivr.net/gh/GOOD-AN/mys_exch_goods@latest/',
15+
'https://fastly.jsdelivr.net/gh/GOOD-AN/mys_exch_goods@latest/',
16+
'https://github.com/GOOD-AN/Mys-Exchange-Goods/raw/main/'
17+
]

update_log.json

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,22 @@
55
{
66
"version": "1.0.0",
77
"update_time": "2022-09-07",
8-
"update_content": "第一版发布"
8+
"update_content": ["第一版发布"]
99
},
1010
{
1111
"version": "1.1.0",
1212
"update_time": "2022-10-31",
13-
"update_content": "1.新增主程序, 优化使用体验 2.优化部分功能逻辑"
13+
"update_content": ["1.新增主程序, 优化使用体验","2.优化部分功能逻辑"]
1414
},
1515
{
1616
"version": "1.1.1",
1717
"update_time": "2022-10-31",
18-
"update_content": "修复检查更新时的错误"
18+
"update_content": ["修复检查更新时的错误"]
19+
},
20+
{
21+
"version": "1.1.2",
22+
"update_time": "2022-11-01",
23+
"update_content": ["更新检测到新版本时的输出"]
1924
}
2025
]
2126
}

0 commit comments

Comments
 (0)