@yuku123/z-team-component 0.2.48 → 0.2.50

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