diff --git a/app_config.py b/app_config.py index 3328a2d..6cd6dbd 100644 --- a/app_config.py +++ b/app_config.py @@ -30,7 +30,7 @@ DEFAULT_CONFIG = { "grok2api_remote_base": "", "grok2api_remote_app_key": "", "api_reverse_tools": "", - "cpa_export_enabled": False, + "cpa_export_enabled": True, "cpa_auth_dir": "./cpa_auths", "cpa_copy_to_hotload": False, "cpa_hotload_dir": "", @@ -62,6 +62,7 @@ def _require_bool(cfg, key): raise ConfigError(f"配置项 {key} 必须是布尔值 true/false") return value + def _require_int(cfg, key, minimum, maximum): value = cfg.get(key) if type(value) is not int: @@ -70,6 +71,7 @@ def _require_int(cfg, key, minimum, maximum): raise ConfigError(f"配置项 {key} 必须在 {minimum} 到 {maximum} 之间") return value + def _require_string(cfg, key, path=False): value = cfg.get(key) if not isinstance(value, str): @@ -81,6 +83,7 @@ def _require_string(cfg, key, path=False): os.path.expanduser(value) return value + def validate_config_structure(raw): if not isinstance(raw, dict): raise ConfigError("config root must be a JSON object") @@ -141,6 +144,7 @@ def validate_config_structure(raw): cfg[key] = os.path.expanduser(value) return cfg + def validate_run_requirements(cfg): cfg = validate_config_structure(cfg) provider = cfg["email_provider"] @@ -166,6 +170,7 @@ def validate_run_requirements(cfg): raise ConfigError("启用 CPA 热加载复制时必须配置 cpa_hotload_dir") return cfg + def validate_config(raw): """Backward-compatible full validation used before a run or save.""" return validate_run_requirements(raw)