From ef7763dea06daf0e52c32e52876bc3e0d76ee317 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=AC=A7=E9=98=B3=E6=B7=87=E6=B7=87?= <35864297+hyb-oyqq@users.noreply.github.com> Date: Wed, 17 Dec 2025 23:37:34 +0800 Subject: [PATCH] =?UTF-8?q?refactor(extraction=5Fthread):=20=E4=BC=98?= =?UTF-8?q?=E5=8C=96=E5=8E=8B=E7=BC=A9=E5=8C=85=E5=86=85=E5=AE=B9=E5=88=86?= =?UTF-8?q?=E6=9E=90=E7=9A=84=E6=97=A5=E5=BF=97=E8=BE=93=E5=87=BA=E6=A0=BC?= =?UTF-8?q?=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 将文件类型判断逻辑提取为变量,提高代码可读性。 --- source/build.spec | 6 +++++- source/workers/extraction_thread.py | 4 +++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/source/build.spec b/source/build.spec index e384961..8cb5704 100644 --- a/source/build.spec +++ b/source/build.spec @@ -6,6 +6,10 @@ from PyInstaller.utils.hooks import collect_submodules, collect_data_files block_cipher = None +# 获取spec文件所在目录的绝对路径 +SPEC_ROOT = os.path.dirname(os.path.abspath(SPEC)) +ICON_PATH = os.path.join(SPEC_ROOT, 'assets', 'images', 'ICO', 'icon.ico') + # 收集所有子模块 hiddenimports = [] hiddenimports += collect_submodules('workers') @@ -67,5 +71,5 @@ exe = EXE( target_arch=None, codesign_identity=None, entitlements_file=None, - icon='assets/images/ICO/icon.ico', + icon=ICON_PATH, ) diff --git a/source/workers/extraction_thread.py b/source/workers/extraction_thread.py index f46bba3..346d566 100644 --- a/source/workers/extraction_thread.py +++ b/source/workers/extraction_thread.py @@ -105,7 +105,9 @@ class ExtractionThread(QThread): debug_logger.debug(f"压缩包内容分析:") debug_logger.debug(f"- 文件总数: {len(file_list)}") for i, f in enumerate(file_list): - debug_logger.debug(f" {i+1}. {f} - 类型: {'文件夹' if f.endswith('/') or f.endswith('\\') else '文件'}") + is_folder = f.endswith('/') or f.endswith('\\') + file_type = '文件夹' if is_folder else '文件' + debug_logger.debug(f" {i+1}. {f} - 类型: {file_type}") update_progress(20, f"正在分析 {self.game_version} 的补丁文件...")