@yuku123/z-team-component 0.2.44 → 0.2.46

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,11 +1,12 @@
1
1
  import { jsxs as s, jsx as e } from "react/jsx-runtime";
2
- import { CopyOutlined as se, ReloadOutlined as Ne, PlusOutlined as ve, DeleteOutlined as Pe, ClearOutlined as Ie, CloseOutlined as Be, SendOutlined as $e, RobotOutlined as Te, CloudServerOutlined as Oe, MessageOutlined as De, KeyOutlined as Le, ApiOutlined as ze, ToolOutlined as Re, BarChartOutlined as Ue } from "@ant-design/icons";
3
- import { Tooltip as Q, Tabs as Ce, Button as z, Modal as ce, Input as Se, Drawer as we, Spin as V, Statistic as B, Table as Ae, message as F, Tag as G, Select as He, Checkbox as qe } from "antd";
4
- import { useState as S, useCallback as H, useEffect as ae, useRef as de, useMemo as xe, Suspense as je, lazy as Fe } from "react";
2
+ import { CopyOutlined as se, ReloadOutlined as Te, PlusOutlined as Se, DeleteOutlined as $e, ClearOutlined as Oe, CloseOutlined as De, SendOutlined as Le, RobotOutlined as Ce, CloudServerOutlined as ze, MessageOutlined as Re, KeyOutlined as Ue, ApiOutlined as He, ToolOutlined as je, BarChartOutlined as qe } from "@ant-design/icons";
3
+ import { Tooltip as W, Tabs as Ae, Button as L, Modal as de, Input as we, Drawer as xe, Spin as V, Statistic as B, Table as Ke, message as J, Tag as Q, Select as Fe, Checkbox as Ge } from "antd";
4
+ import { useState as S, useEffect as X, useCallback as H, useRef as me, useMemo as Me, Suspense as Je, lazy as Qe } from "react";
5
5
  import { s as t } from "./SmartWorkbench.module-xRRmpTTw.js";
6
- import { AgentAppList as Ge, McpPage as Je, SkillMarket as Qe } from "@yuku123/z-agent-component";
7
- const le = "ft_gateway_default_ak", X = "", ue = "";
8
- function Z(a = {}) {
6
+ import { u as be } from "./useAppStore-ibJyVIAX.js";
7
+ import { AgentAppList as We, McpPage as Ye, SkillMarket as Ve } from "@yuku123/z-agent-component";
8
+ const le = "ft_gateway_default_ak", Z = "", he = "";
9
+ function ee(a = {}) {
9
10
  const n = { Accept: "application/json", ...a };
10
11
  try {
11
12
  const l = localStorage.getItem("token");
@@ -14,7 +15,7 @@ function Z(a = {}) {
14
15
  }
15
16
  return n;
16
17
  }
17
- function We(a) {
18
+ function Xe(a) {
18
19
  return {
19
20
  modelName: String(a.modelName ?? a.model_name ?? a.service ?? ""),
20
21
  service: String(a.service ?? a.modelName ?? ""),
@@ -23,12 +24,12 @@ function We(a) {
23
24
  apiType: String(a.apiType ?? a.api_type ?? "OpenAPI")
24
25
  };
25
26
  }
26
- async function _e() {
27
+ async function ge() {
27
28
  let a;
28
29
  try {
29
- a = await fetch(`${X}/api/scenario-instances/0/models`, {
30
+ a = await fetch(`${Z}/api/scenario-instances/0/models`, {
30
31
  credentials: "include",
31
- headers: Z({
32
+ headers: ee({
32
33
  Accept: "application/json",
33
34
  "project-env": window.ENV_TYPE ?? "local"
34
35
  })
@@ -47,11 +48,11 @@ async function _e() {
47
48
  const l = n != null && n.success ? n.data : (n == null ? void 0 : n.data) ?? n;
48
49
  if (!Array.isArray(l))
49
50
  throw new Error("模型列表返回格式异常(非数组)");
50
- return l.map(We);
51
+ return l.map(Xe);
51
52
  }
52
- async function Ye(a, n, l, o) {
53
- var f, _, I, C;
54
- const d = await fetch(`${ue}/v1/chat/completions`, {
53
+ async function Ze(a, n, l, i) {
54
+ var f, b, O, K;
55
+ const m = await fetch(`${he}/v1/chat/completions`, {
55
56
  method: "POST",
56
57
  headers: {
57
58
  "Content-Type": "application/json",
@@ -63,78 +64,78 @@ async function Ye(a, n, l, o) {
63
64
  messages: l,
64
65
  stream: !0
65
66
  }),
66
- signal: o.signal
67
+ signal: i.signal
67
68
  });
68
- if (!d.ok || !d.body) {
69
- const T = await d.text().catch(() => "");
70
- if (/<!doctype html/i.test(T.slice(0, 200)))
69
+ if (!m.ok || !m.body) {
70
+ const v = await m.text().catch(() => "");
71
+ if (/<!doctype html/i.test(v.slice(0, 200)))
71
72
  throw new Error("模型网关未接入(/v1/chat/completions 落到主壳 SPA,无网关响应)");
72
- let M = `HTTP ${d.status}`;
73
+ let w = `HTTP ${m.status}`;
73
74
  try {
74
- const p = JSON.parse(T);
75
- M = ((f = p == null ? void 0 : p.error) == null ? void 0 : f.message) ?? M;
75
+ const h = JSON.parse(v);
76
+ w = ((f = h == null ? void 0 : h.error) == null ? void 0 : f.message) ?? w;
76
77
  } catch {
77
- T && (M = T);
78
+ v && (w = v);
78
79
  }
79
- throw new Error(M);
80
+ throw new Error(w);
80
81
  }
81
- const N = d.body.getReader(), v = new TextDecoder();
82
- let k = "";
82
+ const N = m.body.getReader(), T = new TextDecoder();
83
+ let y = "";
83
84
  try {
84
85
  for (; ; ) {
85
- const { done: T, value: M } = await N.read();
86
- if (T) break;
87
- k += v.decode(M, { stream: !0 });
88
- const p = k.split(`
86
+ const { done: v, value: w } = await N.read();
87
+ if (v) break;
88
+ y += T.decode(w, { stream: !0 });
89
+ const h = y.split(`
89
90
 
90
91
  `);
91
- k = p.pop() ?? "";
92
- for (const c of p) {
92
+ y = h.pop() ?? "";
93
+ for (const d of h) {
93
94
  let g = "";
94
- for (const i of c.split(`
95
+ for (const o of d.split(`
95
96
  `))
96
- i.startsWith("data:") && (g += i.slice(5).trim());
97
+ o.startsWith("data:") && (g += o.slice(5).trim());
97
98
  if (!g || g === "[DONE]") {
98
99
  if (g === "[DONE]") {
99
- o.onDone();
100
+ i.onDone();
100
101
  return;
101
102
  }
102
103
  continue;
103
104
  }
104
105
  try {
105
- const i = JSON.parse(g), w = i == null ? void 0 : i.choices;
106
- if (Array.isArray(w) && w.length > 0) {
107
- const K = (_ = w[0]) == null ? void 0 : _.delta;
108
- if (K != null && K.content && o.onDelta(K.content), (I = w[0]) == null ? void 0 : I.finish_reason) {
109
- const m = i != null && i.usage ? {
110
- promptTokens: i.usage.prompt_tokens ?? 0,
111
- completionTokens: i.usage.completion_tokens ?? 0,
112
- totalTokens: i.usage.total_tokens ?? 0
106
+ const o = JSON.parse(g), M = o == null ? void 0 : o.choices;
107
+ if (Array.isArray(M) && M.length > 0) {
108
+ const _ = (b = M[0]) == null ? void 0 : b.delta;
109
+ if (_ != null && _.content && i.onDelta(_.content), (O = M[0]) == null ? void 0 : O.finish_reason) {
110
+ const G = o != null && o.usage ? {
111
+ promptTokens: o.usage.prompt_tokens ?? 0,
112
+ completionTokens: o.usage.completion_tokens ?? 0,
113
+ totalTokens: o.usage.total_tokens ?? 0
113
114
  } : void 0;
114
- o.onDone(m);
115
+ i.onDone(G);
115
116
  return;
116
117
  }
117
118
  }
118
- if (i != null && i.usage) {
119
- const K = {
120
- promptTokens: i.usage.prompt_tokens ?? 0,
121
- completionTokens: i.usage.completion_tokens ?? 0,
122
- totalTokens: i.usage.total_tokens ?? 0
119
+ if (o != null && o.usage) {
120
+ const _ = {
121
+ promptTokens: o.usage.prompt_tokens ?? 0,
122
+ completionTokens: o.usage.completion_tokens ?? 0,
123
+ totalTokens: o.usage.total_tokens ?? 0
123
124
  };
124
- o.onDone(K);
125
+ i.onDone(_);
125
126
  return;
126
127
  }
127
128
  } catch {
128
129
  }
129
130
  }
130
131
  }
131
- o.onDone();
132
- } catch (T) {
133
- if ((C = o.signal) != null && C.aborted) return;
134
- throw o.onError(T instanceof Error ? T : new Error(String(T))), T;
132
+ i.onDone();
133
+ } catch (v) {
134
+ if ((K = i.signal) != null && K.aborted) return;
135
+ throw i.onError(v instanceof Error ? v : new Error(String(v))), v;
135
136
  }
136
137
  }
137
- async function ne(a, n) {
138
+ async function ae(a, n) {
138
139
  const l = await a.text();
139
140
  if (!a.ok)
140
141
  throw new Error(`${n}失败 HTTP ${a.status}${l ? `: ${l.slice(0, 120)}` : ""}`);
@@ -146,7 +147,7 @@ async function ne(a, n) {
146
147
  throw new Error(`${n}返回非 JSON:${l.slice(0, 120)}`);
147
148
  }
148
149
  }
149
- function Ve(a) {
150
+ function et(a) {
150
151
  const n = a.status === 1;
151
152
  return {
152
153
  id: Number(a.id),
@@ -168,10 +169,10 @@ function Ve(a) {
168
169
  secret: a.secret_key
169
170
  };
170
171
  }
171
- async function Me(a, n, l) {
172
- const o = await fetch(`${X}/api/ak/create`, {
172
+ async function _e(a, n, l) {
173
+ const i = await fetch(`${Z}/api/ak/create`, {
173
174
  method: "POST",
174
- headers: Z({ Accept: "application/json", "Content-Type": "application/json" }),
175
+ headers: ee({ Accept: "application/json", "Content-Type": "application/json" }),
175
176
  credentials: "include",
176
177
  body: JSON.stringify({
177
178
  akName: l || `AK-${n || a}`,
@@ -180,113 +181,113 @@ async function Me(a, n, l) {
180
181
  ownerUserId: a,
181
182
  ownerUserName: n
182
183
  })
183
- }), d = await ne(o, "创建 AK"), N = (d == null ? void 0 : d.data) ?? {}, v = N.accessKey ?? "", k = N.secretKey ?? "";
184
- return v && k && pe(v, k), { apiKey: k, akPrefix: v, message: "AK 已创建,secretKey 仅创建时可见" };
184
+ }), m = await ae(i, "创建 AK"), N = (m == null ? void 0 : m.data) ?? {}, T = N.accessKey ?? "", y = N.secretKey ?? "";
185
+ return T && y && ke(T, y), { apiKey: y, akPrefix: T, message: "AK 已创建,secretKey 仅创建时可见" };
185
186
  }
186
- async function ie(a) {
187
+ async function oe(a) {
187
188
  const n = await fetch(
188
- `${X}/api/ak/list`,
189
- { headers: Z({ Accept: "application/json" }), credentials: "include" }
190
- ), l = await ne(n, "获取 AK 列表"), o = Array.isArray(l == null ? void 0 : l.data) ? l.data : [];
191
- return (a ? o.filter((N) => !N.owner_user_id || String(N.owner_user_id) === String(a)) : o).filter((N) => (N.is_deleted ?? 0) === 0).map(Ve);
189
+ `${Z}/api/ak/list`,
190
+ { headers: ee({ Accept: "application/json" }), credentials: "include" }
191
+ ), l = await ae(n, "获取 AK 列表"), i = Array.isArray(l == null ? void 0 : l.data) ? l.data : [];
192
+ return (a ? i.filter((N) => !N.owner_user_id || String(N.owner_user_id) === String(a)) : i).filter((N) => (N.is_deleted ?? 0) === 0).map(et);
192
193
  }
193
- async function Xe(a) {
194
- const n = await fetch(`${X}/api/ak/delete?id=${encodeURIComponent(String(a))}`, {
194
+ async function tt(a) {
195
+ const n = await fetch(`${Z}/api/ak/delete?id=${encodeURIComponent(String(a))}`, {
195
196
  method: "POST",
196
- headers: Z({ Accept: "application/json" }),
197
+ headers: ee({ Accept: "application/json" }),
197
198
  credentials: "include"
198
199
  });
199
- await ne(n, "吊销 AK");
200
+ await ae(n, "吊销 AK");
200
201
  }
201
- async function be(a) {
202
- var T, M;
202
+ async function Ee(a) {
203
+ var v, w;
203
204
  const n = await fetch(
204
- `${X}/api/admin/llm-call-monitor/stats?hours=168`,
205
- { headers: Z({ Accept: "application/json" }), credentials: "include" }
206
- ), l = await ne(n, "获取调用统计"), d = ((l == null ? void 0 : l.data) ?? {}).summary ?? {};
205
+ `${Z}/api/admin/llm-call-monitor/stats?hours=168`,
206
+ { headers: ee({ Accept: "application/json" }), credentials: "include" }
207
+ ), l = await ae(n, "获取调用统计"), m = ((l == null ? void 0 : l.data) ?? {}).summary ?? {};
207
208
  let N = [];
208
209
  try {
209
- const p = await fetch(
210
- `${X}/api/admin/llm-call-monitor/recent?page=1&size=20`,
211
- { headers: Z({ Accept: "application/json" }), credentials: "include" }
212
- ), c = await ne(p, "获取调用明细");
213
- N = (Array.isArray((T = c == null ? void 0 : c.data) == null ? void 0 : T.records) ? c.data.records : []).map((i, w) => {
214
- const K = Number(i.promptTokens ?? 0), q = Number(i.completionTokens ?? 0);
210
+ const h = await fetch(
211
+ `${Z}/api/admin/llm-call-monitor/recent?page=1&size=20`,
212
+ { headers: ee({ Accept: "application/json" }), credentials: "include" }
213
+ ), d = await ae(h, "获取调用明细");
214
+ N = (Array.isArray((v = d == null ? void 0 : d.data) == null ? void 0 : v.records) ? d.data.records : []).map((o, M) => {
215
+ const _ = Number(o.promptTokens ?? 0), j = Number(o.completionTokens ?? 0);
215
216
  return {
216
- id: Number(i.id ?? w),
217
+ id: Number(o.id ?? M),
217
218
  apiKeyId: a,
218
219
  protocol: "chat/completions",
219
- model: String(i.model ?? ""),
220
- stream: Number(i.stream ?? 0),
221
- promptTokens: K,
222
- completionTokens: q,
223
- totalTokens: Number(i.totalTokens ?? K + q),
224
- latencyMs: Number(i.durationMs ?? 0),
225
- statusCode: i.success === !1 || i.success === 0 ? 500 : 200,
226
- errorMsg: i.errorType ?? null,
227
- createTime: String(i.createTime ?? "").replace("T", " ").slice(0, 19)
220
+ model: String(o.model ?? ""),
221
+ stream: Number(o.stream ?? 0),
222
+ promptTokens: _,
223
+ completionTokens: j,
224
+ totalTokens: Number(o.totalTokens ?? _ + j),
225
+ latencyMs: Number(o.durationMs ?? 0),
226
+ statusCode: o.success === !1 || o.success === 0 ? 500 : 200,
227
+ errorMsg: o.errorType ?? null,
228
+ createTime: String(o.createTime ?? "").replace("T", " ").slice(0, 19)
228
229
  };
229
230
  });
230
231
  } catch {
231
232
  }
232
- const v = {}, k = {};
233
- for (const p of N) {
234
- const c = v[M = p.model] || (v[M] = [0, 0, 0]);
235
- c[0] += 1, c[1] += p.promptTokens, c[2] += p.completionTokens;
236
- const g = (p.createTime || "").slice(0, 10);
233
+ const T = {}, y = {};
234
+ for (const h of N) {
235
+ const d = T[w = h.model] || (T[w] = [0, 0, 0]);
236
+ d[0] += 1, d[1] += h.promptTokens, d[2] += h.completionTokens;
237
+ const g = (h.createTime || "").slice(0, 10);
237
238
  if (g) {
238
- const i = k[g] || (k[g] = [0, 0, 0]);
239
- i[0] += 1, i[1] += p.promptTokens, i[2] += p.completionTokens;
239
+ const o = y[g] || (y[g] = [0, 0, 0]);
240
+ o[0] += 1, o[1] += h.promptTokens, o[2] += h.completionTokens;
240
241
  }
241
242
  }
242
- const f = Number(d.totalTokens ?? 0), _ = N.reduce((p, c) => p + c.totalTokens, 0), I = N.reduce((p, c) => p + c.promptTokens, 0), C = N.reduce((p, c) => p + c.completionTokens, 0);
243
+ const f = Number(m.totalTokens ?? 0), b = N.reduce((h, d) => h + d.totalTokens, 0), O = N.reduce((h, d) => h + d.promptTokens, 0), K = N.reduce((h, d) => h + d.completionTokens, 0);
243
244
  return {
244
- totalRequests: Number(d.totalCount ?? 0),
245
+ totalRequests: Number(m.totalCount ?? 0),
245
246
  // 汇总口径优先用后端整窗合计(后端 selectStats 才有 token 合计),
246
247
  // 明细只有最近一页 ⇒ 只在汇总缺失时用明细兜底。
247
- totalPromptTokens: Number(d.totalPromptTokens ?? 0) || I,
248
- totalCompletionTokens: Number(d.totalCompletionTokens ?? 0) || C,
249
- totalTokens: f || _,
250
- avgLatencyMs: Number(d.avgDurationMs ?? 0),
251
- errorCount: Number(d.failCount ?? 0),
252
- daily: k,
253
- models: v,
248
+ totalPromptTokens: Number(m.totalPromptTokens ?? 0) || O,
249
+ totalCompletionTokens: Number(m.totalCompletionTokens ?? 0) || K,
250
+ totalTokens: f || b,
251
+ avgLatencyMs: Number(m.avgDurationMs ?? 0),
252
+ errorCount: Number(m.failCount ?? 0),
253
+ daily: y,
254
+ models: T,
254
255
  recent: N
255
256
  };
256
257
  }
257
- function Ze() {
258
- return typeof window < "u" ? `${window.location.origin}${ue}` : ue;
258
+ function at() {
259
+ return typeof window < "u" ? `${window.location.origin}${he}` : he;
259
260
  }
260
- const he = "ft_gateway_ak_cache";
261
- function pe(a, n) {
261
+ const pe = "ft_gateway_ak_cache";
262
+ function ke(a, n) {
262
263
  try {
263
- const l = JSON.parse(localStorage.getItem(he) || "{}");
264
- l[a] = n, localStorage.setItem(he, JSON.stringify(l));
264
+ const l = JSON.parse(localStorage.getItem(pe) || "{}");
265
+ l[a] = n, localStorage.setItem(pe, JSON.stringify(l));
265
266
  } catch {
266
267
  }
267
268
  }
268
- function et(a) {
269
+ function nt(a) {
269
270
  try {
270
- return JSON.parse(localStorage.getItem(he) || "{}")[a] || null;
271
+ return JSON.parse(localStorage.getItem(pe) || "{}")[a] || null;
271
272
  } catch {
272
273
  return null;
273
274
  }
274
275
  }
275
- async function tt() {
276
+ async function st() {
276
277
  try {
277
- const o = localStorage.getItem(le);
278
- if (o) return o;
278
+ const i = localStorage.getItem(le);
279
+ if (i) return i;
279
280
  } catch {
280
281
  }
281
- const n = (await ie("").catch(() => [])).find((o) => o.active && o.secret);
282
+ const n = (await oe("").catch(() => [])).find((i) => i.active && i.secret);
282
283
  if (n != null && n.secret) {
283
284
  try {
284
285
  localStorage.setItem(le, n.secret);
285
286
  } catch {
286
287
  }
287
- return n.akPrefix && pe(n.akPrefix, n.secret), n.secret;
288
+ return n.akPrefix && ke(n.akPrefix, n.secret), n.secret;
288
289
  }
289
- const l = await Me(
290
+ const l = await _e(
290
291
  "system-default",
291
292
  "系统默认",
292
293
  "智能工作台默认AK(自动创建)"
@@ -299,75 +300,87 @@ async function tt() {
299
300
  }
300
301
  return l.apiKey;
301
302
  }
302
- function Ke() {
303
+ function Pe() {
303
304
  try {
304
305
  localStorage.removeItem(le);
305
306
  } catch {
306
307
  }
307
308
  }
308
- const ke = 1e7;
309
- function fe(a) {
309
+ function Ne(a) {
310
310
  return a >= 1e6 ? `${(a / 1e6).toFixed(1)}M` : a >= 1e3 ? `${(a / 1e3).toFixed(1)}K` : `${a}`;
311
311
  }
312
- function at(a) {
312
+ function rt(a, n) {
313
313
  return `# OpenAI 兼容
314
314
  curl -X POST ${a}/v1/chat/completions \\
315
315
  -H "Content-Type: application/json" \\
316
316
  -H "Authorization: Bearer ft-xxx" \\
317
317
  -d '{
318
- "model": "qwen3.6-flash",
318
+ "model": "${n}",
319
319
  "messages": [{"role":"user","content":"你好"}],
320
320
  "stream": true
321
321
  }'`;
322
322
  }
323
- function nt(a) {
323
+ function lt(a, n) {
324
324
  return `# Anthropic 兼容
325
325
  curl -X POST ${a}/v1/messages \\
326
326
  -H "Content-Type: application/json" \\
327
327
  -H "x-api-key: ft-xxx" \\
328
328
  -d '{
329
- "model": "qwen3.6-flash",
329
+ "model": "${n}",
330
330
  "messages": [{"role":"user","content":"你好"}]
331
331
  }'`;
332
332
  }
333
- function st() {
334
- const [a, n] = S("personal"), [l, o] = S([]), [d, N] = S([]), [v, k] = S(!0), [f, _] = S(!1), [I, C] = S(!1), [T, M] = S(""), [p, c] = S({ open: !1 }), [g, i] = S(null), [w, K] = S(null), [q, m] = S(!1), P = "zifang", D = "zifang", E = Ze(), j = H(async () => {
335
- k(!0);
333
+ function ot() {
334
+ const [a, n] = S("personal"), [l, i] = S([]), [m, N] = S([]), [T, y] = S(!0), [f, b] = S(!1), [O, K] = S(!1), [v, w] = S(""), [h, d] = S({ open: !1 }), [g, o] = S(null), [M, _] = S(null), [j, G] = S(!1), R = be((u) => u.currentUser), c = String((R == null ? void 0 : R.id) ?? ""), E = (R == null ? void 0 : R.username) ?? "", P = at(), [r, p] = S("<model-name>");
335
+ X(() => {
336
+ let u = !1;
337
+ return ge().then((x) => {
338
+ !u && x.length > 0 && p(x[0].modelName);
339
+ }).catch(() => {
340
+ }), () => {
341
+ u = !0;
342
+ };
343
+ }, []);
344
+ const A = H(async () => {
345
+ y(!0);
336
346
  try {
337
- const [h, x] = await Promise.all([
338
- ie("system-default").catch(() => []),
339
- ie(P).catch(() => [])
347
+ const u = c ? await oe(c).catch(() => []) : [], [x] = await Promise.all([
348
+ oe("system-default").catch(() => [])
340
349
  ]);
341
- o(h), N(x);
350
+ i(x), N(u);
342
351
  } finally {
343
- k(!1);
352
+ y(!1);
344
353
  }
345
- }, [P]);
346
- ae(() => {
347
- j();
348
- }, [j]);
349
- const r = () => {
350
- M(""), C(!0);
351
- }, u = async () => {
352
- if (!T.trim()) {
353
- F.warning("请输入 AK 名称");
354
+ }, [c]);
355
+ X(() => {
356
+ A();
357
+ }, [A]);
358
+ const C = () => {
359
+ w(""), K(!0);
360
+ }, q = async () => {
361
+ if (!v.trim()) {
362
+ J.warning("请输入 AK 名称");
354
363
  return;
355
364
  }
356
- _(!0);
365
+ if (!c) {
366
+ J.warning("登录态不可用,无法生成 AK");
367
+ return;
368
+ }
369
+ b(!0);
357
370
  try {
358
- const h = await Me(P, D, T.trim());
359
- pe(h.akPrefix, h.apiKey), C(!1), c({
371
+ const u = await _e(c, E, v.trim());
372
+ ke(u.akPrefix, u.apiKey), K(!1), d({
360
373
  open: !0,
361
- apiKey: h.apiKey,
362
- akPrefix: h.akPrefix
363
- }), j();
364
- } catch (h) {
365
- F.error(h instanceof Error ? h.message : "创建 AK 失败");
374
+ apiKey: u.apiKey,
375
+ akPrefix: u.akPrefix
376
+ }), A();
377
+ } catch (u) {
378
+ J.error(u instanceof Error ? u.message : "创建 AK 失败");
366
379
  } finally {
367
- _(!1);
380
+ b(!1);
368
381
  }
369
- }, A = (h) => {
370
- ce.confirm({
382
+ }, I = (u) => {
383
+ de.confirm({
371
384
  title: "确认吊销此 AK?",
372
385
  content: "吊销后此 AK 将立即失效,无法恢复。",
373
386
  okText: "确认吊销",
@@ -375,75 +388,75 @@ function st() {
375
388
  cancelText: "取消",
376
389
  onOk: async () => {
377
390
  try {
378
- await Xe(h), F.success("AK 已吊销"), j(), Ke();
391
+ await tt(u), J.success("AK 已吊销"), A(), Pe();
379
392
  } catch (x) {
380
- F.error(x instanceof Error ? x.message : "吊销失败");
393
+ J.error(x instanceof Error ? x.message : "吊销失败");
381
394
  }
382
395
  }
383
396
  });
384
- }, b = (h) => {
385
- navigator.clipboard.writeText(h).then(() => F.success("已复制到剪贴板")).catch(() => F.warning("复制失败,请手动复制"));
386
- }, J = (h) => {
387
- const x = et(h.akPrefix);
388
- x ? b(x) : (b(h.akPrefix), F.info("完整 AK 未在本地缓存(可能在本设备外创建),已复制前缀"));
389
- }, $ = async (h) => {
390
- i(h), m(!0), K(null);
397
+ }, F = (u) => {
398
+ navigator.clipboard.writeText(u).then(() => J.success("已复制到剪贴板")).catch(() => J.warning("复制失败,请手动复制"));
399
+ }, ie = (u) => {
400
+ const x = nt(u.akPrefix);
401
+ x ? F(x) : (F(u.akPrefix), J.info("完整 AK 未在本地缓存(可能在本设备外创建),已复制前缀"));
402
+ }, D = async (u) => {
403
+ o(u), G(!0), _(null);
391
404
  try {
392
- const x = await be(h.id);
393
- K(x);
405
+ const x = await Ee(u.id);
406
+ _(x);
394
407
  } catch (x) {
395
- F.error(x instanceof Error ? x.message : "获取用量失败");
408
+ J.error(x instanceof Error ? x.message : "获取用量失败");
396
409
  } finally {
397
- m(!1);
410
+ G(!1);
398
411
  }
399
- }, W = () => {
400
- i(null), K(null);
401
- }, oe = (h) => {
402
- const x = Object.entries(h);
412
+ }, U = () => {
413
+ o(null), _(null);
414
+ }, ne = (u) => {
415
+ const x = Object.entries(u);
403
416
  if (x.length === 0)
404
417
  return /* @__PURE__ */ e("span", { className: t.usageEmpty, children: "暂无数据" });
405
- const Y = Math.max(...x.map(([, y]) => y[1] + y[2]), 1);
406
- return /* @__PURE__ */ e("div", { className: t.usageBarChart, children: x.map(([y, R]) => {
407
- const ge = R[1] + R[2], Ee = ge / Y * 100;
418
+ const Y = Math.max(...x.map(([, k]) => k[1] + k[2]), 1);
419
+ return /* @__PURE__ */ e("div", { className: t.usageBarChart, children: x.map(([k, z]) => {
420
+ const ye = z[1] + z[2], Ie = ye / Y * 100;
408
421
  return /* @__PURE__ */ s("div", { className: t.usageBarCol, children: [
409
- /* @__PURE__ */ e(Q, { title: `${y}: ${R[0]}次 / ${ge} tokens`, children: /* @__PURE__ */ e(
422
+ /* @__PURE__ */ e(W, { title: `${k}: ${z[0]}次 / ${ye} tokens`, children: /* @__PURE__ */ e(
410
423
  "div",
411
424
  {
412
425
  className: t.usageBar,
413
- style: { height: `${Math.max(Ee, 2)}%` }
426
+ style: { height: `${Math.max(Ie, 2)}%` }
414
427
  }
415
428
  ) }),
416
- /* @__PURE__ */ e("span", { className: t.usageBarLabel, children: y })
417
- ] }, y);
429
+ /* @__PURE__ */ e("span", { className: t.usageBarLabel, children: k })
430
+ ] }, k);
418
431
  }) });
419
- }, L = (h) => {
420
- const x = Object.entries(h);
432
+ }, ce = (u) => {
433
+ const x = Object.entries(u);
421
434
  if (x.length === 0)
422
435
  return /* @__PURE__ */ e("span", { className: t.usageEmpty, children: "暂无数据" });
423
- const Y = Math.max(...x.map(([, y]) => y[0]), 1);
424
- return /* @__PURE__ */ e("div", { className: t.modelBreakdown, children: x.sort((y, R) => R[1][0] - y[1][0]).map(([y, R]) => /* @__PURE__ */ s("div", { className: t.modelBreakdownRow, children: [
425
- /* @__PURE__ */ e("span", { className: t.modelBreakdownName, children: y }),
436
+ const Y = Math.max(...x.map(([, k]) => k[0]), 1);
437
+ return /* @__PURE__ */ e("div", { className: t.modelBreakdown, children: x.sort((k, z) => z[1][0] - k[1][0]).map(([k, z]) => /* @__PURE__ */ s("div", { className: t.modelBreakdownRow, children: [
438
+ /* @__PURE__ */ e("span", { className: t.modelBreakdownName, children: k }),
426
439
  /* @__PURE__ */ e("div", { className: t.modelBreakdownBar, children: /* @__PURE__ */ e(
427
440
  "div",
428
441
  {
429
442
  className: t.modelBreakdownFill,
430
- style: { width: `${R[0] / Y * 100}%` }
443
+ style: { width: `${z[0] / Y * 100}%` }
431
444
  }
432
445
  ) }),
433
446
  /* @__PURE__ */ s("span", { className: t.modelBreakdownCount, children: [
434
- R[0],
447
+ z[0],
435
448
  "次 / ",
436
- R[1] + (R[2] || 0),
449
+ z[1] + (z[2] || 0),
437
450
  "tokens"
438
451
  ] })
439
- ] }, y)) });
440
- }, U = [
452
+ ] }, k)) });
453
+ }, Be = [
441
454
  {
442
455
  title: "时间",
443
456
  dataIndex: "createTime",
444
457
  key: "createTime",
445
458
  width: 160,
446
- render: (h) => h ? new Date(h).toLocaleString("zh-CN") : "-"
459
+ render: (u) => u ? new Date(u).toLocaleString("zh-CN") : "-"
447
460
  },
448
461
  { title: "模型", dataIndex: "model", key: "model", width: 140 },
449
462
  {
@@ -451,7 +464,7 @@ function st() {
451
464
  dataIndex: "protocol",
452
465
  key: "protocol",
453
466
  width: 90,
454
- render: (h) => /* @__PURE__ */ e(G, { children: h })
467
+ render: (u) => /* @__PURE__ */ e(Q, { children: u })
455
468
  },
456
469
  {
457
470
  title: "输入",
@@ -476,59 +489,59 @@ function st() {
476
489
  dataIndex: "latencyMs",
477
490
  key: "latencyMs",
478
491
  width: 70,
479
- render: (h) => h ? `${h}ms` : "-"
492
+ render: (u) => u ? `${u}ms` : "-"
480
493
  },
481
494
  {
482
495
  title: "状态",
483
496
  dataIndex: "statusCode",
484
497
  key: "statusCode",
485
498
  width: 60,
486
- render: (h) => h ? /* @__PURE__ */ e(G, { color: h < 400 ? "green" : "red", children: h }) : "-"
499
+ render: (u) => u ? /* @__PURE__ */ e(Q, { color: u < 400 ? "green" : "red", children: u }) : "-"
487
500
  }
488
- ], ee = (h, x) => {
489
- const Y = Array.isArray(h) ? h : [];
490
- return v ? /* @__PURE__ */ e("div", { style: { textAlign: "center", padding: 40 }, children: /* @__PURE__ */ e(V, { tip: "加载中..." }) }) : Y.length === 0 ? /* @__PURE__ */ e("div", { className: t.akEmpty, children: x ? "暂无应用 AK" : "暂无个人 AK,点击上方按钮生成" }) : /* @__PURE__ */ e("div", { style: { display: "flex", flexDirection: "column", gap: 8 }, children: Y.map((y) => /* @__PURE__ */ s(
501
+ ], fe = (u, x) => {
502
+ const Y = Array.isArray(u) ? u : [];
503
+ return T ? /* @__PURE__ */ e("div", { style: { textAlign: "center", padding: 40 }, children: /* @__PURE__ */ e(V, { tip: "加载中..." }) }) : Y.length === 0 ? /* @__PURE__ */ e("div", { className: t.akEmpty, children: x ? "暂无应用 AK" : "暂无个人 AK,点击上方按钮生成" }) : /* @__PURE__ */ e("div", { style: { display: "flex", flexDirection: "column", gap: 8 }, children: Y.map((k) => /* @__PURE__ */ s(
491
504
  "div",
492
505
  {
493
506
  className: t.akCard,
494
- onClick: () => $(y),
507
+ onClick: () => D(k),
495
508
  children: [
496
509
  /* @__PURE__ */ s("div", { className: t.akCardRow, children: [
497
- /* @__PURE__ */ e("span", { className: t.akTitle, children: y.description || y.akPrefix.replace("...", "**") }),
498
- /* @__PURE__ */ e("code", { className: t.akPrefixSmall, children: y.akPrefix.replace("...", "**") }),
510
+ /* @__PURE__ */ e("span", { className: t.akTitle, children: k.description || k.akPrefix.replace("...", "**") }),
511
+ /* @__PURE__ */ e("code", { className: t.akPrefixSmall, children: k.akPrefix.replace("...", "**") }),
499
512
  /* @__PURE__ */ e(
500
513
  "span",
501
514
  {
502
- className: `${t.akStatus} ${y.active ? t.akStatusActive : t.akStatusRevoked}`,
503
- children: y.active ? "活跃" : "已吊销"
515
+ className: `${t.akStatus} ${k.active ? t.akStatusActive : t.akStatusRevoked}`,
516
+ children: k.active ? "活跃" : "已吊销"
504
517
  }
505
518
  ),
506
- y.defaultModel && /* @__PURE__ */ s(G, { style: { fontSize: 11 }, children: [
519
+ k.defaultModel && /* @__PURE__ */ s(Q, { style: { fontSize: 11 }, children: [
507
520
  "默认: ",
508
- y.defaultModel
521
+ k.defaultModel
509
522
  ] }),
510
523
  /* @__PURE__ */ s(
511
524
  "div",
512
525
  {
513
526
  className: t.akCardActions,
514
- onClick: (R) => R.stopPropagation(),
527
+ onClick: (z) => z.stopPropagation(),
515
528
  children: [
516
- /* @__PURE__ */ e(Q, { title: "复制完整 AK", children: /* @__PURE__ */ e(
517
- z,
529
+ /* @__PURE__ */ e(W, { title: "复制完整 AK", children: /* @__PURE__ */ e(
530
+ L,
518
531
  {
519
532
  size: "small",
520
533
  icon: /* @__PURE__ */ e(se, {}),
521
- onClick: () => J(y),
534
+ onClick: () => ie(k),
522
535
  children: "复制"
523
536
  }
524
537
  ) }),
525
- !x && y.active && /* @__PURE__ */ e(
526
- z,
538
+ !x && k.active && /* @__PURE__ */ e(
539
+ L,
527
540
  {
528
541
  size: "small",
529
542
  danger: !0,
530
- icon: /* @__PURE__ */ e(Pe, {}),
531
- onClick: () => A(y.id),
543
+ icon: /* @__PURE__ */ e($e, {}),
544
+ onClick: () => I(k.id),
532
545
  children: "吊销"
533
546
  }
534
547
  )
@@ -537,33 +550,28 @@ function st() {
537
550
  )
538
551
  ] }),
539
552
  /* @__PURE__ */ s("div", { className: t.akCardRow2, children: [
540
- /* @__PURE__ */ e("div", { className: t.akMiniBar, children: /* @__PURE__ */ e(
553
+ k.tokenQuota > 0 && /* @__PURE__ */ e("div", { className: t.akMiniBar, children: /* @__PURE__ */ e(
541
554
  "div",
542
555
  {
543
556
  className: t.akMiniBarFill,
544
557
  style: {
545
558
  width: `${Math.min(
546
- (y.totalTokens || 0) / (y.tokenQuota || ke) * 100,
559
+ (k.totalTokens || 0) / k.tokenQuota * 100,
547
560
  100
548
561
  )}%`
549
562
  }
550
563
  }
551
564
  ) }),
552
565
  /* @__PURE__ */ s("span", { className: t.akUsageText, children: [
553
- fe(y.totalTokens || 0),
554
- " /",
555
- " ",
556
- fe(y.tokenQuota || ke)
557
- ] }),
558
- /* @__PURE__ */ s("span", { className: t.akMetaText, children: [
559
- y.totalRequests || 0,
560
- " 次请求"
566
+ Ne(k.totalTokens || 0),
567
+ k.tokenQuota > 0 ? ` / ${Ne(k.tokenQuota)}` : " tokens"
561
568
  ] }),
562
- /* @__PURE__ */ e("span", { className: t.akMetaText, children: new Date(y.createTime).toLocaleDateString("zh-CN") })
569
+ /* @__PURE__ */ e("span", { className: t.akMetaText, children: k.lastUsedAt ? `最近使用 ${k.lastUsedAt}` : "尚未使用" }),
570
+ /* @__PURE__ */ e("span", { className: t.akMetaText, children: new Date(k.createTime).toLocaleDateString("zh-CN") })
563
571
  ] })
564
572
  ]
565
573
  },
566
- y.id
574
+ k.id
567
575
  )) });
568
576
  };
569
577
  return /* @__PURE__ */ s("div", { className: t.akContainer, children: [
@@ -572,23 +580,23 @@ function st() {
572
580
  /* @__PURE__ */ s("div", { className: t.akBaseUrlRow, children: [
573
581
  /* @__PURE__ */ s("div", { className: t.akBaseUrlItem, children: [
574
582
  /* @__PURE__ */ e("span", { className: t.akBaseUrlLabel, children: "OpenAI 兼容" }),
575
- /* @__PURE__ */ e("code", { className: t.akBaseUrlValue, children: E }),
576
- /* @__PURE__ */ e(Q, { title: "复制 Base URL", children: /* @__PURE__ */ e(
583
+ /* @__PURE__ */ e("code", { className: t.akBaseUrlValue, children: P }),
584
+ /* @__PURE__ */ e(W, { title: "复制 Base URL", children: /* @__PURE__ */ e(
577
585
  se,
578
586
  {
579
587
  className: t.akCopyIcon,
580
- onClick: () => b(E)
588
+ onClick: () => F(P)
581
589
  }
582
590
  ) })
583
591
  ] }),
584
592
  /* @__PURE__ */ s("div", { className: t.akBaseUrlItem, children: [
585
593
  /* @__PURE__ */ e("span", { className: t.akBaseUrlLabel, children: "Anthropic 兼容" }),
586
- /* @__PURE__ */ e("code", { className: t.akBaseUrlValue, children: E }),
587
- /* @__PURE__ */ e(Q, { title: "复制 Base URL", children: /* @__PURE__ */ e(
594
+ /* @__PURE__ */ e("code", { className: t.akBaseUrlValue, children: P }),
595
+ /* @__PURE__ */ e(W, { title: "复制 Base URL", children: /* @__PURE__ */ e(
588
596
  se,
589
597
  {
590
598
  className: t.akCopyIcon,
591
- onClick: () => b(E)
599
+ onClick: () => F(P)
592
600
  }
593
601
  ) })
594
602
  ] })
@@ -596,11 +604,11 @@ function st() {
596
604
  /* @__PURE__ */ s("div", { className: t.akIntegrationGrid, children: [
597
605
  /* @__PURE__ */ s("div", { children: [
598
606
  /* @__PURE__ */ e("p", { className: t.akCodeLabel, children: "OpenAI 兼容 — curl 示例" }),
599
- /* @__PURE__ */ e("pre", { className: t.akCodeBlock, children: at(E) })
607
+ /* @__PURE__ */ e("pre", { className: t.akCodeBlock, children: rt(P, r) })
600
608
  ] }),
601
609
  /* @__PURE__ */ s("div", { children: [
602
610
  /* @__PURE__ */ e("p", { className: t.akCodeLabel, children: "Anthropic 兼容 — curl 示例" }),
603
- /* @__PURE__ */ e("pre", { className: t.akCodeBlock, children: nt(E) })
611
+ /* @__PURE__ */ e("pre", { className: t.akCodeBlock, children: lt(P, r) })
604
612
  ] })
605
613
  ] })
606
614
  ] }),
@@ -616,10 +624,10 @@ function st() {
616
624
  },
617
625
  children: [
618
626
  /* @__PURE__ */ e(
619
- Ce,
627
+ Ae,
620
628
  {
621
629
  activeKey: a,
622
- onChange: (h) => n(h),
630
+ onChange: (u) => n(u),
623
631
  items: [
624
632
  { key: "app", label: "应用 AK" },
625
633
  { key: "personal", label: "个人 AK" }
@@ -628,13 +636,13 @@ function st() {
628
636
  }
629
637
  ),
630
638
  /* @__PURE__ */ s("div", { style: { display: "flex", gap: 8 }, children: [
631
- /* @__PURE__ */ e(z, { icon: /* @__PURE__ */ e(Ne, {}), onClick: j, size: "small", children: "刷新" }),
639
+ /* @__PURE__ */ e(L, { icon: /* @__PURE__ */ e(Te, {}), onClick: A, size: "small", children: "刷新" }),
632
640
  a === "personal" && /* @__PURE__ */ e(
633
- z,
641
+ L,
634
642
  {
635
643
  type: "primary",
636
- icon: /* @__PURE__ */ e(ve, {}),
637
- onClick: r,
644
+ icon: /* @__PURE__ */ e(Se, {}),
645
+ onClick: C,
638
646
  loading: f,
639
647
  children: "生成 AK"
640
648
  }
@@ -643,15 +651,15 @@ function st() {
643
651
  ]
644
652
  }
645
653
  ),
646
- a === "app" ? ee(l, !0) : ee(d, !1)
654
+ a === "app" ? fe(l, !0) : fe(m, !1)
647
655
  ] }),
648
656
  /* @__PURE__ */ s(
649
- ce,
657
+ de,
650
658
  {
651
- open: I,
659
+ open: O,
652
660
  title: "生成新 AK",
653
- onCancel: () => C(!1),
654
- onOk: u,
661
+ onCancel: () => K(!1),
662
+ onOk: q,
655
663
  okText: "确认生成",
656
664
  cancelText: "取消",
657
665
  confirmLoading: f,
@@ -668,12 +676,12 @@ function st() {
668
676
  }
669
677
  ),
670
678
  /* @__PURE__ */ e(
671
- Se,
679
+ we,
672
680
  {
673
681
  placeholder: "例如:测试用 AK、生产网关 AK",
674
- value: T,
675
- onChange: (h) => M(h.target.value),
676
- onPressEnter: u,
682
+ value: v,
683
+ onChange: (u) => w(u.target.value),
684
+ onPressEnter: q,
677
685
  maxLength: 50,
678
686
  autoFocus: !0
679
687
  }
@@ -682,26 +690,26 @@ function st() {
682
690
  }
683
691
  ),
684
692
  /* @__PURE__ */ s(
685
- ce,
693
+ de,
686
694
  {
687
- open: p.open,
695
+ open: h.open,
688
696
  title: "AK 创建成功",
689
- onCancel: () => c({ open: !1 }),
697
+ onCancel: () => d({ open: !1 }),
690
698
  footer: [
691
699
  /* @__PURE__ */ e(
692
- z,
700
+ L,
693
701
  {
694
702
  icon: /* @__PURE__ */ e(se, {}),
695
- onClick: () => p.apiKey && b(p.apiKey),
703
+ onClick: () => h.apiKey && F(h.apiKey),
696
704
  children: "复制 AK"
697
705
  },
698
706
  "copy"
699
707
  ),
700
708
  /* @__PURE__ */ e(
701
- z,
709
+ L,
702
710
  {
703
711
  type: "primary",
704
- onClick: () => c({ open: !1 }),
712
+ onClick: () => d({ open: !1 }),
705
713
  children: "我已保存"
706
714
  },
707
715
  "close"
@@ -721,49 +729,50 @@ function st() {
721
729
  wordBreak: "break-all",
722
730
  userSelect: "all"
723
731
  },
724
- children: p.apiKey
732
+ children: h.apiKey
725
733
  }
726
734
  ),
727
735
  /* @__PURE__ */ s("div", { style: { marginTop: 8, fontSize: 12, color: "var(--text-muted)" }, children: [
728
736
  "前缀: ",
729
- p.akPrefix
737
+ h.akPrefix
730
738
  ] })
731
739
  ]
732
740
  }
733
741
  ),
734
742
  /* @__PURE__ */ e(
735
- we,
743
+ xe,
736
744
  {
737
745
  title: g ? /* @__PURE__ */ s("span", { children: [
738
746
  "AK 详情 — ",
739
747
  /* @__PURE__ */ e("code", { children: g.akPrefix })
740
748
  ] }) : "AK 详情",
741
749
  open: !!g,
742
- onClose: W,
750
+ onClose: U,
743
751
  size: "large",
744
- children: q ? /* @__PURE__ */ e("div", { style: { textAlign: "center", padding: 60 }, children: /* @__PURE__ */ e(V, { tip: "加载用量数据..." }) }) : w ? /* @__PURE__ */ s("div", { className: t.usageDrawerContent, children: [
752
+ children: j ? /* @__PURE__ */ e("div", { style: { textAlign: "center", padding: 60 }, children: /* @__PURE__ */ e(V, { tip: "加载用量数据..." }) }) : M ? /* @__PURE__ */ s("div", { className: t.usageDrawerContent, children: [
753
+ /* @__PURE__ */ e("div", { style: { fontSize: 12, color: "#8c8c8c", marginBottom: 12 }, children: "以下为网关全局调用统计(近 7 天窗口), 监控侧不按 AK 留存;该 AK 自身的累计消耗见下方「本 AK 累计 Token」。" }),
745
754
  /* @__PURE__ */ s("div", { className: t.usageStatsGrid, children: [
746
- /* @__PURE__ */ e(B, { title: "总请求数", value: w.totalRequests }),
747
- /* @__PURE__ */ e(B, { title: "总 Token", value: w.totalTokens }),
755
+ /* @__PURE__ */ e(B, { title: "总请求数", value: M.totalRequests }),
756
+ /* @__PURE__ */ e(B, { title: "总 Token", value: M.totalTokens }),
748
757
  /* @__PURE__ */ e(
749
758
  B,
750
759
  {
751
760
  title: "输入 Token",
752
- value: w.totalPromptTokens
761
+ value: M.totalPromptTokens
753
762
  }
754
763
  ),
755
764
  /* @__PURE__ */ e(
756
765
  B,
757
766
  {
758
767
  title: "输出 Token",
759
- value: w.totalCompletionTokens
768
+ value: M.totalCompletionTokens
760
769
  }
761
770
  ),
762
771
  /* @__PURE__ */ e(
763
772
  B,
764
773
  {
765
774
  title: "平均耗时",
766
- value: w.avgLatencyMs,
775
+ value: M.avgLatencyMs,
767
776
  suffix: "ms"
768
777
  }
769
778
  ),
@@ -771,30 +780,37 @@ function st() {
771
780
  B,
772
781
  {
773
782
  title: "错误数",
774
- value: w.errorCount,
783
+ value: M.errorCount,
775
784
  styles: {
776
785
  content: {
777
- color: w.errorCount > 0 ? "#ff4d4f" : void 0
786
+ color: M.errorCount > 0 ? "#ff4d4f" : void 0
778
787
  }
779
788
  }
780
789
  }
790
+ ),
791
+ /* @__PURE__ */ e(
792
+ B,
793
+ {
794
+ title: "本 AK 累计 Token",
795
+ value: (g == null ? void 0 : g.totalTokens) ?? 0
796
+ }
781
797
  )
782
798
  ] }),
783
799
  /* @__PURE__ */ s("div", { className: t.usageSection, children: [
784
- /* @__PURE__ */ e("h4", { className: t.usageSectionTitle, children: "每日调用曲线(近 30 天)" }),
785
- oe(w.daily)
800
+ /* @__PURE__ */ e("h4", { className: t.usageSectionTitle, children: "每日调用曲线(按最近调用明细聚合)" }),
801
+ ne(M.daily)
786
802
  ] }),
787
803
  /* @__PURE__ */ s("div", { className: t.usageSection, children: [
788
804
  /* @__PURE__ */ e("h4", { className: t.usageSectionTitle, children: "模型用量分布" }),
789
- L(w.models)
805
+ ce(M.models)
790
806
  ] }),
791
807
  /* @__PURE__ */ s("div", { className: t.usageSection, children: [
792
808
  /* @__PURE__ */ e("h4", { className: t.usageSectionTitle, children: "最近调用记录" }),
793
809
  /* @__PURE__ */ e(
794
- Ae,
810
+ Ke,
795
811
  {
796
- columns: U,
797
- dataSource: w.recent,
812
+ columns: Be,
813
+ dataSource: M.recent,
798
814
  rowKey: "id",
799
815
  size: "small",
800
816
  pagination: {
@@ -802,7 +818,7 @@ function st() {
802
818
  size: "small",
803
819
  showSizeChanger: !0,
804
820
  pageSizeOptions: ["10", "20", "50", "100"],
805
- showTotal: (h) => `共 ${h} 条`
821
+ showTotal: (u) => `共 ${u} 条`
806
822
  },
807
823
  scroll: { x: 760 }
808
824
  }
@@ -813,62 +829,62 @@ function st() {
813
829
  )
814
830
  ] });
815
831
  }
816
- function rt(a) {
832
+ function it(a) {
817
833
  const n = [];
818
834
  if (!a) return n;
819
835
  const l = /<(think|thinking|reasoning)>([\s\S]*?)<\/\1>/gi;
820
- let o = 0, d;
821
- for (; (d = l.exec(a)) !== null; )
822
- d.index > o && n.push({ type: "text", text: a.slice(o, d.index) }), n.push({ type: "think", text: d[2] }), o = d.index + d[0].length;
823
- return o < a.length && n.push({ type: "text", text: a.slice(o) }), n;
836
+ let i = 0, m;
837
+ for (; (m = l.exec(a)) !== null; )
838
+ m.index > i && n.push({ type: "text", text: a.slice(i, m.index) }), n.push({ type: "think", text: m[2] }), i = m.index + m[0].length;
839
+ return i < a.length && n.push({ type: "text", text: a.slice(i) }), n;
824
840
  }
825
841
  const re = 4;
826
- let lt = 0;
827
- function it({ initialModels: a }) {
828
- const [n, l] = S([]), [o, d] = S([]), [N, v] = S(!0), [k, f] = S(null), [_, I] = S(""), [C, T] = S(!1), M = de(""), p = de(/* @__PURE__ */ new Map()), c = de(/* @__PURE__ */ new Map());
829
- ae(() => {
842
+ let ct = 0;
843
+ function dt({ initialModels: a }) {
844
+ const [n, l] = S([]), [i, m] = S([]), [N, T] = S(!0), [y, f] = S(null), [b, O] = S(""), [K, v] = S(!1), w = me(""), h = me(/* @__PURE__ */ new Map()), d = me(/* @__PURE__ */ new Map());
845
+ X(() => {
830
846
  (async () => {
831
847
  try {
832
- const r = await _e();
833
- d(r), v(!1);
834
- const u = a.length > 0 ? a : r.slice(0, 1).map((A) => A.modelName);
835
- l(u.slice(0, re).map((A) => me(A)));
848
+ const r = await ge();
849
+ m(r), T(!1);
850
+ const p = a.length > 0 ? a : r.slice(0, 1).map((A) => A.modelName);
851
+ l(p.slice(0, re).map((A) => ue(A)));
836
852
  } catch (r) {
837
- v(!1), f(r instanceof Error ? r.message : "模型列表加载失败");
853
+ T(!1), f(r instanceof Error ? r.message : "模型列表加载失败");
838
854
  }
839
855
  })();
840
- }, []), ae(() => {
841
- if (a.length > 0 && o.length > 0) {
842
- const r = a.slice(0, re).map((u) => me(u));
856
+ }, []), X(() => {
857
+ if (a.length > 0 && i.length > 0) {
858
+ const r = a.slice(0, re).map((p) => ue(p));
843
859
  l(r);
844
860
  }
845
861
  }, [a.join(",")]);
846
862
  const g = H((r) => {
847
- const u = c.current.get(r);
848
- u && (u.scrollTop = u.scrollHeight);
849
- }, []), i = H(
850
- (r, u) => {
851
- l((A) => A.map((b) => b.id === r ? u(b) : b));
863
+ const p = d.current.get(r);
864
+ p && (p.scrollTop = p.scrollHeight);
865
+ }, []), o = H(
866
+ (r, p) => {
867
+ l((A) => A.map((C) => C.id === r ? p(C) : C));
852
868
  },
853
869
  []
854
- ), w = H(async () => {
855
- if (M.current) return M.current;
856
- const r = await tt();
857
- return M.current = r, r;
858
- }, []), K = H(async () => {
859
- const r = _.trim();
860
- if (!r || C) return;
861
- let u;
870
+ ), M = H(async () => {
871
+ if (w.current) return w.current;
872
+ const r = await st();
873
+ return w.current = r, r;
874
+ }, []), _ = H(async () => {
875
+ const r = b.trim();
876
+ if (!r || K) return;
877
+ let p;
862
878
  try {
863
- u = await w();
879
+ p = await M();
864
880
  } catch {
865
881
  return;
866
882
  }
867
- I(""), T(!0);
868
- const A = n.map(($) => ({
869
- ...$,
883
+ O(""), v(!0);
884
+ const A = n.map((I) => ({
885
+ ...I,
870
886
  messages: [
871
- ...$.messages,
887
+ ...I.messages,
872
888
  { role: "user", content: r },
873
889
  { role: "assistant", content: "" }
874
890
  ],
@@ -878,103 +894,103 @@ function it({ initialModels: a }) {
878
894
  usage: null
879
895
  }));
880
896
  l(A);
881
- const b = A;
882
- b.forEach(($) => {
883
- const W = new AbortController();
884
- p.current.set($.id, W);
885
- const oe = $.messages.slice(0, -1);
886
- Ye(u, $.model, oe, {
887
- onDelta: (L) => {
888
- i($.id, (U) => ({
897
+ const C = A;
898
+ C.forEach((I) => {
899
+ const F = new AbortController();
900
+ h.current.set(I.id, F);
901
+ const ie = I.messages.slice(0, -1);
902
+ Ze(p, I.model, ie, {
903
+ onDelta: (D) => {
904
+ o(I.id, (U) => ({
889
905
  ...U,
890
- streamingContent: U.streamingContent + L,
906
+ streamingContent: U.streamingContent + D,
891
907
  messages: U.messages.map(
892
- (ee, h) => h === U.messages.length - 1 ? { ...ee, content: U.streamingContent + L } : ee
908
+ (ne, ce) => ce === U.messages.length - 1 ? { ...ne, content: U.streamingContent + D } : ne
893
909
  )
894
- })), g($.id);
910
+ })), g(I.id);
895
911
  },
896
- onDone: (L) => {
897
- i($.id, (U) => ({
912
+ onDone: (D) => {
913
+ o(I.id, (U) => ({
898
914
  ...U,
899
915
  isStreaming: !1,
900
- usage: L ? {
901
- promptTokens: L.promptTokens,
902
- completionTokens: L.completionTokens,
903
- totalTokens: L.totalTokens
916
+ usage: D ? {
917
+ promptTokens: D.promptTokens,
918
+ completionTokens: D.completionTokens,
919
+ totalTokens: D.totalTokens
904
920
  } : null
905
- })), p.current.delete($.id);
921
+ })), h.current.delete(I.id);
906
922
  },
907
- onError: (L) => {
908
- (L.message.includes("401") || L.message.includes("API key")) && (Ke(), M.current = ""), i($.id, (U) => ({
923
+ onError: (D) => {
924
+ (D.message.includes("401") || D.message.includes("API key")) && (Pe(), w.current = ""), o(I.id, (U) => ({
909
925
  ...U,
910
926
  isStreaming: !1,
911
- error: L.message
912
- })), p.current.delete($.id);
927
+ error: D.message
928
+ })), h.current.delete(I.id);
913
929
  },
914
- signal: W.signal
930
+ signal: F.signal
915
931
  }).catch(() => {
916
932
  });
917
933
  });
918
- const J = setInterval(() => {
919
- b.every(
920
- (W) => !p.current.has(W.id)
921
- ) && (clearInterval(J), T(!1));
934
+ const q = setInterval(() => {
935
+ C.every(
936
+ (F) => !h.current.has(F.id)
937
+ ) && (clearInterval(q), v(!1));
922
938
  }, 200);
923
939
  setTimeout(() => {
924
- clearInterval(J), T(!1);
940
+ clearInterval(q), v(!1);
925
941
  }, 300 * 1e3);
926
- }, [_, C, n, w, i, g]), q = H(() => {
927
- p.current.forEach((r) => r.abort()), p.current.clear(), l((r) => r.map((u) => ({ ...u, isStreaming: !1 }))), T(!1);
928
- }, []), m = H(() => {
929
- var u;
942
+ }, [b, K, n, M, o, g]), j = H(() => {
943
+ h.current.forEach((r) => r.abort()), h.current.clear(), l((r) => r.map((p) => ({ ...p, isStreaming: !1 }))), v(!1);
944
+ }, []), G = H(() => {
945
+ var p;
930
946
  if (n.length >= re) return;
931
- const r = (u = o.find((A) => !n.some((b) => b.model === A.modelName))) == null ? void 0 : u.modelName;
932
- r && l((A) => [...A, me(r)]);
933
- }, [n, o]), P = H(() => {
934
- p.current.forEach((r) => r.abort()), p.current.clear(), l(
935
- (r) => r.map((u) => ({
936
- ...u,
947
+ const r = (p = i.find((A) => !n.some((C) => C.model === A.modelName))) == null ? void 0 : p.modelName;
948
+ r && l((A) => [...A, ue(r)]);
949
+ }, [n, i]), R = H(() => {
950
+ h.current.forEach((r) => r.abort()), h.current.clear(), l(
951
+ (r) => r.map((p) => ({
952
+ ...p,
937
953
  messages: [],
938
954
  streamingContent: "",
939
955
  isStreaming: !1,
940
956
  error: null,
941
957
  usage: null
942
958
  }))
943
- ), T(!1);
944
- }, [C, n]), D = H((r) => {
945
- const u = p.current.get(r);
946
- u && u.abort(), p.current.delete(r), l((A) => A.filter((b) => b.id !== r));
959
+ ), v(!1);
960
+ }, [K, n]), c = H((r) => {
961
+ const p = h.current.get(r);
962
+ p && p.abort(), h.current.delete(r), l((A) => A.filter((C) => C.id !== r));
947
963
  }, []), E = H(
948
- (r, u) => {
949
- i(r, (A) => ({ ...A, model: u }));
964
+ (r, p) => {
965
+ o(r, (A) => ({ ...A, model: p }));
950
966
  },
951
- [i]
952
- ), j = o.map((r) => ({
967
+ [o]
968
+ ), P = i.map((r) => ({
953
969
  label: r.modelName,
954
970
  value: r.modelName
955
971
  }));
956
- return N ? /* @__PURE__ */ e("div", { style: { textAlign: "center", padding: 60 }, children: /* @__PURE__ */ e(V, { tip: "加载模型列表..." }) }) : k ? /* @__PURE__ */ s("div", { className: t.chatContainer, children: [
972
+ return N ? /* @__PURE__ */ e("div", { style: { textAlign: "center", padding: 60 }, children: /* @__PURE__ */ e(V, { tip: "加载模型列表..." }) }) : y ? /* @__PURE__ */ s("div", { className: t.chatContainer, children: [
957
973
  /* @__PURE__ */ e("div", { className: t.chatHeader, children: /* @__PURE__ */ e("h3", { className: t.chatTitle, children: "模型对话" }) }),
958
974
  /* @__PURE__ */ s("div", { className: t.akEmpty, children: [
959
975
  "模型列表加载失败:",
960
- k
976
+ y
961
977
  ] })
962
978
  ] }) : /* @__PURE__ */ s("div", { className: t.chatContainer, children: [
963
979
  /* @__PURE__ */ s("div", { className: t.chatHeader, children: [
964
980
  /* @__PURE__ */ s("h3", { className: t.chatTitle, children: [
965
981
  "模型对话",
966
- n.length > 1 && /* @__PURE__ */ s(G, { color: "blue", style: { marginLeft: 12, fontSize: 12 }, children: [
982
+ n.length > 1 && /* @__PURE__ */ s(Q, { color: "blue", style: { marginLeft: 12, fontSize: 12 }, children: [
967
983
  n.length,
968
984
  " 个模型对比"
969
985
  ] })
970
986
  ] }),
971
987
  /* @__PURE__ */ e(
972
- z,
988
+ L,
973
989
  {
974
990
  size: "small",
975
- icon: /* @__PURE__ */ e(Ie, {}),
976
- onClick: P,
977
- disabled: C || n.every((r) => r.messages.length === 0),
991
+ icon: /* @__PURE__ */ e(Oe, {}),
992
+ onClick: R,
993
+ disabled: K || n.every((r) => r.messages.length === 0),
978
994
  children: "清空重新来"
979
995
  }
980
996
  )
@@ -983,12 +999,12 @@ function it({ initialModels: a }) {
983
999
  n.map((r) => /* @__PURE__ */ s("div", { className: t.chatPanel, children: [
984
1000
  /* @__PURE__ */ s("div", { className: t.chatPanelHeader, children: [
985
1001
  /* @__PURE__ */ e(
986
- He,
1002
+ Fe,
987
1003
  {
988
1004
  size: "small",
989
1005
  value: r.model,
990
- onChange: (u) => E(r.id, u),
991
- options: j,
1006
+ onChange: (p) => E(r.id, p),
1007
+ options: P,
992
1008
  style: { minWidth: 140, flex: 1 },
993
1009
  showSearch: !0,
994
1010
  optionFilterProp: "label"
@@ -998,8 +1014,8 @@ function it({ initialModels: a }) {
998
1014
  "span",
999
1015
  {
1000
1016
  className: t.chatPanelClose,
1001
- onClick: () => D(r.id),
1002
- children: /* @__PURE__ */ e(Be, {})
1017
+ onClick: () => c(r.id),
1018
+ children: /* @__PURE__ */ e(De, {})
1003
1019
  }
1004
1020
  )
1005
1021
  ] }),
@@ -1007,29 +1023,29 @@ function it({ initialModels: a }) {
1007
1023
  "div",
1008
1024
  {
1009
1025
  className: t.chatPanelBody,
1010
- ref: (u) => {
1011
- c.current.set(r.id, u);
1026
+ ref: (p) => {
1027
+ d.current.set(r.id, p);
1012
1028
  },
1013
1029
  children: [
1014
- r.messages.map((u, A) => /* @__PURE__ */ s(
1030
+ r.messages.map((p, A) => /* @__PURE__ */ s(
1015
1031
  "div",
1016
1032
  {
1017
- className: u.role === "user" ? t.chatMsgUser : t.chatMsgAI,
1033
+ className: p.role === "user" ? t.chatMsgUser : t.chatMsgAI,
1018
1034
  children: [
1019
- u.role === "assistant" ? rt(u.content).map(
1020
- (b, J) => b.type === "think" ? /* @__PURE__ */ s(
1035
+ p.role === "assistant" ? it(p.content).map(
1036
+ (C, q) => C.type === "think" ? /* @__PURE__ */ s(
1021
1037
  "details",
1022
1038
  {
1023
1039
  className: t.chatThinkBlock,
1024
1040
  children: [
1025
1041
  /* @__PURE__ */ e("summary", { children: "思考过程" }),
1026
- /* @__PURE__ */ e("pre", { children: b.text })
1042
+ /* @__PURE__ */ e("pre", { children: C.text })
1027
1043
  ]
1028
1044
  },
1029
- J
1030
- ) : /* @__PURE__ */ e("span", { style: { whiteSpace: "pre-wrap" }, children: b.text }, J)
1031
- ) : /* @__PURE__ */ e("span", { style: { whiteSpace: "pre-wrap" }, children: u.content }),
1032
- r.isStreaming && A === r.messages.length - 1 && u.role === "assistant" && /* @__PURE__ */ e("span", { className: t.chatStreamingCursor })
1045
+ q
1046
+ ) : /* @__PURE__ */ e("span", { style: { whiteSpace: "pre-wrap" }, children: C.text }, q)
1047
+ ) : /* @__PURE__ */ e("span", { style: { whiteSpace: "pre-wrap" }, children: p.content }),
1048
+ r.isStreaming && A === r.messages.length - 1 && p.role === "assistant" && /* @__PURE__ */ e("span", { className: t.chatStreamingCursor })
1033
1049
  ]
1034
1050
  },
1035
1051
  A
@@ -1049,33 +1065,33 @@ function it({ initialModels: a }) {
1049
1065
  }
1050
1066
  )
1051
1067
  ] }, r.id)),
1052
- n.length < re && /* @__PURE__ */ e(Q, { title: "添加面板", children: /* @__PURE__ */ e("div", { className: t.addPanelBtn, onClick: m, children: /* @__PURE__ */ e(ve, {}) }) })
1068
+ n.length < re && /* @__PURE__ */ e(W, { title: "添加面板", children: /* @__PURE__ */ e("div", { className: t.addPanelBtn, onClick: G, children: /* @__PURE__ */ e(Se, {}) }) })
1053
1069
  ] }),
1054
1070
  /* @__PURE__ */ s("div", { className: t.chatInputBar, children: [
1055
1071
  /* @__PURE__ */ e(
1056
- Se.TextArea,
1072
+ we.TextArea,
1057
1073
  {
1058
1074
  className: t.chatInput,
1059
- value: _,
1060
- onChange: (r) => I(r.target.value),
1075
+ value: b,
1076
+ onChange: (r) => O(r.target.value),
1061
1077
  placeholder: "输入消息,所有面板将同时收到并流式输出...",
1062
1078
  autoSize: { minRows: 1, maxRows: 4 },
1063
1079
  onPressEnter: (r) => {
1064
- r.shiftKey || (r.preventDefault(), K());
1080
+ r.shiftKey || (r.preventDefault(), _());
1065
1081
  },
1066
- disabled: C
1082
+ disabled: K
1067
1083
  }
1068
1084
  ),
1069
- C ? /* @__PURE__ */ e(z, { danger: !0, onClick: q, children: "停止" }) : /* @__PURE__ */ s(z, { type: "primary", onClick: K, disabled: !_.trim(), children: [
1070
- /* @__PURE__ */ e($e, {}),
1085
+ K ? /* @__PURE__ */ e(L, { danger: !0, onClick: j, children: "停止" }) : /* @__PURE__ */ s(L, { type: "primary", onClick: _, disabled: !b.trim(), children: [
1086
+ /* @__PURE__ */ e(Le, {}),
1071
1087
  " 发送"
1072
1088
  ] })
1073
1089
  ] })
1074
1090
  ] });
1075
1091
  }
1076
- function me(a) {
1092
+ function ue(a) {
1077
1093
  return {
1078
- id: ++lt,
1094
+ id: ++ct,
1079
1095
  model: a,
1080
1096
  messages: [],
1081
1097
  streamingContent: "",
@@ -1084,32 +1100,32 @@ function me(a) {
1084
1100
  usage: null
1085
1101
  };
1086
1102
  }
1087
- function ot({ onStartChat: a }) {
1088
- const [n, l] = S([]), [o, d] = S(!0), [N, v] = S(null), [k, f] = S(/* @__PURE__ */ new Set()), _ = () => {
1089
- d(!0), v(null), _e().then((c) => {
1090
- l(c), d(!1);
1091
- }).catch((c) => {
1092
- l([]), v(c instanceof Error ? c.message : "加载失败"), d(!1);
1103
+ function mt({ onStartChat: a }) {
1104
+ const [n, l] = S([]), [i, m] = S(!0), [N, T] = S(null), [y, f] = S(/* @__PURE__ */ new Set()), b = () => {
1105
+ m(!0), T(null), ge().then((d) => {
1106
+ l(d), m(!1);
1107
+ }).catch((d) => {
1108
+ l([]), T(d instanceof Error ? d.message : "加载失败"), m(!1);
1093
1109
  });
1094
1110
  };
1095
- ae(() => {
1096
- _();
1111
+ X(() => {
1112
+ b();
1097
1113
  }, []);
1098
- const I = (c) => {
1114
+ const O = (d) => {
1099
1115
  f((g) => {
1100
- const i = new Set(g);
1101
- return i.has(c) ? i.delete(c) : i.add(c), i;
1116
+ const o = new Set(g);
1117
+ return o.has(d) ? o.delete(d) : o.add(d), o;
1102
1118
  });
1103
- }, C = Array.from(k), T = (c) => {
1104
- a([c]);
1105
- }, M = () => {
1106
- C.length > 0 && a(C);
1107
- }, p = (c) => {
1108
- if (!c) return "default";
1109
- const g = c.toLowerCase();
1119
+ }, K = Array.from(y), v = (d) => {
1120
+ a([d]);
1121
+ }, w = () => {
1122
+ K.length > 0 && a(K);
1123
+ }, h = (d) => {
1124
+ if (!d) return "default";
1125
+ const g = d.toLowerCase();
1110
1126
  return g.includes("aliyun") || g.includes("ali") ? "blue" : g.includes("zhipu") || g.includes("glm") ? "purple" : g.includes("moonshot") || g.includes("kimi") ? "cyan" : g.includes("minimax") ? "orange" : "default";
1111
1127
  };
1112
- return o ? /* @__PURE__ */ e("div", { style: { textAlign: "center", padding: 60 }, children: /* @__PURE__ */ e(V, { tip: "加载模型列表..." }) }) : N ? /* @__PURE__ */ s("div", { children: [
1128
+ return i ? /* @__PURE__ */ e("div", { style: { textAlign: "center", padding: 60 }, children: /* @__PURE__ */ e(V, { tip: "加载模型列表..." }) }) : N ? /* @__PURE__ */ s("div", { children: [
1113
1129
  /* @__PURE__ */ s("div", { className: t.modelMgmtHeader, children: [
1114
1130
  /* @__PURE__ */ e("h3", { className: t.modelMgmtTitle, children: "模型管理" }),
1115
1131
  /* @__PURE__ */ e("p", { className: t.modelMgmtSubtitle, children: "数据库管理的可用模型,可选择单个或多个模型发起对话对比" })
@@ -1117,7 +1133,7 @@ function ot({ onStartChat: a }) {
1117
1133
  /* @__PURE__ */ s("div", { className: t.akEmpty, children: [
1118
1134
  "模型列表加载失败:",
1119
1135
  N,
1120
- /* @__PURE__ */ e("div", { style: { marginTop: 16 }, children: /* @__PURE__ */ e(z, { type: "primary", onClick: _, children: "重试" }) })
1136
+ /* @__PURE__ */ e("div", { style: { marginTop: 16 }, children: /* @__PURE__ */ e(L, { type: "primary", onClick: b, children: "重试" }) })
1121
1137
  ] })
1122
1138
  ] }) : /* @__PURE__ */ s("div", { children: [
1123
1139
  /* @__PURE__ */ s("div", { className: t.modelMgmtHeader, children: [
@@ -1125,134 +1141,134 @@ function ot({ onStartChat: a }) {
1125
1141
  /* @__PURE__ */ e("p", { className: t.modelMgmtSubtitle, children: "数据库管理的可用模型,可选择单个或多个模型发起对话对比" })
1126
1142
  ] }),
1127
1143
  n.length === 0 && /* @__PURE__ */ e("div", { className: t.akEmpty, children: "后端暂无启用模型(z_team_model_config 中 enable=1 的行),请先在数据库或网关配置中启用" }),
1128
- /* @__PURE__ */ e("div", { className: t.modelGrid, children: n.map((c) => {
1129
- const g = k.has(c.modelName);
1144
+ /* @__PURE__ */ e("div", { className: t.modelGrid, children: n.map((d) => {
1145
+ const g = y.has(d.modelName);
1130
1146
  return /* @__PURE__ */ s(
1131
1147
  "div",
1132
1148
  {
1133
1149
  className: `${t.modelCard} ${g ? t.modelCardSelected : ""}`,
1134
- onClick: () => I(c.modelName),
1150
+ onClick: () => O(d.modelName),
1135
1151
  children: [
1136
1152
  /* @__PURE__ */ e(
1137
- qe,
1153
+ Ge,
1138
1154
  {
1139
1155
  className: t.modelCheckbox,
1140
1156
  checked: g,
1141
- onChange: (i) => {
1142
- i.stopPropagation(), I(c.modelName);
1157
+ onChange: (o) => {
1158
+ o.stopPropagation(), O(d.modelName);
1143
1159
  }
1144
1160
  }
1145
1161
  ),
1146
1162
  /* @__PURE__ */ s("div", { className: t.modelCardHeader, children: [
1147
- /* @__PURE__ */ e("div", { className: t.modelIconWrap, children: /* @__PURE__ */ e(Te, {}) }),
1163
+ /* @__PURE__ */ e("div", { className: t.modelIconWrap, children: /* @__PURE__ */ e(Ce, {}) }),
1148
1164
  /* @__PURE__ */ s("div", { className: t.modelCardInfo, children: [
1149
- /* @__PURE__ */ e("h4", { className: t.modelName, children: c.modelName }),
1165
+ /* @__PURE__ */ e("h4", { className: t.modelName, children: d.modelName }),
1150
1166
  /* @__PURE__ */ s("div", { className: t.modelTags, children: [
1151
- c.modelProvider && /* @__PURE__ */ e(
1152
- G,
1167
+ d.modelProvider && /* @__PURE__ */ e(
1168
+ Q,
1153
1169
  {
1154
- color: p(c.modelProvider),
1170
+ color: h(d.modelProvider),
1155
1171
  style: { fontSize: 11, margin: 0 },
1156
- children: c.modelProvider
1172
+ children: d.modelProvider
1157
1173
  }
1158
1174
  ),
1159
- /* @__PURE__ */ e(G, { style: { fontSize: 11, margin: 0 }, children: c.apiType })
1175
+ /* @__PURE__ */ e(Q, { style: { fontSize: 11, margin: 0 }, children: d.apiType })
1160
1176
  ] })
1161
1177
  ] })
1162
1178
  ] }),
1163
- /* @__PURE__ */ e("p", { className: t.modelEndpoint, children: c.endpoint }),
1179
+ /* @__PURE__ */ e("p", { className: t.modelEndpoint, children: d.endpoint }),
1164
1180
  /* @__PURE__ */ e("div", { className: t.modelCardFooter, children: /* @__PURE__ */ e(
1165
- z,
1181
+ L,
1166
1182
  {
1167
1183
  type: "link",
1168
1184
  size: "small",
1169
- onClick: (i) => {
1170
- i.stopPropagation(), T(c.modelName);
1185
+ onClick: (o) => {
1186
+ o.stopPropagation(), v(d.modelName);
1171
1187
  },
1172
1188
  children: "发起对话"
1173
1189
  }
1174
1190
  ) })
1175
1191
  ]
1176
1192
  },
1177
- c.modelName
1193
+ d.modelName
1178
1194
  );
1179
1195
  }) }),
1180
- C.length > 0 && /* @__PURE__ */ s("div", { className: t.modelActionBar, children: [
1196
+ K.length > 0 && /* @__PURE__ */ s("div", { className: t.modelActionBar, children: [
1181
1197
  /* @__PURE__ */ s("span", { className: t.modelSelectionCount, children: [
1182
1198
  "已选择 ",
1183
- C.length,
1199
+ K.length,
1184
1200
  " 个模型"
1185
1201
  ] }),
1186
1202
  /* @__PURE__ */ e(
1187
- z,
1203
+ L,
1188
1204
  {
1189
1205
  type: "primary",
1190
- onClick: M,
1191
- disabled: C.length === 0,
1206
+ onClick: w,
1207
+ disabled: K.length === 0,
1192
1208
  children: "批量对比"
1193
1209
  }
1194
1210
  )
1195
1211
  ] })
1196
1212
  ] });
1197
1213
  }
1198
- const ct = "_container_15pgq_5", dt = "_page_15pgq_10", mt = "_kpiGrid_15pgq_16", ut = "_kpiCard_15pgq_22", ht = "_sectionCard_15pgq_29", pt = "_sectionHead_15pgq_36", gt = "_sectionHint_15pgq_42", kt = "_akList_15pgq_47", ft = "_errorState_15pgq_54", yt = "_errorTitle_15pgq_66", Nt = "_errorDetail_15pgq_72", O = {
1199
- container: ct,
1200
- page: dt,
1201
- kpiGrid: mt,
1202
- kpiCard: ut,
1203
- sectionCard: ht,
1204
- sectionHead: pt,
1205
- sectionHint: gt,
1206
- akList: kt,
1207
- errorState: ft,
1208
- errorTitle: yt,
1209
- errorDetail: Nt
1210
- }, vt = Fe(
1214
+ const ut = "_container_15pgq_5", ht = "_page_15pgq_10", pt = "_kpiGrid_15pgq_16", gt = "_kpiCard_15pgq_22", kt = "_sectionCard_15pgq_29", ft = "_sectionHead_15pgq_36", yt = "_sectionHint_15pgq_42", Nt = "_akList_15pgq_47", vt = "_errorState_15pgq_54", Tt = "_errorTitle_15pgq_66", St = "_errorDetail_15pgq_72", $ = {
1215
+ container: ut,
1216
+ page: ht,
1217
+ kpiGrid: pt,
1218
+ kpiCard: gt,
1219
+ sectionCard: kt,
1220
+ sectionHead: ft,
1221
+ sectionHint: yt,
1222
+ akList: Nt,
1223
+ errorState: vt,
1224
+ errorTitle: Tt,
1225
+ errorDetail: St
1226
+ }, Ct = Qe(
1211
1227
  () => import("@yuku123/z-agent-component").then((a) => ({ default: a.AgentDashboard }))
1212
- ), Tt = ["zifang", "system-default"];
1228
+ ), At = "system-default";
1213
1229
  function te(a) {
1214
1230
  return a >= 1e6 ? `${(a / 1e6).toFixed(2)}M` : a >= 1e3 ? `${(a / 1e3).toFixed(1)}K` : String(a ?? 0);
1215
1231
  }
1216
- function Ct({ daily: a }) {
1232
+ function wt({ daily: a }) {
1217
1233
  const n = Object.entries(a);
1218
1234
  if (n.length === 0) return /* @__PURE__ */ e("span", { className: t.usageEmpty, children: "暂无数据" });
1219
- const l = Math.max(...n.map(([, o]) => o[1] + o[2]), 1);
1220
- return /* @__PURE__ */ e("div", { className: t.usageBarChart, children: n.map(([o, d]) => {
1221
- const N = d[1] + d[2];
1235
+ const l = Math.max(...n.map(([, i]) => i[1] + i[2]), 1);
1236
+ return /* @__PURE__ */ e("div", { className: t.usageBarChart, children: n.map(([i, m]) => {
1237
+ const N = m[1] + m[2];
1222
1238
  return /* @__PURE__ */ s("div", { className: t.usageBarCol, children: [
1223
- /* @__PURE__ */ e(Q, { title: `${o}: ${d[0]}次 / ${N} tokens`, children: /* @__PURE__ */ e(
1239
+ /* @__PURE__ */ e(W, { title: `${i}: ${m[0]}次 / ${N} tokens`, children: /* @__PURE__ */ e(
1224
1240
  "div",
1225
1241
  {
1226
1242
  className: t.usageBar,
1227
1243
  style: { height: `${Math.max(N / l * 100, 2)}%` }
1228
1244
  }
1229
1245
  ) }),
1230
- /* @__PURE__ */ e("span", { className: t.usageBarLabel, children: o })
1231
- ] }, o);
1246
+ /* @__PURE__ */ e("span", { className: t.usageBarLabel, children: i })
1247
+ ] }, i);
1232
1248
  }) });
1233
1249
  }
1234
- function ye({ models: a }) {
1250
+ function ve({ models: a }) {
1235
1251
  const n = Object.entries(a);
1236
1252
  if (n.length === 0) return /* @__PURE__ */ e("span", { className: t.usageEmpty, children: "暂无数据" });
1237
- const l = Math.max(...n.map(([, o]) => o[0]), 1);
1238
- return /* @__PURE__ */ e("div", { className: t.modelBreakdown, children: n.sort((o, d) => d[1][0] - o[1][0]).map(([o, d]) => /* @__PURE__ */ s("div", { className: t.modelBreakdownRow, children: [
1239
- /* @__PURE__ */ e("span", { className: t.modelBreakdownName, children: o }),
1253
+ const l = Math.max(...n.map(([, i]) => i[0]), 1);
1254
+ return /* @__PURE__ */ e("div", { className: t.modelBreakdown, children: n.sort((i, m) => m[1][0] - i[1][0]).map(([i, m]) => /* @__PURE__ */ s("div", { className: t.modelBreakdownRow, children: [
1255
+ /* @__PURE__ */ e("span", { className: t.modelBreakdownName, children: i }),
1240
1256
  /* @__PURE__ */ e("div", { className: t.modelBreakdownBar, children: /* @__PURE__ */ e(
1241
1257
  "div",
1242
1258
  {
1243
1259
  className: t.modelBreakdownFill,
1244
- style: { width: `${d[0] / l * 100}%` }
1260
+ style: { width: `${m[0] / l * 100}%` }
1245
1261
  }
1246
1262
  ) }),
1247
1263
  /* @__PURE__ */ s("span", { className: t.modelBreakdownCount, children: [
1248
- d[0],
1264
+ m[0],
1249
1265
  "次 / ",
1250
- te(d[1] + (d[2] || 0)),
1266
+ te(m[1] + (m[2] || 0)),
1251
1267
  "tokens"
1252
1268
  ] })
1253
- ] }, o)) });
1269
+ ] }, i)) });
1254
1270
  }
1255
- const St = [
1271
+ const xt = [
1256
1272
  {
1257
1273
  title: "时间",
1258
1274
  dataIndex: "createTime",
@@ -1261,7 +1277,7 @@ const St = [
1261
1277
  render: (a) => a ? new Date(a).toLocaleString("zh-CN") : "-"
1262
1278
  },
1263
1279
  { title: "模型", dataIndex: "model", key: "model", width: 150 },
1264
- { title: "协议", dataIndex: "protocol", key: "protocol", width: 90, render: (a) => /* @__PURE__ */ e(G, { children: a }) },
1280
+ { title: "协议", dataIndex: "protocol", key: "protocol", width: 90, render: (a) => /* @__PURE__ */ e(Q, { children: a }) },
1265
1281
  { title: "输入", dataIndex: "promptTokens", key: "promptTokens", width: 70 },
1266
1282
  { title: "输出", dataIndex: "completionTokens", key: "completionTokens", width: 70 },
1267
1283
  { title: "总Token", dataIndex: "totalTokens", key: "totalTokens", width: 80 },
@@ -1271,198 +1287,211 @@ const St = [
1271
1287
  dataIndex: "statusCode",
1272
1288
  key: "statusCode",
1273
1289
  width: 60,
1274
- render: (a) => a ? /* @__PURE__ */ e(G, { color: a < 400 ? "green" : "red", children: a }) : "-"
1290
+ render: (a) => a ? /* @__PURE__ */ e(Q, { color: a < 400 ? "green" : "red", children: a }) : "-"
1275
1291
  }
1276
1292
  ];
1277
- function wt(a) {
1293
+ function Kt(a) {
1278
1294
  var n;
1279
1295
  return ((n = a == null ? void 0 : a.stats) == null ? void 0 : n.recent) ?? [];
1280
1296
  }
1281
- function At() {
1282
- var p, c, g, i, w, K, q;
1283
- const [a, n] = S(!0), [l, o] = S(null), [d, N] = S([]), [v, k] = S(null), [f, _] = S(null), I = H(async () => {
1284
- n(!0), o(null);
1297
+ function Mt() {
1298
+ var g, o, M, _, j, G, R;
1299
+ const [a, n] = S(!0), [l, i] = S(null), [m, N] = S([]), [T, y] = S(null), [f, b] = S(null), O = String(be((c) => {
1300
+ var E;
1301
+ return ((E = c.currentUser) == null ? void 0 : E.id) ?? "";
1302
+ })), K = Array.from(
1303
+ new Set([O, At].filter((c) => c !== ""))
1304
+ ), v = H(async () => {
1305
+ n(!0), i(null);
1285
1306
  try {
1286
- const m = await Promise.allSettled(
1287
- Tt.map((u) => ie(u))
1288
- ), P = [];
1289
- let D = 0;
1290
- for (const u of m)
1291
- u.status === "fulfilled" ? P.push(...u.value) : D += 1;
1292
- if (D === m.length)
1307
+ const c = await Promise.allSettled(
1308
+ K.map((C) => oe(C))
1309
+ ), E = [];
1310
+ let P = 0;
1311
+ for (const C of c)
1312
+ C.status === "fulfilled" ? E.push(...C.value) : P += 1;
1313
+ if (P === c.length)
1293
1314
  throw new Error("网关不可达:无法获取 AK 列表");
1294
- P.sort((u, A) => (u.id ?? 0) - (A.id ?? 0));
1295
- let E = null, j = null;
1315
+ E.sort((C, q) => (C.id ?? 0) - (q.id ?? 0));
1316
+ let r = null, p = null;
1296
1317
  try {
1297
- E = await be(0);
1298
- } catch (u) {
1299
- j = u instanceof Error ? u.message : "获取用量失败";
1318
+ r = await Ee(0);
1319
+ } catch (C) {
1320
+ p = C instanceof Error ? C.message : "获取用量失败";
1300
1321
  }
1301
- k(E);
1302
- const r = P.map((u) => ({
1303
- key: u,
1304
- stats: E,
1305
- statsError: j
1322
+ y(r);
1323
+ const A = E.map((C) => ({
1324
+ key: C,
1325
+ stats: r,
1326
+ statsError: p
1306
1327
  }));
1307
- N(r);
1308
- } catch (m) {
1309
- o(m instanceof Error ? m.message : "加载失败");
1328
+ N(A);
1329
+ } catch (c) {
1330
+ i(c instanceof Error ? c.message : "加载失败");
1310
1331
  } finally {
1311
1332
  n(!1);
1312
1333
  }
1313
- }, []);
1314
- ae(() => {
1315
- I();
1316
- }, [I]);
1317
- const C = xe(() => {
1318
- const m = v, P = {};
1319
- for (const [D, E] of Object.entries((m == null ? void 0 : m.models) ?? {}))
1320
- P[D] = [E[0] ?? 0, E[1] ?? 0, E[2] ?? 0];
1334
+ }, [K.join(",")]);
1335
+ X(() => {
1336
+ v();
1337
+ }, [v]);
1338
+ const w = Me(() => {
1339
+ const c = T, E = {};
1340
+ for (const [P, r] of Object.entries((c == null ? void 0 : c.models) ?? {}))
1341
+ E[P] = [r[0] ?? 0, r[1] ?? 0, r[2] ?? 0];
1321
1342
  return {
1322
- requests: (m == null ? void 0 : m.totalRequests) ?? 0,
1323
- tokens: (m == null ? void 0 : m.totalTokens) ?? 0,
1324
- avgLatency: (m == null ? void 0 : m.avgLatencyMs) ?? 0,
1325
- errors: (m == null ? void 0 : m.errorCount) ?? 0,
1326
- models: P
1343
+ requests: (c == null ? void 0 : c.totalRequests) ?? 0,
1344
+ tokens: (c == null ? void 0 : c.totalTokens) ?? 0,
1345
+ avgLatency: (c == null ? void 0 : c.avgLatencyMs) ?? 0,
1346
+ errors: (c == null ? void 0 : c.errorCount) ?? 0,
1347
+ models: E
1327
1348
  };
1328
- }, [v]), T = d.reduce((m, P) => m + (P.key.tokenQuota || 0), 0), M = () => a ? /* @__PURE__ */ e("div", { style: { textAlign: "center", padding: 60 }, children: /* @__PURE__ */ e(V, { tip: "加载监控数据..." }) }) : l ? /* @__PURE__ */ s("div", { className: O.errorState, children: [
1329
- /* @__PURE__ */ e("div", { className: O.errorTitle, children: "模型监控数据加载失败" }),
1330
- /* @__PURE__ */ e("div", { className: O.errorDetail, children: l }),
1331
- /* @__PURE__ */ e(z, { icon: /* @__PURE__ */ e(Ne, {}), onClick: I, type: "primary", children: "重试" })
1332
- ] }) : /* @__PURE__ */ s("div", { className: O.page, children: [
1333
- /* @__PURE__ */ s("div", { className: O.kpiGrid, children: [
1334
- /* @__PURE__ */ e("div", { className: O.kpiCard, children: /* @__PURE__ */ e(B, { title: "总请求(近7天)", value: C.requests }) }),
1335
- /* @__PURE__ */ e("div", { className: O.kpiCard, children: /* @__PURE__ */ e(B, { title: "总 Tokens", value: te(C.tokens) }) }),
1336
- /* @__PURE__ */ e("div", { className: O.kpiCard, children: /* @__PURE__ */ e(B, { title: "平均延迟", value: C.avgLatency, suffix: "ms" }) }),
1337
- /* @__PURE__ */ e("div", { className: O.kpiCard, children: /* @__PURE__ */ e(
1349
+ }, [T]), h = m.reduce((c, E) => c + (E.key.tokenQuota || 0), 0), d = () => a ? /* @__PURE__ */ e("div", { style: { textAlign: "center", padding: 60 }, children: /* @__PURE__ */ e(V, { tip: "加载监控数据..." }) }) : l ? /* @__PURE__ */ s("div", { className: $.errorState, children: [
1350
+ /* @__PURE__ */ e("div", { className: $.errorTitle, children: "模型监控数据加载失败" }),
1351
+ /* @__PURE__ */ e("div", { className: $.errorDetail, children: l }),
1352
+ /* @__PURE__ */ e(L, { icon: /* @__PURE__ */ e(Te, {}), onClick: v, type: "primary", children: "重试" })
1353
+ ] }) : /* @__PURE__ */ s("div", { className: $.page, children: [
1354
+ /* @__PURE__ */ s("div", { className: $.kpiGrid, children: [
1355
+ /* @__PURE__ */ e("div", { className: $.kpiCard, children: /* @__PURE__ */ e(B, { title: "总请求(近7天)", value: w.requests }) }),
1356
+ /* @__PURE__ */ e("div", { className: $.kpiCard, children: /* @__PURE__ */ e(B, { title: "总 Tokens", value: te(w.tokens) }) }),
1357
+ /* @__PURE__ */ e("div", { className: $.kpiCard, children: /* @__PURE__ */ e(B, { title: "平均延迟", value: w.avgLatency, suffix: "ms" }) }),
1358
+ /* @__PURE__ */ e("div", { className: $.kpiCard, children: /* @__PURE__ */ e(
1338
1359
  B,
1339
1360
  {
1340
1361
  title: "错误数",
1341
- value: C.errors,
1342
- valueStyle: C.errors > 0 ? { color: "#ff4d4f" } : void 0
1362
+ value: w.errors,
1363
+ valueStyle: w.errors > 0 ? { color: "#ff4d4f" } : void 0
1343
1364
  }
1344
1365
  ) })
1345
1366
  ] }),
1346
- /* @__PURE__ */ s("div", { className: O.sectionCard, children: [
1347
- /* @__PURE__ */ s("div", { className: O.sectionHead, children: [
1367
+ /* @__PURE__ */ s("div", { className: $.sectionCard, children: [
1368
+ /* @__PURE__ */ s("div", { className: $.sectionHead, children: [
1348
1369
  /* @__PURE__ */ e("span", { className: t.usageSectionTitle, children: "AK 用量" }),
1349
- T > 0 && /* @__PURE__ */ s("span", { className: O.sectionHint, children: [
1370
+ h > 0 && /* @__PURE__ */ s("span", { className: $.sectionHint, children: [
1350
1371
  "合计额度 ",
1351
- te(T),
1372
+ te(h),
1352
1373
  " tokens"
1353
1374
  ] })
1354
1375
  ] }),
1355
- d.length === 0 ? /* @__PURE__ */ e("div", { className: t.akEmpty, children: "网关下暂无 AK" }) : /* @__PURE__ */ e("div", { className: O.akList, children: d.map((m) => {
1356
- const P = m.key.totalTokens ?? 0, D = m.key.tokenQuota || 0, E = D > 0 ? Math.min(P / D * 100, 100) : 0;
1376
+ m.length === 0 ? /* @__PURE__ */ e("div", { className: t.akEmpty, children: "网关下暂无 AK" }) : /* @__PURE__ */ e("div", { className: $.akList, children: m.map((c) => {
1377
+ const E = c.key.totalTokens ?? 0, P = c.key.tokenQuota || 0, r = P > 0 ? Math.min(E / P * 100, 100) : 0;
1357
1378
  return /* @__PURE__ */ s(
1358
1379
  "div",
1359
1380
  {
1360
1381
  className: t.akCard,
1361
- onClick: () => _(m),
1382
+ onClick: () => b(c),
1362
1383
  children: [
1363
1384
  /* @__PURE__ */ s("div", { className: t.akCardRow, children: [
1364
- /* @__PURE__ */ e("span", { className: t.akTitle, children: m.key.description || m.key.userName || `AK #${m.key.id}` }),
1365
- /* @__PURE__ */ e("span", { className: t.akPrefixSmall, children: m.key.akPrefix }),
1385
+ /* @__PURE__ */ e("span", { className: t.akTitle, children: c.key.description || c.key.userName || `AK #${c.key.id}` }),
1386
+ /* @__PURE__ */ e("span", { className: t.akPrefixSmall, children: c.key.akPrefix }),
1366
1387
  /* @__PURE__ */ e(
1367
1388
  "span",
1368
1389
  {
1369
- className: `${t.akStatus} ${m.key.active ? t.akStatusActive : t.akStatusRevoked}`,
1370
- children: m.key.active ? "启用" : "吊销"
1390
+ className: `${t.akStatus} ${c.key.active ? t.akStatusActive : t.akStatusRevoked}`,
1391
+ children: c.key.active ? "启用" : "吊销"
1371
1392
  }
1372
1393
  ),
1373
- /* @__PURE__ */ e("span", { className: t.akMetaText, children: m.key.userId === "system-default" ? "系统对话" : m.key.userId })
1394
+ /* @__PURE__ */ e("span", { className: t.akMetaText, children: c.key.userId === "system-default" ? "系统对话" : c.key.userId })
1374
1395
  ] }),
1375
1396
  /* @__PURE__ */ s("div", { className: t.akCardRow2, children: [
1376
1397
  /* @__PURE__ */ e("div", { className: t.akMiniBar, children: /* @__PURE__ */ e(
1377
1398
  "div",
1378
1399
  {
1379
1400
  className: t.akMiniBarFill,
1380
- style: { width: `${E}%` }
1401
+ style: { width: `${r}%` }
1381
1402
  }
1382
1403
  ) }),
1383
1404
  /* @__PURE__ */ s("span", { className: t.akUsageText, children: [
1384
- te(P),
1385
- D > 0 ? ` / ${te(D)}` : "",
1405
+ te(E),
1406
+ P > 0 ? ` / ${te(P)}` : "",
1386
1407
  " tokens"
1387
1408
  ] }),
1388
- /* @__PURE__ */ e("span", { className: t.akMetaText, children: m.statsError ? m.statsError : m.key.lastUsedAt ? `最近使用 ${m.key.lastUsedAt}` : "尚未使用" })
1409
+ /* @__PURE__ */ e("span", { className: t.akMetaText, children: c.statsError ? c.statsError : c.key.lastUsedAt ? `最近使用 ${c.key.lastUsedAt}` : "尚未使用" })
1389
1410
  ] })
1390
1411
  ]
1391
1412
  },
1392
- m.key.id
1413
+ c.key.id
1393
1414
  );
1394
1415
  }) })
1395
1416
  ] }),
1396
- /* @__PURE__ */ s("div", { className: O.sectionCard, children: [
1417
+ /* @__PURE__ */ s("div", { className: $.sectionCard, children: [
1397
1418
  /* @__PURE__ */ e("span", { className: t.usageSectionTitle, children: "模型用量分布(网关全局)" }),
1398
- /* @__PURE__ */ e(ye, { models: C.models })
1419
+ /* @__PURE__ */ e(ve, { models: w.models })
1399
1420
  ] })
1400
1421
  ] });
1401
- return /* @__PURE__ */ s("div", { className: O.container, children: [
1422
+ return /* @__PURE__ */ s("div", { className: $.container, children: [
1402
1423
  /* @__PURE__ */ s("div", { className: t.modelMgmtHeader, children: [
1403
1424
  /* @__PURE__ */ e("h2", { className: t.modelMgmtTitle, children: "模型监控" }),
1404
- /* @__PURE__ */ e("p", { className: t.modelMgmtSubtitle, children: "大模型网关管控视图 — 按 AK / 模型聚合调用量、Tokens 与延迟(近 30 天)" })
1425
+ /* @__PURE__ */ e("p", { className: t.modelMgmtSubtitle, children: "大模型网关管控视图 — 网关全局聚合调用量、Tokens 与延迟(近 7 天)" })
1405
1426
  ] }),
1406
1427
  /* @__PURE__ */ e(
1407
- Ce,
1428
+ Ae,
1408
1429
  {
1409
1430
  defaultActiveKey: "usage",
1410
1431
  items: [
1411
- { key: "usage", label: "模型用量", children: M() },
1432
+ { key: "usage", label: "模型用量", children: d() },
1412
1433
  {
1413
1434
  key: "sessions",
1414
1435
  label: "会话统计",
1415
- children: /* @__PURE__ */ e(je, { fallback: /* @__PURE__ */ e(V, { tip: "加载会话统计..." }), children: /* @__PURE__ */ e(vt, {}) })
1436
+ children: /* @__PURE__ */ e(Je, { fallback: /* @__PURE__ */ e(V, { tip: "加载会话统计..." }), children: /* @__PURE__ */ e(Ct, {}) })
1416
1437
  }
1417
1438
  ]
1418
1439
  }
1419
1440
  ),
1420
1441
  /* @__PURE__ */ e(
1421
- we,
1442
+ xe,
1422
1443
  {
1423
1444
  title: f ? `AK 用量 — ${f.key.description || f.key.akPrefix}` : "",
1424
1445
  width: 860,
1425
1446
  open: !!f,
1426
- onClose: () => _(null),
1447
+ onClose: () => b(null),
1427
1448
  destroyOnHidden: !0,
1428
1449
  children: f && /* @__PURE__ */ s("div", { className: t.usageDrawerContent, children: [
1450
+ /* @__PURE__ */ e("div", { style: { fontSize: 12, color: "#8c8c8c", marginBottom: 12 }, children: "调用监控是网关全局维度(不按 AK 留存),以下统计覆盖全部 AK; 该 AK 自身的累计消耗见「本 AK 累计 Token」。" }),
1429
1451
  /* @__PURE__ */ s("div", { className: t.usageStatsGrid, children: [
1430
- /* @__PURE__ */ e(B, { title: "总请求", value: ((p = f.stats) == null ? void 0 : p.totalRequests) ?? 0 }),
1431
- /* @__PURE__ */ e(B, { title: "总 Tokens", value: ((c = f.stats) == null ? void 0 : c.totalTokens) ?? 0 }),
1432
- /* @__PURE__ */ e(B, { title: "平均延迟", value: ((g = f.stats) == null ? void 0 : g.avgLatencyMs) ?? 0, suffix: "ms" }),
1433
- /* @__PURE__ */ e(B, { title: "输入 Tokens", value: ((i = f.stats) == null ? void 0 : i.totalPromptTokens) ?? 0 }),
1434
- /* @__PURE__ */ e(B, { title: "输出 Tokens", value: ((w = f.stats) == null ? void 0 : w.totalCompletionTokens) ?? 0 }),
1452
+ /* @__PURE__ */ e(B, { title: "总请求", value: ((g = f.stats) == null ? void 0 : g.totalRequests) ?? 0 }),
1453
+ /* @__PURE__ */ e(B, { title: "总 Tokens", value: ((o = f.stats) == null ? void 0 : o.totalTokens) ?? 0 }),
1454
+ /* @__PURE__ */ e(B, { title: "平均延迟", value: ((M = f.stats) == null ? void 0 : M.avgLatencyMs) ?? 0, suffix: "ms" }),
1455
+ /* @__PURE__ */ e(B, { title: "输入 Tokens", value: ((_ = f.stats) == null ? void 0 : _.totalPromptTokens) ?? 0 }),
1456
+ /* @__PURE__ */ e(B, { title: "输出 Tokens", value: ((j = f.stats) == null ? void 0 : j.totalCompletionTokens) ?? 0 }),
1457
+ /* @__PURE__ */ e(
1458
+ B,
1459
+ {
1460
+ title: "本 AK 累计 Token",
1461
+ value: f.key.totalTokens ?? 0
1462
+ }
1463
+ ),
1435
1464
  /* @__PURE__ */ e(
1436
1465
  B,
1437
1466
  {
1438
1467
  title: "错误数",
1439
- value: ((K = f.stats) == null ? void 0 : K.errorCount) ?? 0,
1440
- valueStyle: (((q = f.stats) == null ? void 0 : q.errorCount) ?? 0) > 0 ? { color: "#ff4d4f" } : void 0
1468
+ value: ((G = f.stats) == null ? void 0 : G.errorCount) ?? 0,
1469
+ valueStyle: (((R = f.stats) == null ? void 0 : R.errorCount) ?? 0) > 0 ? { color: "#ff4d4f" } : void 0
1441
1470
  }
1442
1471
  )
1443
1472
  ] }),
1444
1473
  /* @__PURE__ */ s("div", { className: t.usageSection, children: [
1445
- /* @__PURE__ */ e("span", { className: t.usageSectionTitle, children: "每日用量(近 30 天)" }),
1446
- f.stats ? /* @__PURE__ */ e(Ct, { daily: f.stats.daily ?? {} }) : /* @__PURE__ */ e("span", { className: t.usageEmpty, children: f.statsError ?? "暂无数据" })
1474
+ /* @__PURE__ */ e("span", { className: t.usageSectionTitle, children: "每日用量(按最近调用明细聚合)" }),
1475
+ f.stats ? /* @__PURE__ */ e(wt, { daily: f.stats.daily ?? {} }) : /* @__PURE__ */ e("span", { className: t.usageEmpty, children: f.statsError ?? "暂无数据" })
1447
1476
  ] }),
1448
1477
  /* @__PURE__ */ s("div", { className: t.usageSection, children: [
1449
- /* @__PURE__ */ e("span", { className: t.usageSectionTitle, children: "模型用量分布" }),
1450
- f.stats ? /* @__PURE__ */ e(ye, { models: f.stats.models ?? {} }) : /* @__PURE__ */ e("span", { className: t.usageEmpty, children: f.statsError ?? "暂无数据" })
1478
+ /* @__PURE__ */ e("span", { className: t.usageSectionTitle, children: "模型用量分布(按最近调用明细聚合)" }),
1479
+ f.stats ? /* @__PURE__ */ e(ve, { models: f.stats.models ?? {} }) : /* @__PURE__ */ e("span", { className: t.usageEmpty, children: f.statsError ?? "暂无数据" })
1451
1480
  ] }),
1452
1481
  /* @__PURE__ */ s("div", { className: t.usageSection, children: [
1453
1482
  /* @__PURE__ */ e("span", { className: t.usageSectionTitle, children: "最近调用" }),
1454
1483
  /* @__PURE__ */ e(
1455
- Ae,
1484
+ Ke,
1456
1485
  {
1457
1486
  size: "small",
1458
- columns: St,
1459
- dataSource: wt(f),
1487
+ columns: xt,
1488
+ dataSource: Kt(f),
1460
1489
  rowKey: "id",
1461
1490
  pagination: {
1462
1491
  pageSize: 8,
1463
1492
  showSizeChanger: !0,
1464
1493
  pageSizeOptions: ["8", "20", "50", "100"],
1465
- showTotal: (m) => `共 ${m} 条`
1494
+ showTotal: (c) => `共 ${c} 条`
1466
1495
  }
1467
1496
  }
1468
1497
  )
@@ -1472,49 +1501,49 @@ function At() {
1472
1501
  )
1473
1502
  ] });
1474
1503
  }
1475
- const xt = [
1476
- { key: "model-management", label: "模型管理", icon: /* @__PURE__ */ e(Oe, {}) },
1477
- { key: "model-chat", label: "模型对话", icon: /* @__PURE__ */ e(De, {}) },
1478
- { key: "ak-management", label: "AK 管理", icon: /* @__PURE__ */ e(Le, {}) },
1479
- { key: "agent-app", label: "Agent 应用", icon: /* @__PURE__ */ e(Te, {}) },
1480
- { key: "mcp-service", label: "MCP 服务", icon: /* @__PURE__ */ e(ze, {}) },
1481
- { key: "skill-market", label: "技能市场", icon: /* @__PURE__ */ e(Re, {}) },
1482
- { key: "model-monitor", label: "模型监控", icon: /* @__PURE__ */ e(Ue, {}) }
1504
+ const bt = [
1505
+ { key: "model-management", label: "模型管理", icon: /* @__PURE__ */ e(ze, {}) },
1506
+ { key: "model-chat", label: "模型对话", icon: /* @__PURE__ */ e(Re, {}) },
1507
+ { key: "ak-management", label: "AK 管理", icon: /* @__PURE__ */ e(Ue, {}) },
1508
+ { key: "agent-app", label: "Agent 应用", icon: /* @__PURE__ */ e(Ce, {}) },
1509
+ { key: "mcp-service", label: "MCP 服务", icon: /* @__PURE__ */ e(He, {}) },
1510
+ { key: "skill-market", label: "技能市场", icon: /* @__PURE__ */ e(je, {}) },
1511
+ { key: "model-monitor", label: "模型监控", icon: /* @__PURE__ */ e(qe, {}) }
1483
1512
  ];
1484
- function It() {
1485
- const [a, n] = S("model-management"), [l, o] = S([]), d = (k) => {
1486
- o(k), n("model-chat");
1487
- }, N = xe(() => xt, []), v = (k, f, _ = !1) => /* @__PURE__ */ e(
1513
+ function Dt() {
1514
+ const [a, n] = S("model-management"), [l, i] = S([]), m = (y) => {
1515
+ i(y), n("model-chat");
1516
+ }, N = Me(() => bt, []), T = (y, f, b = !1) => /* @__PURE__ */ e(
1488
1517
  "div",
1489
1518
  {
1490
1519
  style: {
1491
- display: a === k ? _ ? "flex" : "block" : "none",
1520
+ display: a === y ? b ? "flex" : "block" : "none",
1492
1521
  height: "100%",
1493
- ..._ ? { flexDirection: "column" } : {}
1522
+ ...b ? { flexDirection: "column" } : {}
1494
1523
  },
1495
1524
  children: f
1496
1525
  }
1497
1526
  );
1498
1527
  return /* @__PURE__ */ s("div", { className: t.container, children: [
1499
- /* @__PURE__ */ e("aside", { className: t.sidebar, children: /* @__PURE__ */ e("nav", { className: t.menuList, children: N.map((k) => /* @__PURE__ */ e(Q, { title: k.label, placement: "right", children: /* @__PURE__ */ e(
1528
+ /* @__PURE__ */ e("aside", { className: t.sidebar, children: /* @__PURE__ */ e("nav", { className: t.menuList, children: N.map((y) => /* @__PURE__ */ e(W, { title: y.label, placement: "right", children: /* @__PURE__ */ e(
1500
1529
  "div",
1501
1530
  {
1502
- className: `${t.menuItem} ${a === k.key ? t.menuItemActive : ""}`,
1503
- onClick: () => n(k.key),
1504
- children: /* @__PURE__ */ e("span", { className: t.menuIcon, children: k.icon })
1531
+ className: `${t.menuItem} ${a === y.key ? t.menuItemActive : ""}`,
1532
+ onClick: () => n(y.key),
1533
+ children: /* @__PURE__ */ e("span", { className: t.menuIcon, children: y.icon })
1505
1534
  }
1506
- ) }, k.key)) }) }),
1535
+ ) }, y.key)) }) }),
1507
1536
  /* @__PURE__ */ s("main", { className: t.panelArea, children: [
1508
- v("model-management", /* @__PURE__ */ e(ot, { onStartChat: d })),
1509
- v("model-chat", /* @__PURE__ */ e(it, { initialModels: l }), !0),
1510
- v("ak-management", /* @__PURE__ */ e(st, {})),
1511
- v("agent-app", /* @__PURE__ */ e(Ge, {})),
1512
- v("mcp-service", /* @__PURE__ */ e(Je, {})),
1513
- v("skill-market", /* @__PURE__ */ e(Qe, {})),
1514
- v("model-monitor", /* @__PURE__ */ e(At, {}))
1537
+ T("model-management", /* @__PURE__ */ e(mt, { onStartChat: m })),
1538
+ T("model-chat", /* @__PURE__ */ e(dt, { initialModels: l }), !0),
1539
+ T("ak-management", /* @__PURE__ */ e(ot, {})),
1540
+ T("agent-app", /* @__PURE__ */ e(We, {})),
1541
+ T("mcp-service", /* @__PURE__ */ e(Ye, {})),
1542
+ T("skill-market", /* @__PURE__ */ e(Ve, {})),
1543
+ T("model-monitor", /* @__PURE__ */ e(Mt, {}))
1515
1544
  ] })
1516
1545
  ] });
1517
1546
  }
1518
1547
  export {
1519
- It as default
1548
+ Dt as default
1520
1549
  };