fix: 三端联调测试 2 P1 + 2 P2 + 4 P3 修复
P1-07: billing get_or_create_usage 同步 max_* 列到当前计划限额 P1-08: relay handler 增加直接配额检查 (relay_requests/input/output_tokens) P2-09: relay failover 成功后记录 tokens 并标记 completed P2-10: Tauri agentStore saas-relay 模式下从 SaaS API 获取真实用量 P2-14: super_admin 合成 subscription + check_quota 放行 P3-19: 新建 ApiKeys.tsx 页面替代 ModelServices 路由 P3-15: antd destroyOnClose → destroyOnHidden (3处) P3-16: ProTable onSearch → onSubmit (2处)
This commit is contained in:
@@ -10,6 +10,7 @@ import type { AgentTemplateFull } from '../lib/saas-client';
|
||||
import { saasClient } from '../lib/saas-client';
|
||||
import { useChatStore } from './chatStore';
|
||||
import { useConversationStore } from './chat/conversationStore';
|
||||
import { getGatewayVersion } from './connectionStore';
|
||||
import { useSaaSStore } from './saasStore';
|
||||
import { createLogger } from '../lib/logger';
|
||||
|
||||
@@ -338,6 +339,22 @@ export const useAgentStore = create<AgentStore>((set, get) => ({
|
||||
byModel: {},
|
||||
};
|
||||
|
||||
// P2-10 修复: saas-relay 模式下从服务端获取真实用量
|
||||
const gwVersion = getGatewayVersion();
|
||||
if (gwVersion === 'saas-relay') {
|
||||
try {
|
||||
const sub = await saasClient.getSubscription();
|
||||
if (sub?.usage) {
|
||||
const serverTokens = (sub.usage.input_tokens ?? 0) + (sub.usage.output_tokens ?? 0);
|
||||
if (serverTokens > 0) {
|
||||
stats.totalTokens = serverTokens;
|
||||
}
|
||||
}
|
||||
} catch {
|
||||
// 降级到本地计数器
|
||||
}
|
||||
}
|
||||
|
||||
set({ usageStats: stats });
|
||||
} catch {
|
||||
// Usage stats are non-critical, ignore errors silently
|
||||
|
||||
Reference in New Issue
Block a user