The only downloader you need. 下载器的集大成者。
TypeScript asyncasynciobittorentbtcross-platformdownload-managerdownloaderfluent-designftphttp3magnetpyqtpyside6pythonqtquicreactsoftwarestreaming
refactor(startup): 理清入口和 startup 的职责
XiaoYouChR3692173915ee
diff --git a/Ghost-Downloader-3.py b/Ghost-Downloader-3.pyindex 8f0ed8b2..e4756a1a 100644--- a/Ghost-Downloader-3.py+++ b/Ghost-Downloader-3.py@@ -50,14 +50,12 @@ def setupEnvironment():def startApp(application, isSilent=False):- import shutilfrom PySide6.QtGui import QIconfrom app.config.cfg import cfg- from app.config.paths import EXECUTABLE_DIRfrom app.view.shell.clipboard_listener import ClipboardListenerfrom app.signal_bus import signalBusfrom app.services.update_service import UpdateService- from app.startup import createEngine, loadPacks, checkUpdateAtStartup+ from app.startup import loadResources, createEngine, deleteBackupDir, loadPacks, checkUpdateAtStartupfrom app.view.windows.main_window import MainWindowdef exceptionHook(exceptionType, value, tb):@@ -78,14 +76,12 @@ def startApp(application, isSilent=False):from app.view.shell.dock import setDockIconVisiblesetDockIconVisible(cfg.shouldShowDockIcon.value, activate=False)+ loadResources(application)engine = createEngine(application)coroutineRunner, taskService, featureService = engine.coroutineRunner, engine.taskService, engine.featureServicebrowserService, speedMeter = engine.browserService, engine.speedMeter- appDir = EXECUTABLE_DIR.parent.parent if sys.platform == "darwin" else EXECUTABLE_DIR- backupDir = appDir.parent / f"{appDir.name}_backup"- if backupDir.is_dir():- shutil.rmtree(backupDir, ignore_errors=True)+ deleteBackupDir()MainWindow.refreshThemeColor()diff --git a/app/startup.py b/app/startup.pyindex a2e63892..bc46d1ac 100644--- a/app/startup.py+++ b/app/startup.py@@ -1,7 +1,15 @@-"""桌面端独有的启动阶段:创建 Engine、加载翻译与 pack、启动时检查更新。"""+"""桌面端独有的准备步骤,每步自成一体、不碰 View。各步的顺序和服务与 View 之间的接线由入口 Ghost-Downloader-3.py 决定。"""from __future__ import annotations+def loadResources(application):+ from PySide6.QtCore import QResource+ from app.config.paths import EXECUTABLE_DIR++ QResource.registerResource(str(EXECUTABLE_DIR / "app" / "assets" / "resources.rcc"))+ loadTranslators(application)++def loadTranslators(application):from PySide6.QtCore import QLocale, QTranslatorfrom app.config.cfg import cfg@@ -22,17 +30,12 @@ def loadTranslators(application):def createEngine(application):import sys- from PySide6.QtCore import QFileSystemWatcher, QResource, QTimer+ from PySide6.QtCore import QFileSystemWatcher, QTimerfrom shiboken6 import isValid- from app.config.paths import EXECUTABLE_DIRfrom app.engine import Enginefrom app.platform.desktop import loadCrxfrom app.services.coroutine_runner import CoroutineRunner- QResource.registerResource(str(EXECUTABLE_DIR / "app" / "assets" / "resources.rcc"))-- loadTranslators(application)-if sys.platform == "win32":from winloop import new_event_loopelse:@@ -46,6 +49,17 @@ def createEngine(application):return Engine(coroutineRunner, QFileSystemWatcher(), loadCrx)+def deleteBackupDir():+ import shutil+ import sys+ from app.config.paths import EXECUTABLE_DIR++ appDir = EXECUTABLE_DIR.parent.parent if sys.platform == "darwin" else EXECUTABLE_DIR+ backupDir = appDir.parent / f"{appDir.name}_backup"+ if backupDir.is_dir():+ shutil.rmtree(backupDir, ignore_errors=True)++def loadPacks(featureService, coroutineRunner, speedMeter):from app.models.pack import PackConfig, PackServicesfrom app.services.update_service import installPendingPacks