@yuku123/z-team-component 0.2.45 → 0.2.47

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