@yuku123/z-team-component 0.2.51 → 0.2.52

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