From c52820550fef62ecc8780f6563c1e5971f49efc3 Mon Sep 17 00:00:00 2001 From: DLmaster361 Date: Sat, 12 Jul 2025 21:54:40 +0800 Subject: [PATCH] =?UTF-8?q?feat(ui):=20=E6=B7=BB=E5=8A=A0=E5=AF=BC?= =?UTF-8?q?=E5=85=A5=E5=AF=BC=E5=87=BA=E9=80=9A=E7=94=A8=E9=85=8D=E7=BD=AE?= =?UTF-8?q?=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/ui/member_manager.py | 71 ++++++++++++++++++++++++++++++++++++++++ resources/version.json | 3 ++ 2 files changed, 74 insertions(+) diff --git a/app/ui/member_manager.py b/app/ui/member_manager.py index 406c883..956bc78 100644 --- a/app/ui/member_manager.py +++ b/app/ui/member_manager.py @@ -2297,11 +2297,15 @@ class MemberManager(QWidget): self.card_Script = self.ScriptSettingCard(self.config, self) self.card_Game = self.GameSettingCard(self.config, self) self.card_Run = self.RunSettingCard(self.config, self) + self.card_Config = self.ConfigSettingCard( + self.name, self.config, self + ) Layout.addWidget(self.card_Name) Layout.addWidget(self.card_Script) Layout.addWidget(self.card_Game) Layout.addWidget(self.card_Run) + Layout.addWidget(self.card_Config) self.viewLayout.addLayout(Layout) class ScriptSettingCard(ExpandGroupSettingCard): @@ -2615,6 +2619,73 @@ class MemberManager(QWidget): self.viewLayout.setSpacing(0) self.addGroupWidget(widget) + class ConfigSettingCard(ExpandGroupSettingCard): + + def __init__(self, name: str, config: GeneralConfig, parent=None): + super().__init__( + FluentIcon.SETTING, + "配置管理", + "使用配置模板文件快速设置脚本", + parent, + ) + self.name = name + self.config = config + + self.card_ImportFromFile = PushSettingCard( + text="从文件导入", + icon=FluentIcon.PAGE_RIGHT, + title="从文件导入通用配置", + content="选择一个配置文件,导入其中的配置信息", + parent=self, + ) + self.card_ExportToFile = PushSettingCard( + text="导出到文件", + icon=FluentIcon.PAGE_RIGHT, + title="导出通用配置到文件", + content="选择一个保存路径,将当前配置信息导出到文件", + parent=self, + ) + + self.card_ImportFromFile.clicked.connect(self.import_from_file) + self.card_ExportToFile.clicked.connect(self.export_to_file) + + widget = QWidget() + Layout = QVBoxLayout(widget) + Layout.addWidget(self.card_ImportFromFile) + Layout.addWidget(self.card_ExportToFile) + self.viewLayout.setContentsMargins(0, 0, 0, 0) + self.viewLayout.setSpacing(0) + self.addGroupWidget(widget) + + def import_from_file(self): + """从文件导入配置""" + + file_path, _ = QFileDialog.getOpenFileName( + self, "选择配置文件", "", "JSON Files (*.json)" + ) + if file_path: + + shutil.copy( + file_path, + Config.member_dict[self.name]["Path"] / "config.json", + ) + self.config.load( + Config.member_dict[self.name]["Path"] / "config.json" + ) + + def export_to_file(self): + """导出配置到文件""" + + file_path, _ = QFileDialog.getSaveFileName( + self, "选择保存路径", "", "JSON Files (*.json)" + ) + if file_path: + + temp = self.config.toDict() + temp["Script"]["Name"] = Path(file_path).stem + with open(file_path, "w", encoding="utf-8") as file: + json.dump(temp, file, ensure_ascii=False, indent=4) + class BranchManager(HeaderCardWidget): """分支管理父页面""" diff --git a/resources/version.json b/resources/version.json index 3d58ed5..3226b06 100644 --- a/resources/version.json +++ b/resources/version.json @@ -2,6 +2,9 @@ "main_version": "4.4.0.5", "version_info": { "4.4.0.5": { + "新增功能": [ + "添加导入导出通用配置功能" + ], "修复BUG": [ "修复开机自启相关功能" ]