新增自动更新exe

This commit is contained in:
SiYuan 2024-03-02 23:04:15 +08:00
parent 884a953207
commit 964f4b0b54

View File

@ -457,15 +457,14 @@ class MainWinController(QMainWindow, mainwindow.Ui_MainWindow, QCursorGif):
# 添加自定义按钮
custom_button = error_box.addButton('更新', QMessageBox.ActionRole)
is_update_online = update_info.get('is_update_online')
custom_button.clicked.connect(lambda x:self.update_(update_info.get('download_url'),is_update_online))
custom_button.clicked.connect(lambda x: self.update_(update_info.get('download_url'), is_update_online))
error_box.addButton(QMessageBox.Cancel)
# 显示对话框
error_box.exec_()
def update_(self, url,is_update_online):
def update_(self, url, is_update_online):
QDesktopServices.openUrl(QUrl("https://memotrace.cn/"))
def about(self):
"""
关于
@ -485,6 +484,8 @@ class MainWinController(QMainWindow, mainwindow.Ui_MainWindow, QCursorGif):
super().close()
self.exitSignal.emit(True)
class UpdateThread(QThread):
updateSignal = pyqtSignal(dict)
@ -510,7 +511,7 @@ class UpdateThread(QThread):
with open(INFO_FILE_PATH, "w", encoding="utf-8") as f:
json.dump(data, f, ensure_ascii=False, indent=4)
server_url = urljoin(SERVER_API_URL,'update')
server_url = urljoin(SERVER_API_URL, 'update')
data = {'version': version}
try:
response = requests.post(server_url, json=data)
@ -521,4 +522,4 @@ class UpdateThread(QThread):
print("检查更新失败")
except:
update_info = {'update_available': False}
self.updateSignal.emit(update_info)
self.updateSignal.emit(update_info)