From 7cc75e6f22ea4b7b55c86b045e59aafe2da618d9 Mon Sep 17 00:00:00 2001 From: xystudio889 <173288240@qq.com> Date: Thu, 5 Feb 2026 20:33:33 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=F0=9F=90=9Bfix(update)=203.2.0.18beta7:?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=9B=B4=E6=96=B0=E7=A8=8B=E5=BA=8F=E7=9A=84?= =?UTF-8?q?=E5=A4=A7=E9=87=8Fbug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 修复更新程序bug: - - 如果版本号标签是重制版,那么下载程序无法使用报错404 #152 - - 更新软件索引错误导致更新失败,显示404 #151 - - 如果clickmouse检查到的最新版本没有clickmouse.7z会报错 #140 - 尝试修复了workflow --- .github/workflows/test.yml | 12 +++++------- Gui/check_update.py | 20 +++++++++----------- Gui/main.py | 23 +++++++++++++++-------- Gui/res/versions.json | 2 +- 4 files changed, 30 insertions(+), 27 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index dfd5f2f..0c90d40 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -8,7 +8,7 @@ permissions: contents: read jobs: - build-and-deploy: + tests: runs-on: ubuntu-latest steps: @@ -16,12 +16,10 @@ jobs: - name: Set up Python uses: actions/setup-python@v5 with: - python-version: '3.13' + python-version: '3.13' - name: Install dependencies run: | - cd gui - python -m pip install --upgrade pip - pip install -r tests/requirements.txt + cd ./gui/ + pip install -r ./tests/requirements.txt - name: Test🔍 - run: | - pytest + run: pytest diff --git a/Gui/check_update.py b/Gui/check_update.py index c686ae2..cf50e22 100644 --- a/Gui/check_update.py +++ b/Gui/check_update.py @@ -44,12 +44,12 @@ def get_value_by_indices(data, indices_list): keys_update = None # 检察更新的函数 -def get_version(website: str='github', include_prerelease: bool=False) -> str | None: +def get_version(include_prerelease: bool=False) -> str | None: '''获取最新的版本号''' if keys is None: - return get_lang('b2'), -1 + return [get_lang('b2'), -1] if web_data is None: - return get_lang('b1'), -1 + return [get_lang('b1'), -1] try: web = web_data['api_web'] @@ -58,8 +58,8 @@ def get_version(website: str='github', include_prerelease: bool=False) -> str | else_data = web_data['addtional_info'] releases_tag_condition = web_data['releases_tag_condition'] condition = eval(web_data['condition']) - except Exception as e: - return format_exc(), -1 + except Exception: + return [format_exc(), -1] try: # 获取版本号 @@ -73,27 +73,25 @@ def get_version(website: str='github', include_prerelease: bool=False) -> str | latest_tag = get_value_by_indices(releases, releases_tag_condition) return latest_tag except Exception: - return format_exc(), -1, -1 + return [format_exc(), -1, -1] def check_update( - use_website = 'github', include_prerelease=False ): '''检查更新''' # 获取版本号 installed_version = __version__ version = get_version( - use_website, include_prerelease, ) + version.append(version[0]) version[0] = re.sub(r'-re\d+$', '', version[0]) # 去除结尾重制版标志 latest_version = version[0] version_update_info = version[1] version_data = version[2] - latest_version if version_update_info == -1: # 出错 - return latest_version, -1, -1 + return latest_version, -1, -1, -1 # 获取哈希 if web_data['has_hash']: @@ -116,7 +114,7 @@ def check_update( else: needs_update = False - return needs_update, latest_version, version_update_info, hash_data + return [needs_update, latest_version, version_update_info, hash_data, version[-1]] def download_file(url, save_path): ''' diff --git a/Gui/main.py b/Gui/main.py index f892d91..0cecd0a 100644 --- a/Gui/main.py +++ b/Gui/main.py @@ -1056,12 +1056,17 @@ def on_check_update(self): # 检查更新 self.update_checked = True if should_check_update_res: - self.check_update_thread = QtThread(check_update, args=('github', True)) + self.check_update_thread = QtThread(check_update, args=(False,)) self.check_update_thread.finished.connect(self.on_check_update_result) self.check_update_thread.start() else: logger.info('使用缓存检查更新') self.on_check_update_result(update_cache) + + def save(self): + '''保存更新缓存''' + if should_check_update_res: + save_update_cache(should_update=result[0], latest_version=result[1], update_info=result[2], hash=result[3], update_version_tag=result[4]) # 缓存最新版本 def on_check_update_result(self, check_data): '''检查更新结果''' @@ -1071,14 +1076,17 @@ def on_check_update_result(self, check_data): if should_check_update_res: result = check_data else: - result = (update_cache['should_update'], update_cache['latest_version'], None, update_cache['hash']) # 使用缓存 + result = [update_cache['should_update'], update_cache['latest_version'], None, update_cache['hash'], update_cache['update_version_tag']] # 使用缓存 + + if result[3] is None and web_data['has_hash']: # 哈希为空,但是有哈希属性,说明这个版本没有发布的编译压缩包 + self.save() + result[0] = False # 因为没有最新版本,没有编译后版本,所以认为不需要更新 + return # 检查结果处理 if settings.get('update_notify', 0) in {0}: # 判断是否需要弹出通知 if result[1] != -1: # -1表示函数出错 - if should_check_update_res: - save_update_cache(should_update=result[0], latest_version=result[1], update_info=result[2], hash=result[3]) # 缓存最新版本 - pass + self.save() if result[0]: # 检查到需要更新 logger.info('检查到更新') # 弹出更新窗口 @@ -1092,8 +1100,7 @@ def on_check_update_result(self, check_data): MessageBox.critical(self, get_lang('14'), f'{get_lang('18')}\n{result[0]}') else: if result[1] != -1: - if should_check_update_res: - save_update_cache(should_update=result[0], latest_version=result[1], update_info=result[2], hash=result[3]) + self.save() def on_update(self, judge = False): '''显示更新提示''' @@ -1921,7 +1928,7 @@ def on_update(self): try: self.close() os.rename('updater', 'updater.old') - self.down_thread = QtThread(download_file, args=(web_data['down_web'].format(latest_version=result[1]), 'updater.old/clickmouse.7z')) + self.down_thread = QtThread(download_file, args=(web_data['down_web'].format(latest_version=result[4]), 'updater.old/clickmouse.7z')) self.down_thread.finished.connect(self.on_update_finished) self.down_thread.start() except: diff --git a/Gui/res/versions.json b/Gui/res/versions.json index a9083bb..cc0684e 100644 --- a/Gui/res/versions.json +++ b/Gui/res/versions.json @@ -1 +1 @@ -{"package_format_version": "1.2.0", "clickmouse":"3.2.0.18beta6"} +{"package_format_version": "1.2.0", "clickmouse":"3.2.0.18beta7"} From 8156d94613b0078aab5345dec1a8a5ea5be88c09 Mon Sep 17 00:00:00 2001 From: xystudio889 <173288240@qq.com> Date: Thu, 5 Feb 2026 20:52:30 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=F0=9F=9B=92ci(workflow)=E4=BF=AE=E6=94=B9w?= =?UTF-8?q?orkflow?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 修改workflow - - 多个版本的pytest测试 - - pr时候触发 --- .github/workflows/test.yml | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 0c90d40..0b25f67 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -3,23 +3,31 @@ name: Running tests on: push: pull_request: + types: + - opened + - synchronize permissions: contents: read jobs: - tests: + run_tests: runs-on: ubuntu-latest - + strategy: + matrix: + python-version: ['3.8', '3.9', '3.10', '3.11', '3.12', '3.13', '3.14'] steps: - uses: actions/checkout@v4 - name: Set up Python uses: actions/setup-python@v5 with: - python-version: '3.13' + python-version: ${{ matrix.python-version }} - name: Install dependencies run: | - cd ./gui/ + cd ./Gui/ + python -m pip install --upgrade pip pip install -r ./tests/requirements.txt - name: Test🔍 - run: pytest + run: | + python --version + pytest