refactor(ai): 配置页单列卡片重构 + 移除无用的 Token 预算

- AI 设置页改为单列分卡片布局(Card/Field/Toggle 辅助组件),自定义配置卡
  头部标注「Chat Completions」
- 移除从未实际生效的 ai_daily_token_budget(后端 config/api/settings +
  前端 Settings 接口与保存参数 + UI)
- 测试结果不再展示 token 消耗,仅显示「连通成功 · 模型: xxx」
This commit is contained in:
shy3130
2026-06-25 15:53:15 +08:00
parent 76ec644f35
commit 37ebe19f1e
5 changed files with 160 additions and 95 deletions
-4
View File
@@ -57,7 +57,6 @@ def get_settings() -> dict:
"ai_api_key_masked": secrets_store.mask(secrets_store.get_ai_key()),
"has_ai_key": bool(secrets_store.get_ai_key()),
"ai_model": secrets_store.get_ai_config("ai_model", settings.ai_model),
"ai_daily_token_budget": int(secrets_store.get_ai_config("ai_daily_token_budget", str(settings.ai_daily_token_budget)) or settings.ai_daily_token_budget),
"ai_user_agent": secrets_store.get_ai_config("ai_user_agent", settings.ai_user_agent),
}
@@ -212,7 +211,6 @@ class AiSettingsIn(BaseModel):
base_url: str = ""
api_key: str | None = None
model: str = ""
daily_token_budget: int = 500_000
user_agent: str = ""
@@ -238,8 +236,6 @@ def save_ai_settings(req: AiSettingsIn) -> dict:
if req.model:
updates["ai_model"] = req.model
settings.ai_model = req.model
updates["ai_daily_token_budget"] = req.daily_token_budget
settings.ai_daily_token_budget = req.daily_token_budget
# user_agent 允许清空(回到默认浏览器 UA),故无条件持久化
updates["ai_user_agent"] = req.user_agent
settings.ai_user_agent = req.user_agent