@yuku123/z-team-component 0.2.42 → 0.2.43

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