Skip to content

Commit

Permalink
新增自动更新exe
Browse files Browse the repository at this point in the history
  • Loading branch information
LC044 committed Mar 2, 2024
1 parent 884a953 commit 964f4b0
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions app/ui/mainview.py
Original file line number Diff line number Diff line change
Expand Up @@ -457,15 +457,14 @@ def show_update(self, update_info):
# 添加自定义按钮
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):
"""
关于
Expand All @@ -485,6 +484,8 @@ def close(self) -> bool:

super().close()
self.exitSignal.emit(True)


class UpdateThread(QThread):
updateSignal = pyqtSignal(dict)

Expand All @@ -510,7 +511,7 @@ def run(self):

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)
Expand All @@ -521,4 +522,4 @@ def run(self):
print("检查更新失败")
except:
update_info = {'update_available': False}
self.updateSignal.emit(update_info)
self.updateSignal.emit(update_info)

0 comments on commit 964f4b0

Please sign in to comment.