@yuku123/z-team-component 0.2.42 → 0.2.45

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