@yuku123/z-team-component 0.2.136 → 0.2.138

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.
Files changed (49) hide show
  1. package/dist/{AdminModuleContent-T7ZXoVAV.js → AdminModuleContent-9gH_G78B.js} +12866 -13280
  2. package/dist/{ChangeLogView-ChmYvz8Z.js → ChangeLogView-DzFmZVBw.js} +1 -1
  3. package/dist/{ComponentDoc-D5Gbd6B_.js → ComponentDoc-KyD5wtuW.js} +435 -445
  4. package/dist/{InvitationManagementPage-kaqwNuPz.js → InvitationManagementPage-6-0uZNuO.js} +1 -1
  5. package/dist/{OnboardingPage-Cy_sPHS1.js → OnboardingPage-tLarxnp5.js} +2 -2
  6. package/dist/{ScheduledTasks-GAP-U6s9.js → ScheduledTasks-QGmD7Uhz.js} +6 -6
  7. package/dist/SystemShell-CWawiWOn.js +885 -0
  8. package/dist/SystemWorkbench.module-CZv_ruUa.js +36 -0
  9. package/dist/{admin-logs-BdwcT77i.js → admin-logs-DXjxD-y2.js} +1 -1
  10. package/dist/{api-6nYxtAbN.js → api-DOjASQ0k.js} +1 -1
  11. package/dist/{api-B0S5AhOe.js → api-Dzr8HLsU.js} +1 -1
  12. package/dist/{createWorkspaceWsHandler-B9UE_uoO.js → createWorkspaceWsHandler-DCokPv4M.js} +3 -3
  13. package/dist/{index-DJu6AFf9.js → index-0AjMJyFL.js} +3 -3
  14. package/dist/{index-CCsvaPw9.js → index-4NOi2xz4.js} +2 -2
  15. package/dist/{index-g36zRqmZ.js → index-4icVyiM3.js} +5 -5
  16. package/dist/{index-B0f8tIBU.js → index-8VddM67M.js} +2 -2
  17. package/dist/{index-BQYKmytF.js → index-B75TTql4.js} +2 -2
  18. package/dist/{index-Y9EcfhJG.js → index-BHfNKXIA.js} +3 -3
  19. package/dist/{index-tln7BkiQ.js → index-BdEokzAv.js} +6 -6
  20. package/dist/{index-CX19wylA.js → index-BgdqkNkT.js} +3 -3
  21. package/dist/{index-DOYSz9Bg.js → index-C9NwYJh-.js} +1 -1
  22. package/dist/{index-eqbuW74W.js → index-CLP0LnEz.js} +12 -12
  23. package/dist/index-CNmSLd0s.js +1894 -0
  24. package/dist/{index-cY1tZiV2.js → index-CUOByyqy.js} +3 -3
  25. package/dist/{index-CnKYpM41.js → index-CjYmL2yJ.js} +1 -1
  26. package/dist/{index-BWaPbYG2.js → index-Crzx3zh2.js} +2 -2
  27. package/dist/index-Cwptuq_d.js +1323 -0
  28. package/dist/{index-B6n7ueTc.js → index-DC1fQH0J.js} +2 -2
  29. package/dist/{index-DNAeZe0a.js → index-DGdtqBi4.js} +4 -4
  30. package/dist/{index-CazCOFR2.js → index-DXA0r7Co.js} +2 -2
  31. package/dist/{index-DgYhtv8V.js → index-DZcMGMHV.js} +4 -4
  32. package/dist/{index-BC6eLVMc.js → index-DarTFF-M.js} +1 -1
  33. package/dist/{index-C7DP8H_Q.js → index-DxZEpsT6.js} +2964 -2962
  34. package/dist/{index-DWi-8Esh.js → index-PJZV-bFc.js} +1 -1
  35. package/dist/{index-DJ2TNQP6.js → index-VqKcDrn3.js} +2 -2
  36. package/dist/{index-DbThmpZg.js → index-ZqDoLUxb.js} +1 -1
  37. package/dist/index.js +1 -1
  38. package/dist/{instance-ChzeFK3e.js → instance-CDA6R8yG.js} +1 -1
  39. package/dist/{menuPermission-DDzb20pQ.js → menuPermission-LCjN8Osm.js} +3 -3
  40. package/dist/pages.js +1 -1
  41. package/dist/{send-default-agent-team-message-DOgtkW6m.js → send-default-agent-team-message-3Uyy88s_.js} +1 -1
  42. package/dist/{sso-user-DaRbfrdM.js → sso-user-DX2FYQCh.js} +1 -1
  43. package/dist/{training-N-5-qsDf.js → training-BgYM7EV-.js} +1 -1
  44. package/dist/{webide-BEV0VT3u.js → webide-BsF30aLX.js} +1289 -1255
  45. package/dist/z-team-component.css +1 -1
  46. package/package.json +1 -1
  47. package/dist/SystemShell-69TBLWk8.js +0 -978
  48. package/dist/index-CE1Vtf-B.js +0 -1718
  49. package/dist/index-T4Rvjyn0.js +0 -1299
@@ -1,1718 +0,0 @@
1
- import { jsxs as o, jsx as e } from "react/jsx-runtime";
2
- import { CopyOutlined as re, ReloadOutlined as Ae, PlusOutlined as Be, DeleteOutlined as qe, ClearOutlined as Ge, CloseOutlined as Je, SendOutlined as We, RobotOutlined as xe, CloudServerOutlined as Qe, MessageOutlined as Ve, KeyOutlined as Ye, ApiOutlined as Xe, ToolOutlined as Ze, BarChartOutlined as et } from "@ant-design/icons";
3
- import { useState as f, useEffect as Z, useCallback as F, useRef as pe, useMemo as Ie, Suspense as tt, lazy as at } from "react";
4
- import { Table as _e, Tooltip as ae, Tabs as Me, Input as fe, Button as z, Modal as ke, Drawer as be, Spin as ne, Statistic as K, message as J, Tag as Y, Select as nt, Checkbox as ot } from "antd";
5
- import { u as Pe } from "./ComponentDoc-D5Gbd6B_.js";
6
- import { AgentAppList as st, McpPage as lt, SkillMarket as rt } from "@yuku123/z-agent-component";
7
- const de = "ft_gateway_default_ak", Ee = "system-default", ee = "", ye = "";
8
- function te(a = {}) {
9
- const n = { Accept: "application/json", ...a };
10
- try {
11
- const l = localStorage.getItem("token");
12
- l && (n.Authorization = `Bearer ${l}`);
13
- } catch {
14
- }
15
- return n;
16
- }
17
- function ct(a) {
18
- return {
19
- modelName: String(a.modelName ?? a.model_name ?? a.service ?? ""),
20
- service: String(a.service ?? a.modelName ?? ""),
21
- endpoint: String(a.endpoint ?? ""),
22
- modelProvider: a.modelProvider ?? a.model_provider ?? null,
23
- apiType: String(a.apiType ?? a.api_type ?? "OpenAPI")
24
- };
25
- }
26
- async function Ne() {
27
- let a;
28
- try {
29
- a = await fetch(`${ee}/api/scenario-instances/0/models`, {
30
- credentials: "include",
31
- headers: te({
32
- Accept: "application/json",
33
- "project-env": window.ENV_TYPE ?? "local"
34
- })
35
- });
36
- } catch {
37
- throw new Error("模型列表不可达:模型配置接口请求失败");
38
- }
39
- if (!a.ok)
40
- throw new Error(`模型列表获取失败(HTTP ${a.status})`);
41
- let n;
42
- try {
43
- n = await a.json();
44
- } catch {
45
- throw new Error("模型列表返回格式异常(非 JSON)");
46
- }
47
- const l = n != null && n.success ? n.data : (n == null ? void 0 : n.data) ?? n;
48
- if (!Array.isArray(l))
49
- throw new Error("模型列表返回格式异常(非数组)");
50
- return l.map(ct);
51
- }
52
- async function it(a, n, l, c) {
53
- var I, O, A;
54
- const u = await fetch(`${ye}/v1/chat/completions`, {
55
- method: "POST",
56
- headers: {
57
- "Content-Type": "application/json",
58
- Authorization: `Bearer ${a}`,
59
- Accept: "text/event-stream"
60
- },
61
- body: JSON.stringify({
62
- model: n,
63
- messages: l,
64
- stream: !0
65
- }),
66
- signal: c.signal
67
- });
68
- if (!u.ok || !u.body) {
69
- const T = await u.text().catch(() => "");
70
- if (/<!doctype html/i.test(T.slice(0, 200)))
71
- throw new Error("模型网关未接入(/v1/chat/completions 落到主壳 SPA,无网关响应)");
72
- let S = `HTTP ${u.status}`;
73
- try {
74
- const h = JSON.parse(T);
75
- S = ((I = h == null ? void 0 : h.error) == null ? void 0 : I.message) ?? S;
76
- } catch {
77
- T && (S = T);
78
- }
79
- throw new Error(S);
80
- }
81
- const y = u.body.getReader(), N = new TextDecoder();
82
- let _ = "", k;
83
- try {
84
- for (; ; ) {
85
- const { done: T, value: S } = await y.read();
86
- if (T) break;
87
- _ += N.decode(S, { stream: !0 });
88
- const h = _.split(`
89
-
90
- `);
91
- _ = h.pop() ?? "";
92
- for (const i of h) {
93
- let g = "";
94
- for (const m of i.split(`
95
- `))
96
- m.startsWith("data:") && (g += m.slice(5).trim());
97
- if (!g || g === "[DONE]") {
98
- if (g === "[DONE]") {
99
- c.onDone(k);
100
- return;
101
- }
102
- continue;
103
- }
104
- try {
105
- const m = JSON.parse(g), B = m == null ? void 0 : m.choices;
106
- if (m != null && m.usage) {
107
- const b = {
108
- promptTokens: m.usage.prompt_tokens ?? 0,
109
- completionTokens: m.usage.completion_tokens ?? 0,
110
- totalTokens: m.usage.total_tokens ?? 0
111
- };
112
- (!k || b.totalTokens > 0) && (k = b);
113
- }
114
- if (Array.isArray(B) && B.length > 0) {
115
- const b = (O = B[0]) == null ? void 0 : O.delta;
116
- b != null && b.content && c.onDelta(b.content);
117
- continue;
118
- }
119
- c.onDone(k);
120
- return;
121
- } catch {
122
- }
123
- }
124
- }
125
- c.onDone(k);
126
- } catch (T) {
127
- if ((A = c.signal) != null && A.aborted) return;
128
- throw c.onError(T instanceof Error ? T : new Error(String(T))), T;
129
- }
130
- }
131
- async function le(a, n) {
132
- const l = await a.text();
133
- if (!a.ok)
134
- throw new Error(`${n}失败 HTTP ${a.status}${l ? `: ${l.slice(0, 120)}` : ""}`);
135
- if (/<!doctype html/i.test(l.slice(0, 200)))
136
- throw new Error("AK 接口落到主壳 SPA(无后端响应)");
137
- try {
138
- return JSON.parse(l);
139
- } catch {
140
- throw new Error(`${n}返回非 JSON:${l.slice(0, 120)}`);
141
- }
142
- }
143
- function dt(a) {
144
- const n = a.status === 1;
145
- return {
146
- id: Number(a.id),
147
- akPrefix: a.access_key ?? "",
148
- userId: a.owner_user_id ?? "",
149
- userName: a.owner_user_name ?? "",
150
- description: a.description || a.ak_name || "",
151
- status: n ? "active" : "disabled",
152
- active: n,
153
- isDeleted: a.is_deleted ?? 0,
154
- totalRequests: 0,
155
- totalTokens: Number(a.total_tokens ?? 0),
156
- tokenQuota: 0,
157
- rateLimitRpm: 0,
158
- defaultModel: null,
159
- lastUsedAt: a.last_used_time ?? null,
160
- createTime: (a.created_time ?? "").replace("T", " ").slice(0, 19),
161
- updateTime: (a.updated_time ?? "").replace("T", " ").slice(0, 19),
162
- secret: a.secret_key
163
- };
164
- }
165
- async function Ke(a, n, l) {
166
- const c = await fetch(`${ee}/api/ak/create`, {
167
- method: "POST",
168
- headers: te({ Accept: "application/json", "Content-Type": "application/json" }),
169
- credentials: "include",
170
- body: JSON.stringify({
171
- akName: l || `AK-${n || a}`,
172
- description: l,
173
- akType: "PERSONAL",
174
- ownerUserId: a,
175
- ownerUserName: n
176
- })
177
- }), u = await le(c, "创建 AK"), y = (u == null ? void 0 : u.data) ?? {}, N = y.accessKey ?? "", _ = y.secretKey ?? "";
178
- return N && _ && Te(N, _), { apiKey: _, akPrefix: N, message: "AK 已创建,secretKey 仅创建时可见" };
179
- }
180
- async function me(a) {
181
- const n = await fetch(
182
- `${ee}/api/ak/list`,
183
- { headers: te({ Accept: "application/json" }), credentials: "include" }
184
- ), l = await le(n, "获取 AK 列表"), c = Array.isArray(l == null ? void 0 : l.data) ? l.data : [];
185
- return (a ? c.filter((y) => (y.owner_user_id == null || y.owner_user_id === "" ? Ee : String(y.owner_user_id)) === String(a)) : c).filter((y) => (y.is_deleted ?? 0) === 0).map(dt);
186
- }
187
- async function mt(a) {
188
- const n = await fetch(`${ee}/api/ak/delete?id=${encodeURIComponent(String(a))}`, {
189
- method: "POST",
190
- headers: te({ Accept: "application/json" }),
191
- credentials: "include"
192
- });
193
- await le(n, "吊销 AK");
194
- }
195
- async function $e(a) {
196
- var T, S;
197
- const n = await fetch(
198
- `${ee}/api/admin/llm-call-monitor/stats?hours=168`,
199
- { headers: te({ Accept: "application/json" }), credentials: "include" }
200
- ), l = await le(n, "获取调用统计"), u = ((l == null ? void 0 : l.data) ?? {}).summary ?? {};
201
- let y = [];
202
- try {
203
- const h = await fetch(
204
- `${ee}/api/admin/llm-call-monitor/recent?page=1&size=20`,
205
- { headers: te({ Accept: "application/json" }), credentials: "include" }
206
- ), i = await le(h, "获取调用明细");
207
- y = (Array.isArray((T = i == null ? void 0 : i.data) == null ? void 0 : T.records) ? i.data.records : []).map((m, B) => {
208
- const b = Number(m.promptTokens ?? 0), j = Number(m.completionTokens ?? 0);
209
- return {
210
- id: Number(m.id ?? B),
211
- apiKeyId: a,
212
- protocol: "chat/completions",
213
- model: String(m.model ?? ""),
214
- stream: Number(m.stream ?? 0),
215
- promptTokens: b,
216
- completionTokens: j,
217
- totalTokens: Number(m.totalTokens ?? b + j),
218
- latencyMs: Number(m.durationMs ?? 0),
219
- statusCode: m.success === !1 || m.success === 0 ? 500 : 200,
220
- errorMsg: m.errorType ?? null,
221
- createTime: String(m.createTime ?? "").replace("T", " ").slice(0, 19)
222
- };
223
- });
224
- } catch {
225
- }
226
- const N = {}, _ = {};
227
- for (const h of y) {
228
- const i = N[S = h.model] || (N[S] = [0, 0, 0]);
229
- i[0] += 1, i[1] += h.promptTokens, i[2] += h.completionTokens;
230
- const g = (h.createTime || "").slice(0, 10);
231
- if (g) {
232
- const m = _[g] || (_[g] = [0, 0, 0]);
233
- m[0] += 1, m[1] += h.promptTokens, m[2] += h.completionTokens;
234
- }
235
- }
236
- const k = Number(u.totalTokens ?? 0), I = y.reduce((h, i) => h + i.totalTokens, 0), O = y.reduce((h, i) => h + i.promptTokens, 0), A = y.reduce((h, i) => h + i.completionTokens, 0);
237
- return {
238
- totalRequests: Number(u.totalCount ?? 0),
239
- // 汇总口径优先用后端整窗合计(后端 selectStats 才有 token 合计),
240
- // 明细只有最近一页 ⇒ 只在汇总缺失时用明细兜底。
241
- totalPromptTokens: Number(u.totalPromptTokens ?? 0) || O,
242
- totalCompletionTokens: Number(u.totalCompletionTokens ?? 0) || A,
243
- totalTokens: k || I,
244
- avgLatencyMs: Number(u.avgDurationMs ?? 0),
245
- errorCount: Number(u.failCount ?? 0),
246
- daily: _,
247
- models: N,
248
- recent: y
249
- };
250
- }
251
- function ut() {
252
- return typeof window < "u" ? `${window.location.origin}${ye}` : ye;
253
- }
254
- async function Le(a) {
255
- const n = await fetch(`${ee}${a}`, {
256
- headers: te({ Accept: "application/json" }),
257
- credentials: "include"
258
- });
259
- if (!(n.headers.get("content-type") || "").includes("json"))
260
- throw new Error("网关控制面未启用(该路径返回的是前端页面,不是接口)");
261
- if (!n.ok)
262
- throw new Error(`网关控制面请求失败(HTTP ${n.status})`);
263
- return n.json();
264
- }
265
- async function ht() {
266
- return Le("/z-llm/admin/overview");
267
- }
268
- async function pt() {
269
- const a = await Le("/z-llm/admin/usage");
270
- return (Array.isArray(a == null ? void 0 : a.byTenant) ? a.byTenant : []).map((l) => ({
271
- tenantCode: String(l.tenantCode ?? l.keyId ?? ""),
272
- requests: Number(l.requests ?? l.count ?? 0),
273
- promptTokens: Number(l.promptTokens ?? 0),
274
- completionTokens: Number(l.completionTokens ?? 0),
275
- cost: Number(l.cost ?? 0)
276
- }));
277
- }
278
- const Ce = "ft_gateway_ak_cache";
279
- function Te(a, n) {
280
- try {
281
- const l = JSON.parse(localStorage.getItem(Ce) || "{}");
282
- l[a] = n, localStorage.setItem(Ce, JSON.stringify(l));
283
- } catch {
284
- }
285
- }
286
- function kt(a) {
287
- try {
288
- return JSON.parse(localStorage.getItem(Ce) || "{}")[a] || null;
289
- } catch {
290
- return null;
291
- }
292
- }
293
- async function gt() {
294
- try {
295
- const c = localStorage.getItem(de);
296
- if (c) return c;
297
- } catch {
298
- }
299
- const n = (await me("").catch(() => [])).find((c) => c.active && c.secret);
300
- if (n != null && n.secret) {
301
- try {
302
- localStorage.setItem(de, n.secret);
303
- } catch {
304
- }
305
- return n.akPrefix && Te(n.akPrefix, n.secret), n.secret;
306
- }
307
- const l = await Ke(
308
- "system-default",
309
- "系统默认",
310
- "智能工作台默认AK(自动创建)"
311
- );
312
- if (!l.apiKey)
313
- throw new Error("AK 创建成功但未返回 secretKey");
314
- try {
315
- localStorage.setItem(de, l.apiKey);
316
- } catch {
317
- }
318
- return l.apiKey;
319
- }
320
- function Oe() {
321
- try {
322
- localStorage.removeItem(de);
323
- } catch {
324
- }
325
- }
326
- const _t = "_container_18ocl_7", ft = "_sidebar_18ocl_16", yt = "_menuList_18ocl_26", Ct = "_menuItem_18ocl_35", Nt = "_menuItemActive_18ocl_53", Tt = "_menuIcon_18ocl_59", vt = "_menuLabel_18ocl_64", wt = "_panelArea_18ocl_70", St = "_modelMgmtHeader_18ocl_82", At = "_modelMgmtTitle_18ocl_86", Bt = "_modelMgmtSubtitle_18ocl_93", xt = "_modelGrid_18ocl_99", It = "_modelCard_18ocl_105", Mt = "_modelCardSelected_18ocl_134", bt = "_modelCardHeader_18ocl_139", Pt = "_modelIconWrap_18ocl_146", Et = "_modelCardInfo_18ocl_159", Kt = "_modelName_18ocl_164", $t = "_modelTags_18ocl_173", Lt = "_modelEndpoint_18ocl_189", Ot = "_modelCardFooter_18ocl_198", Ut = "_modelCheckbox_18ocl_206", Rt = "_modelActionBar_18ocl_213", Dt = "_modelSelectionCount_18ocl_227", zt = "_chatContainer_18ocl_236", Ht = "_chatHeader_18ocl_243", Ft = "_chatTitle_18ocl_251", jt = "_chatPanels_18ocl_258", qt = "_chatPanel_18ocl_258", Gt = "_chatPanelHeader_18ocl_285", Jt = "_chatPanelClose_18ocl_295", Wt = "_chatPanelBody_18ocl_307", Qt = "_chatMsgUser_18ocl_316", Vt = "_chatMsgAI_18ocl_328", Yt = "_chatMsgError_18ocl_341", Xt = "_chatStreamingCursor_18ocl_351", Zt = "_chatUsageBar_18ocl_370", ea = "_chatThinkBlock_18ocl_380", ta = "_chatInputBar_18ocl_429", aa = "_chatInput_18ocl_429", na = "_addPanelBtn_18ocl_442", oa = "_akContainer_18ocl_471", sa = "_akIntegrationPanel_18ocl_477", la = "_akIntegrationTitle_18ocl_484", ra = "_akIntegrationGrid_18ocl_491", ca = "_akCodeBlock_18ocl_497", ia = "_akCodeLabel_18ocl_509", da = "_akCard_18ocl_516", ma = "_akCardRow_18ocl_534", ua = "_akTitle_18ocl_541", ha = "_akPrefixSmall_18ocl_551", pa = "_akStatus_18ocl_557", ka = "_akStatusActive_18ocl_563", ga = "_akStatusRevoked_18ocl_569", _a = "_akCardActions_18ocl_575", fa = "_akCardRow2_18ocl_582", ya = "_akMiniBar_18ocl_588", Ca = "_akMiniBarFill_18ocl_597", Na = "_akUsageText_18ocl_604", Ta = "_akMetaText_18ocl_611", va = "_akEmpty_18ocl_617", wa = "_akBaseUrlRow_18ocl_625", Sa = "_akBaseUrlItem_18ocl_631", Aa = "_akBaseUrlLabel_18ocl_641", Ba = "_akBaseUrlValue_18ocl_647", xa = "_akCopyIcon_18ocl_657", Ia = "_usageDrawerContent_18ocl_671", Ma = "_usageStatsGrid_18ocl_677", ba = "_usageSection_18ocl_683", Pa = "_usageSectionTitle_18ocl_687", Ea = "_usageBarChart_18ocl_697", Ka = "_usageBarCol_18ocl_706", $a = "_usageBar_18ocl_697", La = "_usageBarLabel_18ocl_729", Oa = "_modelBreakdown_18ocl_737", Ua = "_modelBreakdownRow_18ocl_743", Ra = "_modelBreakdownName_18ocl_749", Da = "_modelBreakdownBar_18ocl_759", za = "_modelBreakdownFill_18ocl_767", Ha = "_modelBreakdownCount_18ocl_774", Fa = "_usageEmpty_18ocl_781", t = {
327
- container: _t,
328
- sidebar: ft,
329
- menuList: yt,
330
- menuItem: Ct,
331
- menuItemActive: Nt,
332
- menuIcon: Tt,
333
- menuLabel: vt,
334
- panelArea: wt,
335
- modelMgmtHeader: St,
336
- modelMgmtTitle: At,
337
- modelMgmtSubtitle: Bt,
338
- modelGrid: xt,
339
- modelCard: It,
340
- modelCardSelected: Mt,
341
- modelCardHeader: bt,
342
- modelIconWrap: Pt,
343
- modelCardInfo: Et,
344
- modelName: Kt,
345
- modelTags: $t,
346
- modelEndpoint: Lt,
347
- modelCardFooter: Ot,
348
- modelCheckbox: Ut,
349
- modelActionBar: Rt,
350
- modelSelectionCount: Dt,
351
- chatContainer: zt,
352
- chatHeader: Ht,
353
- chatTitle: Ft,
354
- chatPanels: jt,
355
- chatPanel: qt,
356
- chatPanelHeader: Gt,
357
- chatPanelClose: Jt,
358
- chatPanelBody: Wt,
359
- chatMsgUser: Qt,
360
- chatMsgAI: Vt,
361
- chatMsgError: Yt,
362
- chatStreamingCursor: Xt,
363
- chatUsageBar: Zt,
364
- chatThinkBlock: ea,
365
- chatInputBar: ta,
366
- chatInput: aa,
367
- addPanelBtn: na,
368
- akContainer: oa,
369
- akIntegrationPanel: sa,
370
- akIntegrationTitle: la,
371
- akIntegrationGrid: ra,
372
- akCodeBlock: ca,
373
- akCodeLabel: ia,
374
- akCard: da,
375
- akCardRow: ma,
376
- akTitle: ua,
377
- akPrefixSmall: ha,
378
- akStatus: pa,
379
- akStatusActive: ka,
380
- akStatusRevoked: ga,
381
- akCardActions: _a,
382
- akCardRow2: fa,
383
- akMiniBar: ya,
384
- akMiniBarFill: Ca,
385
- akUsageText: Na,
386
- akMetaText: Ta,
387
- akEmpty: va,
388
- akBaseUrlRow: wa,
389
- akBaseUrlItem: Sa,
390
- akBaseUrlLabel: Aa,
391
- akBaseUrlValue: Ba,
392
- akCopyIcon: xa,
393
- usageDrawerContent: Ia,
394
- usageStatsGrid: Ma,
395
- usageSection: ba,
396
- usageSectionTitle: Pa,
397
- usageBarChart: Ea,
398
- usageBarCol: Ka,
399
- usageBar: $a,
400
- usageBarLabel: La,
401
- modelBreakdown: Oa,
402
- modelBreakdownRow: Ua,
403
- modelBreakdownName: Ra,
404
- modelBreakdownBar: Da,
405
- modelBreakdownFill: za,
406
- modelBreakdownCount: Ha,
407
- usageEmpty: Fa
408
- };
409
- function ce(a) {
410
- return a >= 1e6 ? `${(a / 1e6).toFixed(1)}M` : a >= 1e3 ? `${(a / 1e3).toFixed(1)}K` : `${a}`;
411
- }
412
- function ja(a, n) {
413
- return `# OpenAI 兼容
414
- curl -X POST ${a}/v1/chat/completions \\
415
- -H "Content-Type: application/json" \\
416
- -H "Authorization: Bearer ft-xxx" \\
417
- -d '{
418
- "model": "${n}",
419
- "messages": [{"role":"user","content":"你好"}],
420
- "stream": true
421
- }'`;
422
- }
423
- function qa(a, n) {
424
- return `# Anthropic 兼容
425
- curl -X POST ${a}/v1/messages \\
426
- -H "Content-Type: application/json" \\
427
- -H "x-api-key: ft-xxx" \\
428
- -d '{
429
- "model": "${n}",
430
- "messages": [{"role":"user","content":"你好"}]
431
- }'`;
432
- }
433
- function Ga() {
434
- const [a, n] = f("personal"), [l, c] = f([]), [u, y] = f([]), [N, _] = f(!0), [k, I] = f(!1), [O, A] = f(!1), [T, S] = f(""), [h, i] = f({ open: !1 }), [g, m] = f(null), [B, b] = f(null), [j, X] = f(!1), [W, d] = f(null), [P, U] = f([]), [s, p] = f(""), v = Pe((r) => r.currentUser), x = String((v == null ? void 0 : v.id) ?? ""), E = (v == null ? void 0 : v.username) ?? "", [M, q] = f(""), Q = ut(), [R, H] = f("<model-name>");
435
- Z(() => {
436
- let r = !1;
437
- return Ne().then((C) => {
438
- !r && C.length > 0 && H(C[0].modelName);
439
- }).catch(() => {
440
- }), () => {
441
- r = !0;
442
- };
443
- }, []), Z(() => {
444
- let r = !1;
445
- return Promise.all([ht(), pt()]).then(([C, G]) => {
446
- r || (d(C), U(G), p(""));
447
- }).catch((C) => {
448
- r || (d(null), U([]), p(C instanceof Error ? C.message : "网关台账不可用"));
449
- }), () => {
450
- r = !0;
451
- };
452
- }, []);
453
- const V = F(async () => {
454
- _(!0);
455
- try {
456
- const r = x ? await me(x).catch(() => []) : [], [C] = await Promise.all([
457
- me("system-default").catch(() => [])
458
- ]);
459
- c(C), y(r);
460
- } finally {
461
- _(!1);
462
- }
463
- }, [x]);
464
- Z(() => {
465
- V();
466
- }, [V]);
467
- const ue = () => {
468
- S(""), A(!0);
469
- }, ve = async () => {
470
- if (!T.trim()) {
471
- J.warning("请输入 AK 名称");
472
- return;
473
- }
474
- if (!x) {
475
- J.warning("登录态不可用,无法生成 AK");
476
- return;
477
- }
478
- I(!0);
479
- try {
480
- const r = await Ke(x, E, T.trim());
481
- Te(r.akPrefix, r.apiKey), A(!1), i({
482
- open: !0,
483
- apiKey: r.apiKey,
484
- akPrefix: r.akPrefix
485
- }), V();
486
- } catch (r) {
487
- J.error(r instanceof Error ? r.message : "创建 AK 失败");
488
- } finally {
489
- I(!1);
490
- }
491
- }, Ue = (r) => {
492
- ke.confirm({
493
- title: "确认吊销此 AK?",
494
- content: "吊销后此 AK 将立即失效,无法恢复。",
495
- okText: "确认吊销",
496
- okType: "danger",
497
- cancelText: "取消",
498
- onOk: async () => {
499
- try {
500
- await mt(r), J.success("AK 已吊销"), V(), Oe();
501
- } catch (C) {
502
- J.error(C instanceof Error ? C.message : "吊销失败");
503
- }
504
- }
505
- });
506
- }, oe = (r) => {
507
- navigator.clipboard.writeText(r).then(() => J.success("已复制到剪贴板")).catch(() => J.warning("复制失败,请手动复制"));
508
- }, Re = (r) => {
509
- const C = kt(r.akPrefix);
510
- C ? oe(C) : (oe(r.akPrefix), J.info("完整 AK 未在本地缓存(可能在本设备外创建),已复制前缀"));
511
- }, De = async (r) => {
512
- m(r), X(!0), b(null);
513
- try {
514
- const C = await $e(r.id);
515
- b(C);
516
- } catch (C) {
517
- J.error(C instanceof Error ? C.message : "获取用量失败");
518
- } finally {
519
- X(!1);
520
- }
521
- }, ze = () => {
522
- m(null), b(null);
523
- }, He = (r) => {
524
- const C = Object.entries(r);
525
- if (C.length === 0)
526
- return /* @__PURE__ */ e("span", { className: t.usageEmpty, children: "暂无数据" });
527
- const G = Math.max(...C.map(([, $]) => $[1] + $[2]), 1);
528
- return /* @__PURE__ */ e("div", { className: t.usageBarChart, children: C.map(([$, D]) => {
529
- const w = D[1] + D[2], he = w / G * 100;
530
- return /* @__PURE__ */ o("div", { className: t.usageBarCol, children: [
531
- /* @__PURE__ */ e(ae, { title: `${$}: ${D[0]}次 / ${w} tokens`, children: /* @__PURE__ */ e(
532
- "div",
533
- {
534
- className: t.usageBar,
535
- style: { height: `${Math.max(he, 2)}%` }
536
- }
537
- ) }),
538
- /* @__PURE__ */ e("span", { className: t.usageBarLabel, children: $ })
539
- ] }, $);
540
- }) });
541
- }, Fe = (r) => {
542
- const C = Object.entries(r);
543
- if (C.length === 0)
544
- return /* @__PURE__ */ e("span", { className: t.usageEmpty, children: "暂无数据" });
545
- const G = Math.max(...C.map(([, $]) => $[0]), 1);
546
- return /* @__PURE__ */ e("div", { className: t.modelBreakdown, children: C.sort(($, D) => D[1][0] - $[1][0]).map(([$, D]) => /* @__PURE__ */ o("div", { className: t.modelBreakdownRow, children: [
547
- /* @__PURE__ */ e("span", { className: t.modelBreakdownName, children: $ }),
548
- /* @__PURE__ */ e("div", { className: t.modelBreakdownBar, children: /* @__PURE__ */ e(
549
- "div",
550
- {
551
- className: t.modelBreakdownFill,
552
- style: { width: `${D[0] / G * 100}%` }
553
- }
554
- ) }),
555
- /* @__PURE__ */ o("span", { className: t.modelBreakdownCount, children: [
556
- D[0],
557
- "次 / ",
558
- D[1] + (D[2] || 0),
559
- "tokens"
560
- ] })
561
- ] }, $)) });
562
- }, je = [
563
- {
564
- title: "时间",
565
- dataIndex: "createTime",
566
- key: "createTime",
567
- width: 160,
568
- render: (r) => r ? new Date(r).toLocaleString("zh-CN") : "-"
569
- },
570
- { title: "模型", dataIndex: "model", key: "model", width: 140 },
571
- {
572
- title: "协议",
573
- dataIndex: "protocol",
574
- key: "protocol",
575
- width: 90,
576
- render: (r) => /* @__PURE__ */ e(Y, { children: r })
577
- },
578
- {
579
- title: "输入",
580
- dataIndex: "promptTokens",
581
- key: "promptTokens",
582
- width: 70
583
- },
584
- {
585
- title: "输出",
586
- dataIndex: "completionTokens",
587
- key: "completionTokens",
588
- width: 70
589
- },
590
- {
591
- title: "总Token",
592
- dataIndex: "totalTokens",
593
- key: "totalTokens",
594
- width: 80
595
- },
596
- {
597
- title: "耗时",
598
- dataIndex: "latencyMs",
599
- key: "latencyMs",
600
- width: 70,
601
- render: (r) => r ? `${r}ms` : "-"
602
- },
603
- {
604
- title: "状态",
605
- dataIndex: "statusCode",
606
- key: "statusCode",
607
- width: 60,
608
- render: (r) => r ? /* @__PURE__ */ e(Y, { color: r < 400 ? "green" : "red", children: r }) : "-"
609
- }
610
- ], we = (r, C) => {
611
- const G = Array.isArray(r) ? r : [], $ = M.trim().toLowerCase(), D = $ ? G.filter(
612
- (w) => `${w.description || ""} ${w.akPrefix || ""} ${w.defaultModel || ""}`.toLowerCase().includes($)
613
- ) : G;
614
- return N ? /* @__PURE__ */ e("div", { style: { textAlign: "center", padding: 40 }, children: /* @__PURE__ */ e(ne, { tip: "加载中..." }) }) : G.length === 0 ? /* @__PURE__ */ e("div", { className: t.akEmpty, children: C ? "暂无应用 AK" : "暂无个人 AK,点击上方按钮生成" }) : D.length === 0 ? /* @__PURE__ */ e("div", { className: t.akEmpty, children: "无匹配 AK" }) : /* @__PURE__ */ e("div", { style: { display: "flex", flexDirection: "column", gap: 8 }, children: D.map((w) => /* @__PURE__ */ o(
615
- "div",
616
- {
617
- className: t.akCard,
618
- onClick: () => De(w),
619
- children: [
620
- /* @__PURE__ */ o("div", { className: t.akCardRow, children: [
621
- /* @__PURE__ */ e("span", { className: t.akTitle, children: w.description || w.akPrefix.replace("...", "**") }),
622
- /* @__PURE__ */ e("code", { className: t.akPrefixSmall, children: w.akPrefix.replace("...", "**") }),
623
- /* @__PURE__ */ e(
624
- "span",
625
- {
626
- className: `${t.akStatus} ${w.active ? t.akStatusActive : t.akStatusRevoked}`,
627
- children: w.active ? "活跃" : "已吊销"
628
- }
629
- ),
630
- w.defaultModel && /* @__PURE__ */ o(Y, { style: { fontSize: 11 }, children: [
631
- "默认: ",
632
- w.defaultModel
633
- ] }),
634
- /* @__PURE__ */ o(
635
- "div",
636
- {
637
- className: t.akCardActions,
638
- onClick: (he) => he.stopPropagation(),
639
- children: [
640
- /* @__PURE__ */ e(ae, { title: "复制完整 AK", children: /* @__PURE__ */ e(
641
- z,
642
- {
643
- size: "small",
644
- icon: /* @__PURE__ */ e(re, {}),
645
- onClick: () => Re(w),
646
- children: "复制"
647
- }
648
- ) }),
649
- !C && w.active && /* @__PURE__ */ e(
650
- z,
651
- {
652
- size: "small",
653
- danger: !0,
654
- icon: /* @__PURE__ */ e(qe, {}),
655
- onClick: () => Ue(w.id),
656
- children: "吊销"
657
- }
658
- )
659
- ]
660
- }
661
- )
662
- ] }),
663
- /* @__PURE__ */ o("div", { className: t.akCardRow2, children: [
664
- w.tokenQuota > 0 && /* @__PURE__ */ e("div", { className: t.akMiniBar, children: /* @__PURE__ */ e(
665
- "div",
666
- {
667
- className: t.akMiniBarFill,
668
- style: {
669
- width: `${Math.min(
670
- (w.totalTokens || 0) / w.tokenQuota * 100,
671
- 100
672
- )}%`
673
- }
674
- }
675
- ) }),
676
- /* @__PURE__ */ o("span", { className: t.akUsageText, children: [
677
- ce(w.totalTokens || 0),
678
- w.tokenQuota > 0 ? ` / ${ce(w.tokenQuota)}` : " tokens"
679
- ] }),
680
- /* @__PURE__ */ e("span", { className: t.akMetaText, children: w.lastUsedAt ? `最近使用 ${w.lastUsedAt}` : "尚未使用" }),
681
- /* @__PURE__ */ e("span", { className: t.akMetaText, children: new Date(w.createTime).toLocaleDateString("zh-CN") })
682
- ] })
683
- ]
684
- },
685
- w.id
686
- )) });
687
- };
688
- return /* @__PURE__ */ o("div", { className: t.akContainer, children: [
689
- (W || P.length > 0 || s) && /* @__PURE__ */ o("div", { className: t.akIntegrationPanel, children: [
690
- /* @__PURE__ */ o("h4", { className: t.akIntegrationTitle, children: [
691
- "网关台账",
692
- W && /* @__PURE__ */ e("span", { style: { fontWeight: 400, fontSize: 12, marginLeft: 8, opacity: 0.7 }, children: W.vendors.map((r) => `${r.vendor} ${r.credentials} 凭据/${r.models} 模型`).join(" · ") })
693
- ] }),
694
- s ? /* @__PURE__ */ e("div", { style: { fontSize: 12, opacity: 0.65 }, children: s }) : P.length === 0 ? /* @__PURE__ */ e("div", { style: { fontSize: 12, opacity: 0.65 }, children: "暂无租户用量(仅绑定 tenantCode 并发生过调用的 AK 才会入账)" }) : /* @__PURE__ */ e(
695
- _e,
696
- {
697
- size: "small",
698
- rowKey: "tenantCode",
699
- pagination: !1,
700
- dataSource: P,
701
- columns: [
702
- { title: "租户", dataIndex: "tenantCode", key: "tenantCode" },
703
- { title: "请求数", dataIndex: "requests", key: "requests", width: 90 },
704
- {
705
- title: "Prompt",
706
- dataIndex: "promptTokens",
707
- key: "promptTokens",
708
- width: 100,
709
- render: (r) => ce(r)
710
- },
711
- {
712
- title: "Completion",
713
- dataIndex: "completionTokens",
714
- key: "completionTokens",
715
- width: 110,
716
- render: (r) => ce(r)
717
- },
718
- {
719
- title: "成本",
720
- dataIndex: "cost",
721
- key: "cost",
722
- width: 90,
723
- render: (r) => r ? r.toFixed(4) : "-"
724
- }
725
- ]
726
- }
727
- )
728
- ] }),
729
- /* @__PURE__ */ o("div", { className: t.akIntegrationPanel, children: [
730
- /* @__PURE__ */ e("h4", { className: t.akIntegrationTitle, children: "协议接入地址" }),
731
- /* @__PURE__ */ o("div", { className: t.akBaseUrlRow, children: [
732
- /* @__PURE__ */ o("div", { className: t.akBaseUrlItem, children: [
733
- /* @__PURE__ */ e("span", { className: t.akBaseUrlLabel, children: "OpenAI 兼容" }),
734
- /* @__PURE__ */ e("code", { className: t.akBaseUrlValue, children: Q }),
735
- /* @__PURE__ */ e(ae, { title: "复制 Base URL", children: /* @__PURE__ */ e(
736
- re,
737
- {
738
- className: t.akCopyIcon,
739
- onClick: () => oe(Q)
740
- }
741
- ) })
742
- ] }),
743
- /* @__PURE__ */ o("div", { className: t.akBaseUrlItem, children: [
744
- /* @__PURE__ */ e("span", { className: t.akBaseUrlLabel, children: "Anthropic 兼容" }),
745
- /* @__PURE__ */ e("code", { className: t.akBaseUrlValue, children: Q }),
746
- /* @__PURE__ */ e(ae, { title: "复制 Base URL", children: /* @__PURE__ */ e(
747
- re,
748
- {
749
- className: t.akCopyIcon,
750
- onClick: () => oe(Q)
751
- }
752
- ) })
753
- ] })
754
- ] }),
755
- /* @__PURE__ */ o("div", { className: t.akIntegrationGrid, children: [
756
- /* @__PURE__ */ o("div", { children: [
757
- /* @__PURE__ */ e("p", { className: t.akCodeLabel, children: "OpenAI 兼容 — curl 示例" }),
758
- /* @__PURE__ */ e("pre", { className: t.akCodeBlock, children: ja(Q, R) })
759
- ] }),
760
- /* @__PURE__ */ o("div", { children: [
761
- /* @__PURE__ */ e("p", { className: t.akCodeLabel, children: "Anthropic 兼容 — curl 示例" }),
762
- /* @__PURE__ */ e("pre", { className: t.akCodeBlock, children: qa(Q, R) })
763
- ] })
764
- ] })
765
- ] }),
766
- /* @__PURE__ */ o("div", { children: [
767
- /* @__PURE__ */ o(
768
- "div",
769
- {
770
- style: {
771
- display: "flex",
772
- justifyContent: "space-between",
773
- alignItems: "center",
774
- marginBottom: 12
775
- },
776
- children: [
777
- /* @__PURE__ */ e(
778
- Me,
779
- {
780
- activeKey: a,
781
- onChange: (r) => n(r),
782
- items: [
783
- { key: "app", label: "应用 AK" },
784
- { key: "personal", label: "个人 AK" }
785
- ],
786
- style: { flex: 1 }
787
- }
788
- ),
789
- /* @__PURE__ */ o("div", { style: { display: "flex", gap: 8 }, children: [
790
- /* @__PURE__ */ e(
791
- fe.Search,
792
- {
793
- allowClear: !0,
794
- placeholder: "按名称 / 前缀过滤",
795
- style: { width: 200 },
796
- onChange: (r) => q(r.target.value)
797
- }
798
- ),
799
- /* @__PURE__ */ e(z, { icon: /* @__PURE__ */ e(Ae, {}), onClick: V, size: "small", children: "刷新" }),
800
- a === "personal" && /* @__PURE__ */ e(
801
- z,
802
- {
803
- type: "primary",
804
- icon: /* @__PURE__ */ e(Be, {}),
805
- onClick: ue,
806
- loading: k,
807
- children: "生成 AK"
808
- }
809
- )
810
- ] })
811
- ]
812
- }
813
- ),
814
- a === "app" ? we(l, !0) : we(u, !1)
815
- ] }),
816
- /* @__PURE__ */ o(
817
- ke,
818
- {
819
- open: O,
820
- title: "生成新 AK",
821
- onCancel: () => A(!1),
822
- onOk: ve,
823
- okText: "确认生成",
824
- cancelText: "取消",
825
- confirmLoading: k,
826
- children: [
827
- /* @__PURE__ */ e(
828
- "div",
829
- {
830
- style: {
831
- marginBottom: 8,
832
- color: "var(--text-secondary)",
833
- fontSize: 13
834
- },
835
- children: "请输入 AK 名称(用于标识此密钥的用途)"
836
- }
837
- ),
838
- /* @__PURE__ */ e(
839
- fe,
840
- {
841
- placeholder: "例如:测试用 AK、生产网关 AK",
842
- value: T,
843
- onChange: (r) => S(r.target.value),
844
- onPressEnter: ve,
845
- maxLength: 50,
846
- autoFocus: !0
847
- }
848
- )
849
- ]
850
- }
851
- ),
852
- /* @__PURE__ */ o(
853
- ke,
854
- {
855
- open: h.open,
856
- title: "AK 创建成功",
857
- onCancel: () => i({ open: !1 }),
858
- footer: [
859
- /* @__PURE__ */ e(
860
- z,
861
- {
862
- icon: /* @__PURE__ */ e(re, {}),
863
- onClick: () => h.apiKey && oe(h.apiKey),
864
- children: "复制 AK"
865
- },
866
- "copy"
867
- ),
868
- /* @__PURE__ */ e(
869
- z,
870
- {
871
- type: "primary",
872
- onClick: () => i({ open: !1 }),
873
- children: "我已保存"
874
- },
875
- "close"
876
- )
877
- ],
878
- children: [
879
- /* @__PURE__ */ e("div", { style: { marginBottom: 8, color: "#faad14", fontSize: 14 }, children: "请立即保存此 AK,关闭后将无法再次查看完整密钥。" }),
880
- /* @__PURE__ */ e(
881
- "div",
882
- {
883
- style: {
884
- background: "var(--bg-tertiary, #f6f8fa)",
885
- padding: "12px 14px",
886
- borderRadius: 8,
887
- fontFamily: "SF Mono, Fira Code, monospace",
888
- fontSize: 13,
889
- wordBreak: "break-all",
890
- userSelect: "all"
891
- },
892
- children: h.apiKey
893
- }
894
- ),
895
- /* @__PURE__ */ o("div", { style: { marginTop: 8, fontSize: 12, color: "var(--text-muted)" }, children: [
896
- "前缀: ",
897
- h.akPrefix
898
- ] })
899
- ]
900
- }
901
- ),
902
- /* @__PURE__ */ e(
903
- be,
904
- {
905
- title: g ? /* @__PURE__ */ o("span", { children: [
906
- "AK 详情 — ",
907
- /* @__PURE__ */ e("code", { children: g.akPrefix })
908
- ] }) : "AK 详情",
909
- open: !!g,
910
- onClose: ze,
911
- size: "large",
912
- children: j ? /* @__PURE__ */ e("div", { style: { textAlign: "center", padding: 60 }, children: /* @__PURE__ */ e(ne, { tip: "加载用量数据..." }) }) : B ? /* @__PURE__ */ o("div", { className: t.usageDrawerContent, children: [
913
- /* @__PURE__ */ e("div", { style: { fontSize: 12, color: "#8c8c8c", marginBottom: 12 }, children: "以下为网关全局调用统计(近 7 天窗口), 监控侧不按 AK 留存;该 AK 自身的累计消耗见下方「本 AK 累计 Token」。" }),
914
- /* @__PURE__ */ o("div", { className: t.usageStatsGrid, children: [
915
- /* @__PURE__ */ e(K, { title: "总请求数", value: B.totalRequests }),
916
- /* @__PURE__ */ e(K, { title: "总 Token", value: B.totalTokens }),
917
- /* @__PURE__ */ e(
918
- K,
919
- {
920
- title: "输入 Token",
921
- value: B.totalPromptTokens
922
- }
923
- ),
924
- /* @__PURE__ */ e(
925
- K,
926
- {
927
- title: "输出 Token",
928
- value: B.totalCompletionTokens
929
- }
930
- ),
931
- /* @__PURE__ */ e(
932
- K,
933
- {
934
- title: "平均耗时",
935
- value: B.avgLatencyMs,
936
- suffix: "ms"
937
- }
938
- ),
939
- /* @__PURE__ */ e(
940
- K,
941
- {
942
- title: "错误数",
943
- value: B.errorCount,
944
- styles: {
945
- content: {
946
- color: B.errorCount > 0 ? "#ff4d4f" : void 0
947
- }
948
- }
949
- }
950
- ),
951
- /* @__PURE__ */ e(
952
- K,
953
- {
954
- title: "本 AK 累计 Token",
955
- value: (g == null ? void 0 : g.totalTokens) ?? 0
956
- }
957
- )
958
- ] }),
959
- /* @__PURE__ */ o("div", { className: t.usageSection, children: [
960
- /* @__PURE__ */ e("h4", { className: t.usageSectionTitle, children: "每日调用曲线(按最近调用明细聚合)" }),
961
- He(B.daily)
962
- ] }),
963
- /* @__PURE__ */ o("div", { className: t.usageSection, children: [
964
- /* @__PURE__ */ e("h4", { className: t.usageSectionTitle, children: "模型用量分布" }),
965
- Fe(B.models)
966
- ] }),
967
- /* @__PURE__ */ o("div", { className: t.usageSection, children: [
968
- /* @__PURE__ */ e("h4", { className: t.usageSectionTitle, children: "最近调用记录" }),
969
- /* @__PURE__ */ e(
970
- _e,
971
- {
972
- columns: je,
973
- dataSource: B.recent,
974
- rowKey: "id",
975
- size: "small",
976
- pagination: {
977
- pageSize: 10,
978
- size: "small",
979
- showSizeChanger: !0,
980
- pageSizeOptions: ["10", "20", "50", "100"],
981
- showTotal: (r) => `共 ${r} 条`
982
- },
983
- scroll: { x: 760 }
984
- }
985
- )
986
- ] })
987
- ] }) : /* @__PURE__ */ e("div", { className: t.usageEmpty, children: "暂无用量数据" })
988
- }
989
- )
990
- ] });
991
- }
992
- function Ja(a) {
993
- const n = [];
994
- if (!a) return n;
995
- const l = /<(think|thinking|reasoning)>([\s\S]*?)<\/\1>/gi;
996
- let c = 0, u;
997
- for (; (u = l.exec(a)) !== null; )
998
- u.index > c && n.push({ type: "text", text: a.slice(c, u.index) }), n.push({ type: "think", text: u[2] }), c = u.index + u[0].length;
999
- return c < a.length && n.push({ type: "text", text: a.slice(c) }), n;
1000
- }
1001
- const ie = 4;
1002
- let Wa = 0;
1003
- function Qa({ initialModels: a }) {
1004
- const [n, l] = f([]), [c, u] = f([]), [y, N] = f(!0), [_, k] = f(null), [I, O] = f(""), [A, T] = f(!1), S = pe(""), h = pe(/* @__PURE__ */ new Map()), i = pe(/* @__PURE__ */ new Map());
1005
- Z(() => {
1006
- (async () => {
1007
- try {
1008
- const s = await Ne();
1009
- u(s), N(!1);
1010
- const p = a.length > 0 ? a : s.slice(0, 1).map((v) => v.modelName);
1011
- l(p.slice(0, ie).map((v) => ge(v)));
1012
- } catch (s) {
1013
- N(!1), k(s instanceof Error ? s.message : "模型列表加载失败");
1014
- }
1015
- })();
1016
- }, []), Z(() => {
1017
- if (a.length > 0 && c.length > 0) {
1018
- const s = a.slice(0, ie).map((p) => ge(p));
1019
- l(s);
1020
- }
1021
- }, [a.join(",")]);
1022
- const g = F((s) => {
1023
- const p = i.current.get(s);
1024
- p && (p.scrollTop = p.scrollHeight);
1025
- }, []), m = F(
1026
- (s, p) => {
1027
- l((v) => v.map((x) => x.id === s ? p(x) : x));
1028
- },
1029
- []
1030
- ), B = F(async () => {
1031
- if (S.current) return S.current;
1032
- const s = await gt();
1033
- return S.current = s, s;
1034
- }, []), b = F(async () => {
1035
- const s = I.trim();
1036
- if (!s || A) return;
1037
- let p;
1038
- try {
1039
- p = await B();
1040
- } catch {
1041
- return;
1042
- }
1043
- O(""), T(!0);
1044
- const v = n.map((M) => ({
1045
- ...M,
1046
- messages: [
1047
- ...M.messages,
1048
- { role: "user", content: s },
1049
- { role: "assistant", content: "" }
1050
- ],
1051
- streamingContent: "",
1052
- isStreaming: !0,
1053
- error: null,
1054
- usage: null
1055
- }));
1056
- l(v);
1057
- const x = v;
1058
- x.forEach((M) => {
1059
- const q = new AbortController();
1060
- h.current.set(M.id, q);
1061
- const Q = M.messages.slice(0, -1);
1062
- it(p, M.model, Q, {
1063
- onDelta: (R) => {
1064
- m(M.id, (H) => ({
1065
- ...H,
1066
- streamingContent: H.streamingContent + R,
1067
- messages: H.messages.map(
1068
- (V, ue) => ue === H.messages.length - 1 ? { ...V, content: H.streamingContent + R } : V
1069
- )
1070
- })), g(M.id);
1071
- },
1072
- onDone: (R) => {
1073
- m(M.id, (H) => ({
1074
- ...H,
1075
- isStreaming: !1,
1076
- usage: R ? {
1077
- promptTokens: R.promptTokens,
1078
- completionTokens: R.completionTokens,
1079
- totalTokens: R.totalTokens
1080
- } : null
1081
- })), h.current.delete(M.id);
1082
- },
1083
- onError: (R) => {
1084
- (R.message.includes("401") || R.message.includes("API key")) && (Oe(), S.current = ""), m(M.id, (H) => ({
1085
- ...H,
1086
- isStreaming: !1,
1087
- error: R.message
1088
- })), h.current.delete(M.id);
1089
- },
1090
- signal: q.signal
1091
- }).catch(() => {
1092
- });
1093
- });
1094
- const E = setInterval(() => {
1095
- x.every(
1096
- (q) => !h.current.has(q.id)
1097
- ) && (clearInterval(E), T(!1));
1098
- }, 200);
1099
- setTimeout(() => {
1100
- clearInterval(E), T(!1);
1101
- }, 300 * 1e3);
1102
- }, [I, A, n, B, m, g]), j = F(() => {
1103
- h.current.forEach((s) => s.abort()), h.current.clear(), l((s) => s.map((p) => ({ ...p, isStreaming: !1 }))), T(!1);
1104
- }, []), X = F(() => {
1105
- var p;
1106
- if (n.length >= ie) return;
1107
- const s = (p = c.find((v) => !n.some((x) => x.model === v.modelName))) == null ? void 0 : p.modelName;
1108
- s && l((v) => [...v, ge(s)]);
1109
- }, [n, c]), W = F(() => {
1110
- h.current.forEach((s) => s.abort()), h.current.clear(), l(
1111
- (s) => s.map((p) => ({
1112
- ...p,
1113
- messages: [],
1114
- streamingContent: "",
1115
- isStreaming: !1,
1116
- error: null,
1117
- usage: null
1118
- }))
1119
- ), T(!1);
1120
- }, [A, n]), d = F((s) => {
1121
- const p = h.current.get(s);
1122
- p && p.abort(), h.current.delete(s), l((v) => v.filter((x) => x.id !== s));
1123
- }, []), P = F(
1124
- (s, p) => {
1125
- m(s, (v) => ({ ...v, model: p }));
1126
- },
1127
- [m]
1128
- ), U = c.map((s) => ({
1129
- label: s.modelName,
1130
- value: s.modelName
1131
- }));
1132
- return y ? /* @__PURE__ */ e("div", { style: { textAlign: "center", padding: 60 }, children: /* @__PURE__ */ e(ne, { tip: "加载模型列表..." }) }) : _ ? /* @__PURE__ */ o("div", { className: t.chatContainer, children: [
1133
- /* @__PURE__ */ e("div", { className: t.chatHeader, children: /* @__PURE__ */ e("h3", { className: t.chatTitle, children: "模型对话" }) }),
1134
- /* @__PURE__ */ o("div", { className: t.akEmpty, children: [
1135
- "模型列表加载失败:",
1136
- _
1137
- ] })
1138
- ] }) : /* @__PURE__ */ o("div", { className: t.chatContainer, children: [
1139
- /* @__PURE__ */ o("div", { className: t.chatHeader, children: [
1140
- /* @__PURE__ */ o("h3", { className: t.chatTitle, children: [
1141
- "模型对话",
1142
- n.length > 1 && /* @__PURE__ */ o(Y, { color: "blue", style: { marginLeft: 12, fontSize: 12 }, children: [
1143
- n.length,
1144
- " 个模型对比"
1145
- ] })
1146
- ] }),
1147
- /* @__PURE__ */ e(
1148
- z,
1149
- {
1150
- size: "small",
1151
- icon: /* @__PURE__ */ e(Ge, {}),
1152
- onClick: W,
1153
- disabled: A || n.every((s) => s.messages.length === 0),
1154
- children: "清空重新来"
1155
- }
1156
- )
1157
- ] }),
1158
- /* @__PURE__ */ o("div", { className: t.chatPanels, children: [
1159
- n.map((s) => /* @__PURE__ */ o("div", { className: t.chatPanel, children: [
1160
- /* @__PURE__ */ o("div", { className: t.chatPanelHeader, children: [
1161
- /* @__PURE__ */ e(
1162
- nt,
1163
- {
1164
- size: "small",
1165
- value: s.model,
1166
- onChange: (p) => P(s.id, p),
1167
- options: U,
1168
- style: { minWidth: 140, flex: 1 },
1169
- showSearch: !0,
1170
- optionFilterProp: "label"
1171
- }
1172
- ),
1173
- n.length > 1 && /* @__PURE__ */ e(
1174
- "span",
1175
- {
1176
- className: t.chatPanelClose,
1177
- onClick: () => d(s.id),
1178
- children: /* @__PURE__ */ e(Je, {})
1179
- }
1180
- )
1181
- ] }),
1182
- /* @__PURE__ */ o(
1183
- "div",
1184
- {
1185
- className: t.chatPanelBody,
1186
- ref: (p) => {
1187
- i.current.set(s.id, p);
1188
- },
1189
- children: [
1190
- s.messages.map((p, v) => /* @__PURE__ */ o(
1191
- "div",
1192
- {
1193
- className: p.role === "user" ? t.chatMsgUser : t.chatMsgAI,
1194
- children: [
1195
- p.role === "assistant" ? Ja(p.content).map(
1196
- (x, E) => x.type === "think" ? /* @__PURE__ */ o(
1197
- "details",
1198
- {
1199
- className: t.chatThinkBlock,
1200
- children: [
1201
- /* @__PURE__ */ e("summary", { children: "思考过程" }),
1202
- /* @__PURE__ */ e("pre", { children: x.text })
1203
- ]
1204
- },
1205
- E
1206
- ) : /* @__PURE__ */ e("span", { style: { whiteSpace: "pre-wrap" }, children: x.text }, E)
1207
- ) : /* @__PURE__ */ e("span", { style: { whiteSpace: "pre-wrap" }, children: p.content }),
1208
- s.isStreaming && v === s.messages.length - 1 && p.role === "assistant" && /* @__PURE__ */ e("span", { className: t.chatStreamingCursor })
1209
- ]
1210
- },
1211
- v
1212
- )),
1213
- s.error && /* @__PURE__ */ e("div", { className: t.chatMsgError, children: s.error }),
1214
- s.usage && /* @__PURE__ */ o("div", { className: t.chatUsageBar, children: [
1215
- /* @__PURE__ */ o("span", { children: [
1216
- "输入: ",
1217
- s.usage.promptTokens
1218
- ] }),
1219
- /* @__PURE__ */ o("span", { children: [
1220
- "输出: ",
1221
- s.usage.completionTokens
1222
- ] })
1223
- ] })
1224
- ]
1225
- }
1226
- )
1227
- ] }, s.id)),
1228
- n.length < ie && /* @__PURE__ */ e(ae, { title: "添加面板", children: /* @__PURE__ */ e("div", { className: t.addPanelBtn, onClick: X, children: /* @__PURE__ */ e(Be, {}) }) })
1229
- ] }),
1230
- /* @__PURE__ */ o("div", { className: t.chatInputBar, children: [
1231
- /* @__PURE__ */ e(
1232
- fe.TextArea,
1233
- {
1234
- className: t.chatInput,
1235
- value: I,
1236
- onChange: (s) => O(s.target.value),
1237
- placeholder: "输入消息,所有面板将同时收到并流式输出...",
1238
- autoSize: { minRows: 1, maxRows: 4 },
1239
- onPressEnter: (s) => {
1240
- s.shiftKey || (s.preventDefault(), b());
1241
- },
1242
- disabled: A
1243
- }
1244
- ),
1245
- A ? /* @__PURE__ */ e(z, { danger: !0, onClick: j, children: "停止" }) : /* @__PURE__ */ o(z, { type: "primary", onClick: b, disabled: !I.trim(), children: [
1246
- /* @__PURE__ */ e(We, {}),
1247
- " 发送"
1248
- ] })
1249
- ] })
1250
- ] });
1251
- }
1252
- function ge(a) {
1253
- return {
1254
- id: ++Wa,
1255
- model: a,
1256
- messages: [],
1257
- streamingContent: "",
1258
- isStreaming: !1,
1259
- error: null,
1260
- usage: null
1261
- };
1262
- }
1263
- function Va({ onStartChat: a }) {
1264
- const [n, l] = f([]), [c, u] = f(!0), [y, N] = f(null), [_, k] = f(/* @__PURE__ */ new Set()), I = () => {
1265
- u(!0), N(null), Ne().then((i) => {
1266
- l(i), u(!1);
1267
- }).catch((i) => {
1268
- l([]), N(i instanceof Error ? i.message : "加载失败"), u(!1);
1269
- });
1270
- };
1271
- Z(() => {
1272
- I();
1273
- }, []);
1274
- const O = (i) => {
1275
- k((g) => {
1276
- const m = new Set(g);
1277
- return m.has(i) ? m.delete(i) : m.add(i), m;
1278
- });
1279
- }, A = Array.from(_), T = (i) => {
1280
- a([i]);
1281
- }, S = () => {
1282
- A.length > 0 && a(A);
1283
- }, h = (i) => {
1284
- if (!i) return "default";
1285
- const g = i.toLowerCase();
1286
- 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";
1287
- };
1288
- return c ? /* @__PURE__ */ e("div", { style: { textAlign: "center", padding: 60 }, children: /* @__PURE__ */ e(ne, { tip: "加载模型列表..." }) }) : y ? /* @__PURE__ */ o("div", { children: [
1289
- /* @__PURE__ */ o("div", { className: t.modelMgmtHeader, children: [
1290
- /* @__PURE__ */ e("h3", { className: t.modelMgmtTitle, children: "模型管理" }),
1291
- /* @__PURE__ */ e("p", { className: t.modelMgmtSubtitle, children: "数据库管理的可用模型,可选择单个或多个模型发起对话对比" })
1292
- ] }),
1293
- /* @__PURE__ */ o("div", { className: t.akEmpty, children: [
1294
- "模型列表加载失败:",
1295
- y,
1296
- /* @__PURE__ */ e("div", { style: { marginTop: 16 }, children: /* @__PURE__ */ e(z, { type: "primary", onClick: I, children: "重试" }) })
1297
- ] })
1298
- ] }) : /* @__PURE__ */ o("div", { children: [
1299
- /* @__PURE__ */ o("div", { className: t.modelMgmtHeader, children: [
1300
- /* @__PURE__ */ e("h3", { className: t.modelMgmtTitle, children: "模型管理" }),
1301
- /* @__PURE__ */ e("p", { className: t.modelMgmtSubtitle, children: "数据库管理的可用模型,可选择单个或多个模型发起对话对比" })
1302
- ] }),
1303
- n.length === 0 && /* @__PURE__ */ e("div", { className: t.akEmpty, children: "后端暂无启用模型(z_team_model_config 中 enable=1 的行),请先在数据库或网关配置中启用" }),
1304
- /* @__PURE__ */ e("div", { className: t.modelGrid, children: n.map((i) => {
1305
- const g = _.has(i.modelName);
1306
- return /* @__PURE__ */ o(
1307
- "div",
1308
- {
1309
- className: `${t.modelCard} ${g ? t.modelCardSelected : ""}`,
1310
- onClick: () => O(i.modelName),
1311
- children: [
1312
- /* @__PURE__ */ e(
1313
- ot,
1314
- {
1315
- className: t.modelCheckbox,
1316
- checked: g,
1317
- onChange: (m) => {
1318
- m.stopPropagation(), O(i.modelName);
1319
- }
1320
- }
1321
- ),
1322
- /* @__PURE__ */ o("div", { className: t.modelCardHeader, children: [
1323
- /* @__PURE__ */ e("div", { className: t.modelIconWrap, children: /* @__PURE__ */ e(xe, {}) }),
1324
- /* @__PURE__ */ o("div", { className: t.modelCardInfo, children: [
1325
- /* @__PURE__ */ e("h4", { className: t.modelName, children: i.modelName }),
1326
- /* @__PURE__ */ o("div", { className: t.modelTags, children: [
1327
- i.modelProvider && /* @__PURE__ */ e(
1328
- Y,
1329
- {
1330
- color: h(i.modelProvider),
1331
- style: { fontSize: 11, margin: 0 },
1332
- children: i.modelProvider
1333
- }
1334
- ),
1335
- /* @__PURE__ */ e(Y, { style: { fontSize: 11, margin: 0 }, children: i.apiType })
1336
- ] })
1337
- ] })
1338
- ] }),
1339
- /* @__PURE__ */ e("p", { className: t.modelEndpoint, children: i.endpoint }),
1340
- /* @__PURE__ */ e("div", { className: t.modelCardFooter, children: /* @__PURE__ */ e(
1341
- z,
1342
- {
1343
- type: "link",
1344
- size: "small",
1345
- onClick: (m) => {
1346
- m.stopPropagation(), T(i.modelName);
1347
- },
1348
- children: "发起对话"
1349
- }
1350
- ) })
1351
- ]
1352
- },
1353
- i.modelName
1354
- );
1355
- }) }),
1356
- A.length > 0 && /* @__PURE__ */ o("div", { className: t.modelActionBar, children: [
1357
- /* @__PURE__ */ o("span", { className: t.modelSelectionCount, children: [
1358
- "已选择 ",
1359
- A.length,
1360
- " 个模型"
1361
- ] }),
1362
- /* @__PURE__ */ e(
1363
- z,
1364
- {
1365
- type: "primary",
1366
- onClick: S,
1367
- disabled: A.length === 0,
1368
- children: "批量对比"
1369
- }
1370
- )
1371
- ] })
1372
- ] });
1373
- }
1374
- const Ya = "_container_15pgq_5", Xa = "_page_15pgq_10", Za = "_kpiGrid_15pgq_16", en = "_kpiCard_15pgq_22", tn = "_sectionCard_15pgq_29", an = "_sectionHead_15pgq_36", nn = "_sectionHint_15pgq_42", on = "_akList_15pgq_47", sn = "_errorState_15pgq_54", ln = "_errorTitle_15pgq_66", rn = "_errorDetail_15pgq_72", L = {
1375
- container: Ya,
1376
- page: Xa,
1377
- kpiGrid: Za,
1378
- kpiCard: en,
1379
- sectionCard: tn,
1380
- sectionHead: an,
1381
- sectionHint: nn,
1382
- akList: on,
1383
- errorState: sn,
1384
- errorTitle: ln,
1385
- errorDetail: rn
1386
- }, cn = at(
1387
- () => import("@yuku123/z-agent-component").then((a) => ({ default: a.AgentDashboard }))
1388
- );
1389
- function se(a) {
1390
- return a >= 1e6 ? `${(a / 1e6).toFixed(2)}M` : a >= 1e3 ? `${(a / 1e3).toFixed(1)}K` : String(a ?? 0);
1391
- }
1392
- function dn({ daily: a }) {
1393
- const n = Object.entries(a);
1394
- if (n.length === 0) return /* @__PURE__ */ e("span", { className: t.usageEmpty, children: "暂无数据" });
1395
- const l = Math.max(...n.map(([, c]) => c[1] + c[2]), 1);
1396
- return /* @__PURE__ */ e("div", { className: t.usageBarChart, children: n.map(([c, u]) => {
1397
- const y = u[1] + u[2];
1398
- return /* @__PURE__ */ o("div", { className: t.usageBarCol, children: [
1399
- /* @__PURE__ */ e(ae, { title: `${c}: ${u[0]}次 / ${y} tokens`, children: /* @__PURE__ */ e(
1400
- "div",
1401
- {
1402
- className: t.usageBar,
1403
- style: { height: `${Math.max(y / l * 100, 2)}%` }
1404
- }
1405
- ) }),
1406
- /* @__PURE__ */ e("span", { className: t.usageBarLabel, children: c })
1407
- ] }, c);
1408
- }) });
1409
- }
1410
- function Se({ models: a }) {
1411
- const n = Object.entries(a);
1412
- if (n.length === 0) return /* @__PURE__ */ e("span", { className: t.usageEmpty, children: "暂无数据" });
1413
- const l = Math.max(...n.map(([, c]) => c[0]), 1);
1414
- return /* @__PURE__ */ e("div", { className: t.modelBreakdown, children: n.sort((c, u) => u[1][0] - c[1][0]).map(([c, u]) => /* @__PURE__ */ o("div", { className: t.modelBreakdownRow, children: [
1415
- /* @__PURE__ */ e("span", { className: t.modelBreakdownName, children: c }),
1416
- /* @__PURE__ */ e("div", { className: t.modelBreakdownBar, children: /* @__PURE__ */ e(
1417
- "div",
1418
- {
1419
- className: t.modelBreakdownFill,
1420
- style: { width: `${u[0] / l * 100}%` }
1421
- }
1422
- ) }),
1423
- /* @__PURE__ */ o("span", { className: t.modelBreakdownCount, children: [
1424
- u[0],
1425
- "次 / ",
1426
- se(u[1] + (u[2] || 0)),
1427
- "tokens"
1428
- ] })
1429
- ] }, c)) });
1430
- }
1431
- const mn = [
1432
- {
1433
- title: "时间",
1434
- dataIndex: "createTime",
1435
- key: "createTime",
1436
- width: 160,
1437
- render: (a) => a ? new Date(a).toLocaleString("zh-CN") : "-"
1438
- },
1439
- { title: "模型", dataIndex: "model", key: "model", width: 150 },
1440
- { title: "协议", dataIndex: "protocol", key: "protocol", width: 90, render: (a) => /* @__PURE__ */ e(Y, { children: a }) },
1441
- { title: "输入", dataIndex: "promptTokens", key: "promptTokens", width: 70 },
1442
- { title: "输出", dataIndex: "completionTokens", key: "completionTokens", width: 70 },
1443
- { title: "总Token", dataIndex: "totalTokens", key: "totalTokens", width: 80 },
1444
- { title: "耗时", dataIndex: "latencyMs", key: "latencyMs", width: 70, render: (a) => a ? `${a}ms` : "-" },
1445
- {
1446
- title: "状态",
1447
- dataIndex: "statusCode",
1448
- key: "statusCode",
1449
- width: 60,
1450
- render: (a) => a ? /* @__PURE__ */ e(Y, { color: a < 400 ? "green" : "red", children: a }) : "-"
1451
- }
1452
- ];
1453
- function un(a) {
1454
- var n;
1455
- return ((n = a == null ? void 0 : a.stats) == null ? void 0 : n.recent) ?? [];
1456
- }
1457
- function hn() {
1458
- var g, m, B, b, j, X, W;
1459
- const [a, n] = f(!0), [l, c] = f(null), [u, y] = f([]), [N, _] = f(null), [k, I] = f(null), O = String(Pe((d) => {
1460
- var P;
1461
- return ((P = d.currentUser) == null ? void 0 : P.id) ?? "";
1462
- })), A = Array.from(
1463
- new Set([O, Ee].filter((d) => d !== ""))
1464
- ), T = F(async () => {
1465
- n(!0), c(null);
1466
- try {
1467
- const d = await Promise.allSettled(
1468
- A.map((E) => me(E))
1469
- ), P = [], U = /* @__PURE__ */ new Set();
1470
- let s = 0;
1471
- for (const E of d)
1472
- if (E.status === "fulfilled")
1473
- for (const M of E.value) {
1474
- const q = String(M.id ?? M.akPrefix ?? "");
1475
- U.has(q) || (U.add(q), P.push(M));
1476
- }
1477
- else s += 1;
1478
- if (s === d.length)
1479
- throw new Error("网关不可达:无法获取 AK 列表");
1480
- P.sort((E, M) => (E.id ?? 0) - (M.id ?? 0));
1481
- let p = null, v = null;
1482
- try {
1483
- p = await $e(0);
1484
- } catch (E) {
1485
- v = E instanceof Error ? E.message : "获取用量失败";
1486
- }
1487
- _(p);
1488
- const x = P.map((E) => ({
1489
- key: E,
1490
- stats: p,
1491
- statsError: v
1492
- }));
1493
- y(x);
1494
- } catch (d) {
1495
- c(d instanceof Error ? d.message : "加载失败");
1496
- } finally {
1497
- n(!1);
1498
- }
1499
- }, [A.join(",")]);
1500
- Z(() => {
1501
- T();
1502
- }, [T]);
1503
- const S = Ie(() => {
1504
- const d = N, P = {};
1505
- for (const [U, s] of Object.entries((d == null ? void 0 : d.models) ?? {}))
1506
- P[U] = [s[0] ?? 0, s[1] ?? 0, s[2] ?? 0];
1507
- return {
1508
- requests: (d == null ? void 0 : d.totalRequests) ?? 0,
1509
- tokens: (d == null ? void 0 : d.totalTokens) ?? 0,
1510
- avgLatency: (d == null ? void 0 : d.avgLatencyMs) ?? 0,
1511
- errors: (d == null ? void 0 : d.errorCount) ?? 0,
1512
- models: P
1513
- };
1514
- }, [N]), h = u.reduce((d, P) => d + (P.key.tokenQuota || 0), 0), i = () => a ? /* @__PURE__ */ e("div", { style: { textAlign: "center", padding: 60 }, children: /* @__PURE__ */ e(ne, { tip: "加载监控数据..." }) }) : l ? /* @__PURE__ */ o("div", { className: L.errorState, children: [
1515
- /* @__PURE__ */ e("div", { className: L.errorTitle, children: "模型监控数据加载失败" }),
1516
- /* @__PURE__ */ e("div", { className: L.errorDetail, children: l }),
1517
- /* @__PURE__ */ e(z, { icon: /* @__PURE__ */ e(Ae, {}), onClick: T, type: "primary", children: "重试" })
1518
- ] }) : /* @__PURE__ */ o("div", { className: L.page, children: [
1519
- /* @__PURE__ */ o("div", { className: L.kpiGrid, children: [
1520
- /* @__PURE__ */ e("div", { className: L.kpiCard, children: /* @__PURE__ */ e(K, { title: "总请求(近7天)", value: S.requests }) }),
1521
- /* @__PURE__ */ e("div", { className: L.kpiCard, children: /* @__PURE__ */ e(K, { title: "总 Tokens", value: se(S.tokens) }) }),
1522
- /* @__PURE__ */ e("div", { className: L.kpiCard, children: /* @__PURE__ */ e(K, { title: "平均延迟", value: S.avgLatency, suffix: "ms" }) }),
1523
- /* @__PURE__ */ e("div", { className: L.kpiCard, children: /* @__PURE__ */ e(
1524
- K,
1525
- {
1526
- title: "错误数",
1527
- value: S.errors,
1528
- valueStyle: S.errors > 0 ? { color: "#ff4d4f" } : void 0
1529
- }
1530
- ) })
1531
- ] }),
1532
- /* @__PURE__ */ o("div", { className: L.sectionCard, children: [
1533
- /* @__PURE__ */ o("div", { className: L.sectionHead, children: [
1534
- /* @__PURE__ */ e("span", { className: t.usageSectionTitle, children: "AK 用量" }),
1535
- h > 0 && /* @__PURE__ */ o("span", { className: L.sectionHint, children: [
1536
- "合计额度 ",
1537
- se(h),
1538
- " tokens"
1539
- ] })
1540
- ] }),
1541
- u.length === 0 ? /* @__PURE__ */ e("div", { className: t.akEmpty, children: "网关下暂无 AK" }) : /* @__PURE__ */ e("div", { className: L.akList, children: u.map((d) => {
1542
- const P = d.key.totalTokens ?? 0, U = d.key.tokenQuota || 0, s = U > 0 ? Math.min(P / U * 100, 100) : 0;
1543
- return /* @__PURE__ */ o(
1544
- "div",
1545
- {
1546
- className: t.akCard,
1547
- onClick: () => I(d),
1548
- children: [
1549
- /* @__PURE__ */ o("div", { className: t.akCardRow, children: [
1550
- /* @__PURE__ */ e("span", { className: t.akTitle, children: d.key.description || d.key.userName || `AK #${d.key.id}` }),
1551
- /* @__PURE__ */ e("span", { className: t.akPrefixSmall, children: d.key.akPrefix }),
1552
- /* @__PURE__ */ e(
1553
- "span",
1554
- {
1555
- className: `${t.akStatus} ${d.key.active ? t.akStatusActive : t.akStatusRevoked}`,
1556
- children: d.key.active ? "启用" : "吊销"
1557
- }
1558
- ),
1559
- /* @__PURE__ */ e("span", { className: t.akMetaText, children: d.key.userId === "system-default" ? "系统对话" : d.key.userId })
1560
- ] }),
1561
- /* @__PURE__ */ o("div", { className: t.akCardRow2, children: [
1562
- /* @__PURE__ */ e("div", { className: t.akMiniBar, children: /* @__PURE__ */ e(
1563
- "div",
1564
- {
1565
- className: t.akMiniBarFill,
1566
- style: { width: `${s}%` }
1567
- }
1568
- ) }),
1569
- /* @__PURE__ */ o("span", { className: t.akUsageText, children: [
1570
- se(P),
1571
- U > 0 ? ` / ${se(U)}` : "",
1572
- " tokens"
1573
- ] }),
1574
- /* @__PURE__ */ e("span", { className: t.akMetaText, children: d.statsError ? d.statsError : d.key.lastUsedAt ? `最近使用 ${d.key.lastUsedAt}` : "尚未使用" })
1575
- ] })
1576
- ]
1577
- },
1578
- d.key.id
1579
- );
1580
- }) })
1581
- ] }),
1582
- /* @__PURE__ */ o("div", { className: L.sectionCard, children: [
1583
- /* @__PURE__ */ e("span", { className: t.usageSectionTitle, children: "模型用量分布(网关全局)" }),
1584
- /* @__PURE__ */ e(Se, { models: S.models })
1585
- ] })
1586
- ] });
1587
- return /* @__PURE__ */ o("div", { className: L.container, children: [
1588
- /* @__PURE__ */ o("div", { className: t.modelMgmtHeader, children: [
1589
- /* @__PURE__ */ e("h2", { className: t.modelMgmtTitle, children: "模型监控" }),
1590
- /* @__PURE__ */ e("p", { className: t.modelMgmtSubtitle, children: "大模型网关管控视图 — 网关全局聚合调用量、Tokens 与延迟(近 7 天)" })
1591
- ] }),
1592
- /* @__PURE__ */ e(
1593
- Me,
1594
- {
1595
- defaultActiveKey: "usage",
1596
- items: [
1597
- { key: "usage", label: "模型用量", children: i() },
1598
- {
1599
- key: "sessions",
1600
- label: "会话统计",
1601
- children: /* @__PURE__ */ e(tt, { fallback: /* @__PURE__ */ e(ne, { tip: "加载会话统计..." }), children: /* @__PURE__ */ e(cn, {}) })
1602
- }
1603
- ]
1604
- }
1605
- ),
1606
- /* @__PURE__ */ e(
1607
- be,
1608
- {
1609
- title: k ? `AK 用量 — ${k.key.description || k.key.akPrefix}` : "",
1610
- width: 860,
1611
- open: !!k,
1612
- onClose: () => I(null),
1613
- destroyOnHidden: !0,
1614
- children: k && /* @__PURE__ */ o("div", { className: t.usageDrawerContent, children: [
1615
- /* @__PURE__ */ e("div", { style: { fontSize: 12, color: "#8c8c8c", marginBottom: 12 }, children: "调用监控是网关全局维度(不按 AK 留存),以下统计覆盖全部 AK; 该 AK 自身的累计消耗见「本 AK 累计 Token」。" }),
1616
- /* @__PURE__ */ o("div", { className: t.usageStatsGrid, children: [
1617
- /* @__PURE__ */ e(K, { title: "总请求", value: ((g = k.stats) == null ? void 0 : g.totalRequests) ?? 0 }),
1618
- /* @__PURE__ */ e(K, { title: "总 Tokens", value: ((m = k.stats) == null ? void 0 : m.totalTokens) ?? 0 }),
1619
- /* @__PURE__ */ e(K, { title: "平均延迟", value: ((B = k.stats) == null ? void 0 : B.avgLatencyMs) ?? 0, suffix: "ms" }),
1620
- /* @__PURE__ */ e(K, { title: "输入 Tokens", value: ((b = k.stats) == null ? void 0 : b.totalPromptTokens) ?? 0 }),
1621
- /* @__PURE__ */ e(K, { title: "输出 Tokens", value: ((j = k.stats) == null ? void 0 : j.totalCompletionTokens) ?? 0 }),
1622
- /* @__PURE__ */ e(
1623
- K,
1624
- {
1625
- title: "本 AK 累计 Token",
1626
- value: k.key.totalTokens ?? 0
1627
- }
1628
- ),
1629
- /* @__PURE__ */ e(
1630
- K,
1631
- {
1632
- title: "错误数",
1633
- value: ((X = k.stats) == null ? void 0 : X.errorCount) ?? 0,
1634
- valueStyle: (((W = k.stats) == null ? void 0 : W.errorCount) ?? 0) > 0 ? { color: "#ff4d4f" } : void 0
1635
- }
1636
- )
1637
- ] }),
1638
- /* @__PURE__ */ o("div", { className: t.usageSection, children: [
1639
- /* @__PURE__ */ e("span", { className: t.usageSectionTitle, children: "每日用量(按最近调用明细聚合)" }),
1640
- k.stats ? /* @__PURE__ */ e(dn, { daily: k.stats.daily ?? {} }) : /* @__PURE__ */ e("span", { className: t.usageEmpty, children: k.statsError ?? "暂无数据" })
1641
- ] }),
1642
- /* @__PURE__ */ o("div", { className: t.usageSection, children: [
1643
- /* @__PURE__ */ e("span", { className: t.usageSectionTitle, children: "模型用量分布(按最近调用明细聚合)" }),
1644
- k.stats ? /* @__PURE__ */ e(Se, { models: k.stats.models ?? {} }) : /* @__PURE__ */ e("span", { className: t.usageEmpty, children: k.statsError ?? "暂无数据" })
1645
- ] }),
1646
- /* @__PURE__ */ o("div", { className: t.usageSection, children: [
1647
- /* @__PURE__ */ e("span", { className: t.usageSectionTitle, children: "最近调用" }),
1648
- /* @__PURE__ */ e(
1649
- _e,
1650
- {
1651
- size: "small",
1652
- columns: mn,
1653
- dataSource: un(k),
1654
- rowKey: "id",
1655
- pagination: {
1656
- pageSize: 8,
1657
- showSizeChanger: !0,
1658
- pageSizeOptions: ["8", "20", "50", "100"],
1659
- showTotal: (d) => `共 ${d} 条`
1660
- }
1661
- }
1662
- )
1663
- ] })
1664
- ] })
1665
- }
1666
- )
1667
- ] });
1668
- }
1669
- const pn = [
1670
- { key: "model-management", label: "模型管理", icon: /* @__PURE__ */ e(Qe, {}) },
1671
- { key: "model-chat", label: "模型对话", icon: /* @__PURE__ */ e(Ve, {}) },
1672
- { key: "ak-management", label: "AK 管理", icon: /* @__PURE__ */ e(Ye, {}) },
1673
- { key: "agent-app", label: "Agent 应用", icon: /* @__PURE__ */ e(xe, {}) },
1674
- { key: "mcp-service", label: "MCP 服务", icon: /* @__PURE__ */ e(Xe, {}) },
1675
- { key: "skill-market", label: "技能市场", icon: /* @__PURE__ */ e(Ze, {}) },
1676
- { key: "model-monitor", label: "模型监控", icon: /* @__PURE__ */ e(et, {}) }
1677
- ];
1678
- function Nn() {
1679
- const [a, n] = f("model-management"), [l, c] = f([]), u = (_) => {
1680
- c(_), n("model-chat");
1681
- }, y = Ie(() => pn, []), N = (_, k, I = !1) => /* @__PURE__ */ e(
1682
- "div",
1683
- {
1684
- style: {
1685
- display: a === _ ? I ? "flex" : "block" : "none",
1686
- height: "100%",
1687
- ...I ? { flexDirection: "column" } : {}
1688
- },
1689
- children: k
1690
- }
1691
- );
1692
- return /* @__PURE__ */ o("div", { className: t.container, children: [
1693
- /* @__PURE__ */ e("aside", { className: t.sidebar, children: /* @__PURE__ */ e("nav", { className: t.menuList, children: y.map((_) => /* @__PURE__ */ o(
1694
- "div",
1695
- {
1696
- className: `${t.menuItem} ${a === _.key ? t.menuItemActive : ""}`,
1697
- onClick: () => n(_.key),
1698
- children: [
1699
- /* @__PURE__ */ e("span", { className: t.menuIcon, children: _.icon }),
1700
- /* @__PURE__ */ e("span", { className: t.menuLabel, children: _.label })
1701
- ]
1702
- },
1703
- _.key
1704
- )) }) }),
1705
- /* @__PURE__ */ o("main", { className: t.panelArea, children: [
1706
- N("model-management", /* @__PURE__ */ e(Va, { onStartChat: u })),
1707
- N("model-chat", /* @__PURE__ */ e(Qa, { initialModels: l }), !0),
1708
- N("ak-management", /* @__PURE__ */ e(Ga, {})),
1709
- N("agent-app", /* @__PURE__ */ e(st, {})),
1710
- N("mcp-service", /* @__PURE__ */ e(lt, {})),
1711
- N("skill-market", /* @__PURE__ */ e(rt, {})),
1712
- N("model-monitor", /* @__PURE__ */ e(hn, {}))
1713
- ] })
1714
- ] });
1715
- }
1716
- export {
1717
- Nn as default
1718
- };