The only downloader you need. 下载器的集大成者。
TypeScript asyncasynciobittorentbtcross-platformdownload-managerdownloaderfluent-designftphttp3magnetpyqtpyside6pythonqtquicreactsoftwarestreaming
feat(app): 添加异常捕获和反馈功能
XiaoYouChR84b57c40125b
diff --git a/app/supports/application.py b/app/supports/application.pyindex e5f57f67..0962204c 100644--- a/app/supports/application.py+++ b/app/supports/application.py@@ -86,5 +86,5 @@ def exceptionHook(exception: BaseException, value, tb):""" exception callback function """message = '\n'.join([''.join(traceback.format_tb(tb)),'{0}: {1}'.format(exception.__name__, value)])- logger.opt(exception=(exception, value, tb)).error("Unhandled application exception")+ logger.opt(exception=exception).error("Unhandled application exception")signalBus.catchException.emit(message)diff --git a/app/supports/utils.py b/app/supports/utils.pyindex 69e00568..485d86a9 100644--- a/app/supports/utils.py+++ b/app/supports/utils.py@@ -5,7 +5,7 @@ from functools import wrapsfrom time import sleepfrom typing import Callable-from PySide6.QtCore import QUrl, QOperatingSystemVersion+from PySide6.QtCore import QUrl, QOperatingSystemVersion, Qtfrom PySide6.QtGui import QDesktopServices, QColorfrom loguru import loggerfrom qfluentwidgets import MessageBox, setThemeColor@@ -245,6 +245,7 @@ def bringWindowToTop(window):def showMessageBox(self, title: str, content: str, showYesButton=False, yesSlot=None):"""show message box"""w = MessageBox(title, content, self)+ w.contentLabel.setTextInteractionFlags(Qt.TextInteractionFlag.TextSelectableByMouse)if not showYesButton:w.cancelButton.setText("关闭")w.yesButton.hide()diff --git a/app/view/windows/main_window.py b/app/view/windows/main_window.pyindex 9bc4324a..2471fde1 100644--- a/app/view/windows/main_window.py+++ b/app/view/windows/main_window.py@@ -11,11 +11,11 @@ from qfluentwidgets import MSFluentWindow, SplashScreen, FluentIcon, NavigationIfrom app.services.browser_service import BrowserServicefrom app.services.core_service import coreServicefrom app.services.feature_service import featureService-from app.supports.config import cfg, DEFAULT_HEADERS, AUTHOR_URL, VERSION+from app.supports.config import cfg, DEFAULT_HEADERS, AUTHOR_URL, VERSION, FEEDBACK_URLfrom app.supports.recorder import taskRecorderfrom app.supports.signal_bus import signalBusfrom app.supports.update import fetchLatestRelease, hasNewerRelease, releaseVersion, selectCurrentPlatformAsset-from app.supports.utils import getProxies, bringWindowToTop+from app.supports.utils import getProxies, bringWindowToTop, showMessageBoxfrom app.view.components.add_task_dialog import AddTaskDialogfrom app.view.components.release_info_dialog import ReleaseInfoDialogfrom app.view.components.tray import SystemTrayIcon@@ -62,6 +62,7 @@ class MainWindow(MSFluentWindow):def connectSignalToSlot(self):signalBus.showMainWindow.connect(lambda: bringWindowToTop(self))+ signalBus.catchException.connect(self._onExceptionCaught)cfg.enableClipboardListener.valueChanged.connect(self._syncClipboardListener)def _syncClipboardListener(self):@@ -100,6 +101,20 @@ class MainWindow(MSFluentWindow):bringWindowToTop(self)self.showAddTaskDialog(urls=urls)+ def _onExceptionCaught(self, message: str):+ bringWindowToTop(self)+ showMessageBox(+ self,+ self.tr("程序发生异常"),+ self.tr("点击“确定”后将复制错误信息并打开反馈页面。\n{0}").format(message),+ showYesButton=True,+ yesSlot=lambda: self._copyExceptionAndOpenFeedback(message),+ )++ def _copyExceptionAndOpenFeedback(self, message: str):+ QApplication.clipboard().setText(message)+ QDesktopServices.openUrl(QUrl(FEEDBACK_URL))+def getAddTaskDialog(self) -> AddTaskDialog:if AddTaskDialog.instance is None:instance = AddTaskDialog.initialize(self)