fix: 三端联调 P1 修复 — API密钥页崩溃 + 桌面端401恢复 + 用量统计全零
Some checks failed
CI / Lint & TypeCheck (push) Has been cancelled
CI / Unit Tests (push) Has been cancelled
CI / Build Frontend (push) Has been cancelled
CI / Rust Check (push) Has been cancelled
CI / Security Scan (push) Has been cancelled
CI / E2E Tests (push) Has been cancelled

P1-03: vite.config.ts proxy '/api' → '/api/' 加尾部斜杠,
  防止前缀匹配 /api-keys 导致 SPA 路由崩溃

P1-01: kernel_init 增加 api_key 变更检测(token 刷新后自动重连),
  streamStore 增加 401 自动恢复(refresh token → kernel reconnect),
  KernelClient 新增 getConfig() 方法

P1-02: /api/v1/usage 总计改从 billing_usage_quotas 读取
  (authoritative source,SSE 和 JSON 均写入),
  by_model/by_day 仍从 usage_records 读取
This commit is contained in:
iven
2026-04-14 22:02:02 +08:00
parent 6721a1cc6e
commit e0eb7173c5
5 changed files with 85 additions and 24 deletions

View File

@@ -73,15 +73,18 @@ pub async fn kernel_init(
// Get current config from kernel
let current_config = kernel.config();
// Check if config changed
// Check if config changed (model, base_url, or api_key)
let config_changed = if let Some(ref req) = config_request {
let default_base_url = zclaw_kernel::config::KernelConfig::from_provider(
&req.provider, "", &req.model, None, &req.api_protocol
).llm.base_url;
let request_base_url = req.base_url.clone().unwrap_or(default_base_url.clone());
let current_api_key = &current_config.llm.api_key;
let request_api_key = req.api_key.as_deref().unwrap_or("");
current_config.llm.model != req.model ||
current_config.llm.base_url != request_base_url
current_config.llm.base_url != request_base_url ||
current_api_key != request_api_key
} else {
false
};