diff --git a/app/core/config.py b/app/core/config.py index 39b40d8..5107495 100644 --- a/app/core/config.py +++ b/app/core/config.py @@ -745,8 +745,21 @@ class AppConfig: class GlobalConfig(QConfig): """全局配置""" + function_HomePage = OptionsConfigItem( + "Function", + "HomePage", + "https://ak.hypergryph.com/#information", + OptionsValidator( + [ + "https://ak.hypergryph.com/#information", + "https://ak-webview.hypergryph.com/gameBulletin", + "https://ak.hypergryph.com/user/home", + "https://prts.wiki/w/%E9%A6%96%E9%A1%B5", + ] + ), + ) function_HistoryRetentionTime = OptionsConfigItem( - "Function", "HistoryRetentionTime", 7, OptionsValidator([7, 15, 30, 60, 0]) + "Function", "HistoryRetentionTime", 0, OptionsValidator([7, 15, 30, 60, 0]) ) function_IfAllowSleep = ConfigItem( "Function", "IfAllowSleep", False, BoolValidator() diff --git a/app/ui/home.py b/app/ui/home.py index 7e17c8a..779a045 100644 --- a/app/ui/home.py +++ b/app/ui/home.py @@ -30,10 +30,11 @@ from PySide6.QtWidgets import ( QFrame, QVBoxLayout, ) -from qfluentwidgets import TitleLabel from qframelesswindow.webengine import FramelessWebEngineView from PySide6.QtCore import QUrl +from app.core import Config + class Home(QFrame): @@ -41,12 +42,26 @@ class Home(QFrame): super().__init__(parent=parent) self.setObjectName("主界面") - # self.webView = FramelessWebEngineView(self) - # self.webView.load(QUrl("https://github.com/DLmaster361/AUTO_MAA")) - self.Lable = TitleLabel(" 正在施工中~") + self.webView = FramelessWebEngineView(self) self.vBoxLayout = QVBoxLayout(self) self.vBoxLayout.setContentsMargins(0, 0, 0, 0) - # self.vBoxLayout.addWidget(self.webView) - self.vBoxLayout.addWidget(self.Lable) - self.vBoxLayout.addStretch(1) + self.vBoxLayout.addWidget(self.webView) + + self.current_url = None + + self.refresh() + + def refresh(self): + + if ( + Config.global_config.get(Config.global_config.function_HomePage) + != self.current_url + ): + + self.webView.load( + QUrl(Config.global_config.get(Config.global_config.function_HomePage)) + ) + self.current_url = Config.global_config.get( + Config.global_config.function_HomePage + ) diff --git a/app/ui/main_window.py b/app/ui/main_window.py index d7d1265..aee7f7f 100644 --- a/app/ui/main_window.py +++ b/app/ui/main_window.py @@ -125,6 +125,9 @@ class AUTO_MAA(MSFluentWindow): FluentIcon.SETTING, NavigationItemPosition.BOTTOM, ) + self.stackedWidget.currentChanged.connect( + lambda index: (self.home.refresh() if index == 0 else None) + ) self.stackedWidget.currentChanged.connect( lambda index: (self.member_manager.refresh() if index == 1 else None) ) diff --git a/app/ui/setting.py b/app/ui/setting.py index c90a62f..bea1e81 100644 --- a/app/ui/setting.py +++ b/app/ui/setting.py @@ -414,6 +414,18 @@ class FunctionSettingCard(HeaderCardWidget): super().__init__(parent) self.setTitle("功能") + self.card_HomePage = ComboBoxSettingCard( + configItem=Config.global_config.function_HomePage, + icon=FluentIcon.PAGE_RIGHT, + title="主页内容", + content="选择AUTO_MAA主页展示的内容", + texts=[ + "明日方舟官网情报", + "明日方舟游戏公告", + "明日方舟个人中心", + "PRTS百科网站首页", + ], + ) self.card_HistoryRetentionTime = ComboBoxSettingCard( configItem=Config.global_config.function_HistoryRetentionTime, icon=FluentIcon.PAGE_RIGHT, @@ -436,6 +448,7 @@ class FunctionSettingCard(HeaderCardWidget): ) Layout = QVBoxLayout() + Layout.addWidget(self.card_HomePage) Layout.addWidget(self.card_HistoryRetentionTime) Layout.addWidget(self.card_IfAllowSleep) Layout.addWidget(self.card_IfSilence) diff --git a/main.py b/main.py index badf293..fc4638c 100644 --- a/main.py +++ b/main.py @@ -32,7 +32,7 @@ from qfluentwidgets import FluentTranslator import sys -# @logger.catch +@logger.catch def main(): application = QApplication(sys.argv)