55# @Author : DebuggerX
66
77import configparser
8+ import os
9+ import sys
810from urllib import request
911from json import loads
1012
1921check_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+
2231def _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
5059def 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
0 commit comments