Skip to content

Commit 2a09aaa

Browse files
committed
修改版本提示框按钮和对应逻辑;优化版本忽略文件的路径读取逻辑
1 parent 0466b3f commit 2a09aaa

File tree

2 files changed

+22
-7
lines changed

2 files changed

+22
-7
lines changed

check_version.py

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
# @Author : DebuggerX
66

77
import configparser
8+
import os
9+
import sys
810
from urllib import request
911
from json import loads
1012

@@ -19,12 +21,19 @@
1921
check_last_version_thread = None
2022

2123

24+
def get_exe_path():
25+
if getattr(sys, 'frozen', False):
26+
return os.path.dirname(sys.executable)
27+
else:
28+
return os.path.dirname(__file__)
29+
30+
2231
def _check_ignore_version():
2332
config = configparser.ConfigParser()
2433
global ignore_code
2534
# noinspection PyBroadException
2635
try:
27-
config.read('.ignore.cfg')
36+
config.read(os.path.join(get_exe_path(), '.ignore.cfg'))
2837
ignore_code = float(config.get('version', 'code'))
2938
except Exception:
3039
pass
@@ -48,16 +57,22 @@ def run(self):
4857

4958

5059
def check_last_version_handler(json_obj):
51-
res = QMessageBox().information(msg_box_ui, "有新版本更新!", "新版本(v%s)更新内容:\n%s\n\n点击[确定]转跳到下载页,点击[取消]忽略该版本提醒" % (json_obj['code'], json_obj['desc']),
52-
QMessageBox.Ok,
53-
QMessageBox.Cancel)
54-
if res == QMessageBox.Cancel:
60+
msg_box = QMessageBox()
61+
msg_box.addButton('确定', QMessageBox.AcceptRole)
62+
msg_box.addButton('忽略', QMessageBox.NoRole)
63+
msg_box.addButton('关闭', QMessageBox.RejectRole)
64+
msg_box.setParent(msg_box_ui)
65+
msg_box.setWindowTitle("有新版本更新!")
66+
msg_box.setText("新版本(v%s)更新内容:\n%s\n\n点击[确定]转跳到下载页,点击[忽略]忽略该版本提醒,点击[关闭]退出本提示框" % (json_obj['code'], json_obj['desc']))
67+
68+
res = msg_box.exec()
69+
if res == QMessageBox.RejectRole:
5570
config = configparser.ConfigParser()
5671
config.add_section('version')
5772
config.set('version', 'code', str(json_obj['code']))
58-
with open('.ignore.cfg', 'w') as configfile:
73+
with open(os.path.join(get_exe_path(), '.ignore.cfg'), 'w') as configfile:
5974
config.write(configfile)
60-
else:
75+
elif res == QMessageBox.AcceptRole:
6176
QtGui.QDesktopServices.openUrl(QtCore.QUrl('https://github.com/debuggerx01/JSONFormat4Flutter/releases'))
6277

6378

logo.ico

66.1 KB
Binary file not shown.

0 commit comments

Comments
 (0)