|
@@ -14,39 +14,30 @@ from constant import constant
|
|
|
from loguru import logger
|
|
|
|
|
|
|
|
|
-def _get(show_no_new_version_tip=False):
|
|
|
- """
|
|
|
- 异步解析
|
|
|
+class UpgradeThread(threading.Thread):
|
|
|
+ def __init__(self, parent, show_no_new_version_tip=False):
|
|
|
+ """
|
|
|
+ :param parent: 主线程UI
|
|
|
+ """
|
|
|
+ super(UpgradeThread, self).__init__()
|
|
|
+ self.parent = parent
|
|
|
+ self.show_no_new_version_tip = show_no_new_version_tip
|
|
|
+ self.setDaemon(True)
|
|
|
|
|
|
- 参数:
|
|
|
- show_no_new_version_tip (bool): 是否显示没有新版本提示,默认为False
|
|
|
- """
|
|
|
- url = 'https://gitee.com/lpf_project/common-tools/tags'
|
|
|
- wb_data = requests.get(url)
|
|
|
- soup = BeautifulSoup(wb_data.text, 'html.parser')
|
|
|
- tags = soup.select('div.tag-item-action.tag-name>a')
|
|
|
- is_has_new_version = False
|
|
|
- for tag in tags:
|
|
|
- version = ''.join(list(filter(str.isdigit, tag['title'])))
|
|
|
+ def run(self):
|
|
|
+ url = 'https://gitee.com/lpf_project/RuoYi-MT/releases'
|
|
|
+ wb_data = requests.get(url)
|
|
|
+ soup = BeautifulSoup(wb_data.text, 'html.parser')
|
|
|
+ tags = soup.select('div .release-tag-item .release-meta .tag-name')
|
|
|
+ if len(tags) == 0:
|
|
|
+ return
|
|
|
+ content = soup.select(
|
|
|
+ 'div .release-tag-item .release-body .content .markdown-body p')[0].text
|
|
|
+ tag = tags[0]
|
|
|
+ version = ''.join(list(filter(str.isdigit, tag['data-tag-name'])))
|
|
|
if int(version) > constant.APP_VERSION_INT:
|
|
|
- is_has_new_version = True
|
|
|
- logger.info('检查更新结果:发现新的版本-{}', tag['title'])
|
|
|
- wx.MessageDialog(
|
|
|
- None, '发现新的版本【%s】,请前往gitee下载,\ngitee地址可以查看“关于我们”中的“软件官网”' %
|
|
|
- tag['title'], '版本升级提醒', wx.OK).ShowModal()
|
|
|
- break
|
|
|
- if not is_has_new_version:
|
|
|
- logger.info('检查更新结果:当前版本是最新版本!')
|
|
|
- if show_no_new_version_tip:
|
|
|
- wx.MessageDialog(None, '当前版本是最新版本!', '检测更新', wx.OK).ShowModal()
|
|
|
-
|
|
|
-
|
|
|
-def check(show_no_new_version_tip=False):
|
|
|
- """
|
|
|
- 检测更新
|
|
|
-
|
|
|
- 参数:
|
|
|
- show_no_new_version_tip (bool): 是否显示没有新版本提示,默认为False
|
|
|
- """
|
|
|
- thread = threading.Thread(target=_get, args=(show_no_new_version_tip, ))
|
|
|
- thread.start()
|
|
|
+ wx.CallAfter(self.parent.upgrade_call_after, True,
|
|
|
+ self.show_no_new_version_tip, tag['data-tag-name'], content)
|
|
|
+ else:
|
|
|
+ wx.CallAfter(self.parent.upgrade_call_after,
|
|
|
+ False, self.show_no_new_version_tip)
|