From 27115942eae804c88d87140b686f4d63f3a3d5ad Mon Sep 17 00:00:00 2001 From: qinglong Date: Sun, 14 Jun 2026 10:39:03 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20InitService=E8=87=AA=E5=8A=A8=E5=90=88?= =?UTF-8?q?=E5=B9=B6=E6=A8=A1=E6=9D=BF=E6=96=B0=E5=A2=9E=E5=AD=97=E6=AE=B5?= =?UTF-8?q?(=E8=A7=A3=E5=86=B3=E6=97=A7config=E7=BC=BAbranch=E9=97=AE?= =?UTF-8?q?=E9=A2=98)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- services/init_service.py | 19 ++++++++++++++++++- services/update_service.py | 2 +- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/services/init_service.py b/services/init_service.py index 57f3cd2..606f1f3 100644 --- a/services/init_service.py +++ b/services/init_service.py @@ -116,7 +116,24 @@ class InitService: base_config_file = self.config_path / "base_config.yaml" if base_config_file.exists(): with open(base_config_file, 'r', encoding='utf-8') as f: - self.configs['base'] = yaml.safe_load(f) + loaded = yaml.safe_load(f) or {} + # 合并模板中新增的字段 (不影响用户已修改的值) + template_file = self.config_path / "base_config.yaml.example" + if template_file.exists(): + try: + with open(template_file, 'r', encoding='utf-8') as tf: + template = yaml.safe_load(tf) or {} + def _deep_merge(base, tpl): + for k, v in tpl.items(): + if k not in base: + base[k] = v + elif isinstance(v, dict) and isinstance(base.get(k), dict): + _deep_merge(base[k], v) + _deep_merge(loaded, template) + self._save_config(base_config_file, loaded) + except Exception: + pass + self.configs['base'] = loaded logger.debug("基础配置加载成功") else: # 从模板复制 diff --git a/services/update_service.py b/services/update_service.py index 212f789..fcf6126 100644 --- a/services/update_service.py +++ b/services/update_service.py @@ -85,7 +85,7 @@ class UpdateService: cfg = init.get_config("base").get("framework", {}) except Exception: cfg = {} - self.branch = cfg.get("branch", "dev") + self.branch = cfg.get("branch", "main") self.repo_url = cfg.get("repo_url", "https://git.yeij.top/AskaEth/SenSu").rstrip("/") self.repo_name = self.repo_url.rstrip("/").split("/")[-1] # ZIP 下载地址: Gitea 格式