@yuku123/z-team-component 0.2.80 → 0.2.81
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.
- package/dist/ChangeLogView-_bRZ55Yi.js +542 -0
- package/dist/ComponentDoc-BWciPDcn.js +3998 -0
- package/dist/InvitationManagementPage-X9t4igh7.js +495 -0
- package/dist/OnboardingPage-D2sVawTW.js +393 -0
- package/dist/ScheduledTasks-CdCX5FlH.js +9407 -0
- package/dist/SystemShell-Bd0UpmAs.js +689 -0
- package/dist/_commonjsHelpers-B52_cu2H.js +26 -0
- package/dist/api-BKjWEmUY.js +20 -0
- package/dist/api-CIhVblfa.js +2155 -0
- package/dist/browser-jb_PFvU3.js +1538 -0
- package/dist/createWorkspaceWsHandler-BWP5S5X3.js +12951 -0
- package/dist/ctc-sso-DtJHC-2M.js +117 -0
- package/dist/echarts-B1OU1xr4.js +16 -0
- package/dist/history-BlrA1eaW.js +41 -0
- package/dist/index-B_LJRFsK.js +339 -0
- package/dist/index-BgIheStI.js +133 -0
- package/dist/index-Bn6u-XqL.js +242 -0
- package/dist/index-BohoJQPr.js +7631 -0
- package/dist/index-BydWNuk5.js +1229 -0
- package/dist/index-C815hPWS.js +430 -0
- package/dist/index-CPXlkVYF.js +118 -0
- package/dist/index-CUVdeb8y.js +638 -0
- package/dist/index-CdsD23Cm.js +914 -0
- package/dist/index-CijskN6t.js +316 -0
- package/dist/index-CkhoaNnF.js +137 -0
- package/dist/index-Cvx6rrxD.js +956 -0
- package/dist/index-Cwr5Slv1.js +480 -0
- package/dist/index-CxFAICql.js +42050 -0
- package/dist/index-D6i_zovv.js +574 -0
- package/dist/index-D8aigFpH.js +9583 -0
- package/dist/index-DK70mOTz.js +143 -0
- package/dist/index-DSoOHdTf.js +178 -0
- package/dist/index-DT80Pwa_.js +5893 -0
- package/dist/index-DWsfQMp8.js +208 -0
- package/dist/index-DZoJnRKu.js +112 -0
- package/dist/index-DhDdFRHC.js +279 -0
- package/dist/index-DimSOV0E.js +1143 -0
- package/dist/index-Dm3wmB0K.js +435 -0
- package/dist/index-DsP2ysav.js +93 -0
- package/dist/index-Dwm0j8qF.js +2936 -0
- package/dist/index-DzS6-D3M.js +1640 -0
- package/dist/index-RVaaSElI.js +2700 -0
- package/dist/index-cdB5K3gx.js +814 -0
- package/dist/index-nU-V276i.js +170 -0
- package/dist/index-uF04Ucsi.js +8 -0
- package/dist/index.js +10 -0
- package/dist/index.module-CAa-2T7m.js +72 -0
- package/dist/index.module-UI0iz8K0.js +42 -0
- package/dist/{menuPermission-D9NGpBZP.js → menuPermission-Uzk46Gto.js} +1 -1
- package/dist/pages.js +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,435 @@
|
|
|
1
|
+
import { jsxs as a, jsx as i, Fragment as B } from "react/jsx-runtime";
|
|
2
|
+
import { useState as d, useRef as F, useCallback as D, useEffect as R } from "react";
|
|
3
|
+
import { u as O } from "./useAppStore-BBr_Fwsz.js";
|
|
4
|
+
/* empty css */
|
|
5
|
+
import { T as P, g as U } from "./api-CIhVblfa.js";
|
|
6
|
+
async function y(o, s) {
|
|
7
|
+
const n = await o.text().catch(() => "");
|
|
8
|
+
let t = {};
|
|
9
|
+
if (n)
|
|
10
|
+
try {
|
|
11
|
+
t = JSON.parse(n);
|
|
12
|
+
} catch {
|
|
13
|
+
if (!o.ok) throw new Error(s);
|
|
14
|
+
return n;
|
|
15
|
+
}
|
|
16
|
+
if (typeof t.success == "boolean") {
|
|
17
|
+
if (t.success)
|
|
18
|
+
return U(t.data !== void 0 ? t.data : !0);
|
|
19
|
+
throw new Error(t.message || s);
|
|
20
|
+
}
|
|
21
|
+
if (!o.ok) throw new Error(s);
|
|
22
|
+
return U(t);
|
|
23
|
+
}
|
|
24
|
+
const m = P;
|
|
25
|
+
async function q(o, s) {
|
|
26
|
+
const n = s ? `?token=${encodeURIComponent(s)}` : "", t = { ...o, extend_params: { skip_init_task: "true" } }, r = await fetch(`${m}/scenario-instances${n}`, {
|
|
27
|
+
method: "POST",
|
|
28
|
+
credentials: "include",
|
|
29
|
+
headers: {
|
|
30
|
+
Accept: "application/json",
|
|
31
|
+
"Content-Type": "application/json",
|
|
32
|
+
"project-env": "local"
|
|
33
|
+
},
|
|
34
|
+
body: JSON.stringify(t)
|
|
35
|
+
});
|
|
36
|
+
return y(r, "Failed to create scenario instance");
|
|
37
|
+
}
|
|
38
|
+
async function K(o) {
|
|
39
|
+
const s = o ? `?token=${encodeURIComponent(o)}` : "", n = await fetch(`${m}/scenario-instances${s}`, {
|
|
40
|
+
credentials: "include",
|
|
41
|
+
headers: {
|
|
42
|
+
Accept: "application/json",
|
|
43
|
+
"project-env": "local"
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
return y(n, "Failed to list scenario instances");
|
|
47
|
+
}
|
|
48
|
+
async function G(o, s, n) {
|
|
49
|
+
const t = n ? `?token=${encodeURIComponent(n)}` : "", r = await fetch(
|
|
50
|
+
`${m}/scenario-instances/${o}/messages${t}`,
|
|
51
|
+
{
|
|
52
|
+
method: "POST",
|
|
53
|
+
credentials: "include",
|
|
54
|
+
headers: {
|
|
55
|
+
Accept: "application/json",
|
|
56
|
+
"Content-Type": "application/json",
|
|
57
|
+
"project-env": "local"
|
|
58
|
+
},
|
|
59
|
+
body: JSON.stringify(s)
|
|
60
|
+
}
|
|
61
|
+
);
|
|
62
|
+
return y(r, "Failed to send message");
|
|
63
|
+
}
|
|
64
|
+
async function _(o, s = 50, n, t) {
|
|
65
|
+
const r = new URLSearchParams({ limit: String(s) });
|
|
66
|
+
t && r.set("token", t);
|
|
67
|
+
const h = await fetch(
|
|
68
|
+
`${m}/scenario-instances/${o}/messages?${r}`,
|
|
69
|
+
{
|
|
70
|
+
credentials: "include",
|
|
71
|
+
headers: {
|
|
72
|
+
Accept: "application/json",
|
|
73
|
+
"project-env": "local"
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
);
|
|
77
|
+
return y(h, "Failed to list messages");
|
|
78
|
+
}
|
|
79
|
+
async function J(o, s) {
|
|
80
|
+
const n = s ? `?token=${encodeURIComponent(s)}` : "", t = await fetch(
|
|
81
|
+
// 后端成员列表在 /team(TeamController),没有 /members
|
|
82
|
+
`${m}/scenario-instances/${o}/team${n}`,
|
|
83
|
+
{
|
|
84
|
+
credentials: "include",
|
|
85
|
+
headers: {
|
|
86
|
+
Accept: "application/json",
|
|
87
|
+
"project-env": "local"
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
);
|
|
91
|
+
return y(t, "Failed to list members");
|
|
92
|
+
}
|
|
93
|
+
const L = "dev_brain_scenario";
|
|
94
|
+
function ee() {
|
|
95
|
+
var M;
|
|
96
|
+
const [o, s] = d([]), [n, t] = d(
|
|
97
|
+
null
|
|
98
|
+
), [r, h] = d([]), [u, z] = d([]), [v, b] = d(""), [W, w] = d(!1), [g, S] = d(!1), [A, T] = d(""), C = F(null), { token: f } = O(), I = D(() => {
|
|
99
|
+
var e;
|
|
100
|
+
(e = C.current) == null || e.scrollIntoView({ behavior: "smooth" });
|
|
101
|
+
}, []);
|
|
102
|
+
R(() => {
|
|
103
|
+
I();
|
|
104
|
+
}, [r, I]), R(() => {
|
|
105
|
+
k();
|
|
106
|
+
}, []);
|
|
107
|
+
const k = async () => {
|
|
108
|
+
try {
|
|
109
|
+
const e = await K(f || void 0);
|
|
110
|
+
s(e || []);
|
|
111
|
+
} catch (e) {
|
|
112
|
+
console.error("Failed to load instances:", e);
|
|
113
|
+
}
|
|
114
|
+
}, N = async () => {
|
|
115
|
+
const e = A.trim();
|
|
116
|
+
if (e) {
|
|
117
|
+
S(!0);
|
|
118
|
+
try {
|
|
119
|
+
const c = await q(
|
|
120
|
+
{ scenario_code: L, name: e },
|
|
121
|
+
f || void 0
|
|
122
|
+
);
|
|
123
|
+
T(""), await k(), $(c);
|
|
124
|
+
} catch (c) {
|
|
125
|
+
alert(c instanceof Error ? c.message : "Create failed");
|
|
126
|
+
} finally {
|
|
127
|
+
S(!1);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
}, $ = async (e) => {
|
|
131
|
+
t(e), w(!0);
|
|
132
|
+
try {
|
|
133
|
+
const [c, p] = await Promise.all([
|
|
134
|
+
_(e.id, 50, void 0, f || void 0),
|
|
135
|
+
J(e.id, f || void 0)
|
|
136
|
+
]);
|
|
137
|
+
h(c || []), z(p || []);
|
|
138
|
+
} catch (c) {
|
|
139
|
+
console.error("Failed to load instance data:", c);
|
|
140
|
+
} finally {
|
|
141
|
+
w(!1);
|
|
142
|
+
}
|
|
143
|
+
}, E = async () => {
|
|
144
|
+
const e = v.trim();
|
|
145
|
+
if (!e || !n) return;
|
|
146
|
+
const c = u.filter((l) => l.memberType === "AGENT");
|
|
147
|
+
let p, j = "TEXT";
|
|
148
|
+
for (const l of c)
|
|
149
|
+
if (e.includes(`@${l.displayName}`)) {
|
|
150
|
+
p = String(l.id), j = "AT_AGENT";
|
|
151
|
+
break;
|
|
152
|
+
}
|
|
153
|
+
b("");
|
|
154
|
+
try {
|
|
155
|
+
await G(
|
|
156
|
+
n.id,
|
|
157
|
+
{
|
|
158
|
+
content: e,
|
|
159
|
+
message_type: j,
|
|
160
|
+
...p ? { at_agent_ref_id: p } : {}
|
|
161
|
+
},
|
|
162
|
+
f || void 0
|
|
163
|
+
);
|
|
164
|
+
const l = await _(
|
|
165
|
+
n.id,
|
|
166
|
+
50,
|
|
167
|
+
void 0,
|
|
168
|
+
f || void 0
|
|
169
|
+
);
|
|
170
|
+
h(l || []);
|
|
171
|
+
} catch (l) {
|
|
172
|
+
alert(l instanceof Error ? l.message : "Send failed");
|
|
173
|
+
}
|
|
174
|
+
}, x = u.filter((e) => e.memberType === "AGENT"), H = u.filter((e) => e.memberType === "HUMAN");
|
|
175
|
+
return /* @__PURE__ */ a("div", { style: { display: "flex", height: "100vh", fontFamily: "sans-serif" }, children: [
|
|
176
|
+
/* @__PURE__ */ a(
|
|
177
|
+
"div",
|
|
178
|
+
{
|
|
179
|
+
style: {
|
|
180
|
+
width: 260,
|
|
181
|
+
borderRight: "1px solid #e8e8e8",
|
|
182
|
+
display: "flex",
|
|
183
|
+
flexDirection: "column",
|
|
184
|
+
background: "#fafafa"
|
|
185
|
+
},
|
|
186
|
+
children: [
|
|
187
|
+
/* @__PURE__ */ a("div", { style: { padding: 16, borderBottom: "1px solid #e8e8e8" }, children: [
|
|
188
|
+
/* @__PURE__ */ i("h3", { style: { margin: "0 0 12px" }, children: "Scenario Instances" }),
|
|
189
|
+
/* @__PURE__ */ a("div", { style: { display: "flex", gap: 8 }, children: [
|
|
190
|
+
/* @__PURE__ */ i(
|
|
191
|
+
"input",
|
|
192
|
+
{
|
|
193
|
+
style: {
|
|
194
|
+
flex: 1,
|
|
195
|
+
padding: "6px 8px",
|
|
196
|
+
border: "1px solid #d9d9d9",
|
|
197
|
+
borderRadius: 4
|
|
198
|
+
},
|
|
199
|
+
placeholder: "Instance name",
|
|
200
|
+
value: A,
|
|
201
|
+
onChange: (e) => T(e.target.value),
|
|
202
|
+
onKeyDown: (e) => e.key === "Enter" && N()
|
|
203
|
+
}
|
|
204
|
+
),
|
|
205
|
+
/* @__PURE__ */ i(
|
|
206
|
+
"button",
|
|
207
|
+
{
|
|
208
|
+
style: {
|
|
209
|
+
padding: "6px 12px",
|
|
210
|
+
background: "#1677ff",
|
|
211
|
+
color: "#fff",
|
|
212
|
+
border: "none",
|
|
213
|
+
borderRadius: 4,
|
|
214
|
+
cursor: g ? "not-allowed" : "pointer"
|
|
215
|
+
},
|
|
216
|
+
disabled: g,
|
|
217
|
+
onClick: N,
|
|
218
|
+
children: g ? "..." : "+"
|
|
219
|
+
}
|
|
220
|
+
)
|
|
221
|
+
] })
|
|
222
|
+
] }),
|
|
223
|
+
/* @__PURE__ */ a("div", { style: { flex: 1, overflow: "auto" }, children: [
|
|
224
|
+
o.map((e) => /* @__PURE__ */ a(
|
|
225
|
+
"div",
|
|
226
|
+
{
|
|
227
|
+
onClick: () => $(e),
|
|
228
|
+
style: {
|
|
229
|
+
padding: "10px 16px",
|
|
230
|
+
cursor: "pointer",
|
|
231
|
+
background: (n == null ? void 0 : n.id) === e.id ? "#e6f4ff" : "transparent",
|
|
232
|
+
borderBottom: "1px solid #f0f0f0"
|
|
233
|
+
},
|
|
234
|
+
children: [
|
|
235
|
+
/* @__PURE__ */ i("div", { style: { fontWeight: 500, fontSize: 13 }, children: e.name }),
|
|
236
|
+
/* @__PURE__ */ a("div", { style: { fontSize: 11, color: "#999" }, children: [
|
|
237
|
+
e.scenarioCode,
|
|
238
|
+
" · ",
|
|
239
|
+
e.status
|
|
240
|
+
] })
|
|
241
|
+
]
|
|
242
|
+
},
|
|
243
|
+
e.id
|
|
244
|
+
)),
|
|
245
|
+
o.length === 0 ? /* @__PURE__ */ i("div", { style: { padding: 16, color: "#999", fontSize: 12 }, children: "No instances yet. Create one above." }) : null
|
|
246
|
+
] })
|
|
247
|
+
]
|
|
248
|
+
}
|
|
249
|
+
),
|
|
250
|
+
/* @__PURE__ */ i("div", { style: { flex: 1, display: "flex", flexDirection: "column" }, children: n ? /* @__PURE__ */ a(B, { children: [
|
|
251
|
+
/* @__PURE__ */ a(
|
|
252
|
+
"div",
|
|
253
|
+
{
|
|
254
|
+
style: {
|
|
255
|
+
padding: "12px 20px",
|
|
256
|
+
borderBottom: "1px solid #e8e8e8",
|
|
257
|
+
display: "flex",
|
|
258
|
+
justifyContent: "space-between",
|
|
259
|
+
alignItems: "center"
|
|
260
|
+
},
|
|
261
|
+
children: [
|
|
262
|
+
/* @__PURE__ */ a("div", { children: [
|
|
263
|
+
/* @__PURE__ */ i("span", { style: { fontWeight: 600, fontSize: 15 }, children: n.name }),
|
|
264
|
+
/* @__PURE__ */ a("span", { style: { marginLeft: 8, fontSize: 12, color: "#999" }, children: [
|
|
265
|
+
"ID: ",
|
|
266
|
+
n.id
|
|
267
|
+
] })
|
|
268
|
+
] }),
|
|
269
|
+
/* @__PURE__ */ a("div", { style: { fontSize: 12, color: "#666" }, children: [
|
|
270
|
+
"Members: ",
|
|
271
|
+
H.length,
|
|
272
|
+
" human · ",
|
|
273
|
+
x.length,
|
|
274
|
+
" ",
|
|
275
|
+
"agent"
|
|
276
|
+
] })
|
|
277
|
+
]
|
|
278
|
+
}
|
|
279
|
+
),
|
|
280
|
+
/* @__PURE__ */ a(
|
|
281
|
+
"div",
|
|
282
|
+
{
|
|
283
|
+
style: {
|
|
284
|
+
flex: 1,
|
|
285
|
+
overflow: "auto",
|
|
286
|
+
padding: "16px 20px",
|
|
287
|
+
background: "#fff"
|
|
288
|
+
},
|
|
289
|
+
children: [
|
|
290
|
+
r.length === 0 ? /* @__PURE__ */ i(
|
|
291
|
+
"div",
|
|
292
|
+
{
|
|
293
|
+
style: { color: "#999", textAlign: "center", marginTop: 80 },
|
|
294
|
+
children: "Send a message to start. Use @agent_name to mention an agent."
|
|
295
|
+
}
|
|
296
|
+
) : null,
|
|
297
|
+
r.map((e) => /* @__PURE__ */ a(
|
|
298
|
+
"div",
|
|
299
|
+
{
|
|
300
|
+
style: {
|
|
301
|
+
marginBottom: 12,
|
|
302
|
+
display: "flex",
|
|
303
|
+
flexDirection: e.senderType === "HUMAN" ? "row-reverse" : "row",
|
|
304
|
+
gap: 8
|
|
305
|
+
},
|
|
306
|
+
children: [
|
|
307
|
+
/* @__PURE__ */ i(
|
|
308
|
+
"div",
|
|
309
|
+
{
|
|
310
|
+
style: {
|
|
311
|
+
width: 32,
|
|
312
|
+
height: 32,
|
|
313
|
+
borderRadius: "50%",
|
|
314
|
+
background: e.senderType === "HUMAN" ? "#1677ff" : "#52c41a",
|
|
315
|
+
color: "#fff",
|
|
316
|
+
display: "flex",
|
|
317
|
+
alignItems: "center",
|
|
318
|
+
justifyContent: "center",
|
|
319
|
+
fontSize: 14,
|
|
320
|
+
flexShrink: 0
|
|
321
|
+
},
|
|
322
|
+
children: e.senderType === "HUMAN" ? "U" : "A"
|
|
323
|
+
}
|
|
324
|
+
),
|
|
325
|
+
/* @__PURE__ */ a("div", { style: { maxWidth: "70%" }, children: [
|
|
326
|
+
/* @__PURE__ */ a(
|
|
327
|
+
"div",
|
|
328
|
+
{
|
|
329
|
+
style: {
|
|
330
|
+
fontSize: 11,
|
|
331
|
+
color: "#999",
|
|
332
|
+
marginBottom: 2,
|
|
333
|
+
textAlign: e.senderType === "HUMAN" ? "right" : "left"
|
|
334
|
+
},
|
|
335
|
+
children: [
|
|
336
|
+
e.senderType === "HUMAN" ? "You" : "Agent",
|
|
337
|
+
" ·",
|
|
338
|
+
" ",
|
|
339
|
+
e.messageType
|
|
340
|
+
]
|
|
341
|
+
}
|
|
342
|
+
),
|
|
343
|
+
/* @__PURE__ */ i(
|
|
344
|
+
"div",
|
|
345
|
+
{
|
|
346
|
+
style: {
|
|
347
|
+
padding: "8px 12px",
|
|
348
|
+
borderRadius: 8,
|
|
349
|
+
background: e.senderType === "HUMAN" ? "#1677ff" : "#f5f5f5",
|
|
350
|
+
color: e.senderType === "HUMAN" ? "#fff" : "#333",
|
|
351
|
+
fontSize: 13,
|
|
352
|
+
whiteSpace: "pre-wrap",
|
|
353
|
+
wordBreak: "break-word"
|
|
354
|
+
},
|
|
355
|
+
children: e.content
|
|
356
|
+
}
|
|
357
|
+
)
|
|
358
|
+
] })
|
|
359
|
+
]
|
|
360
|
+
},
|
|
361
|
+
e.id
|
|
362
|
+
)),
|
|
363
|
+
/* @__PURE__ */ i("div", { ref: C })
|
|
364
|
+
]
|
|
365
|
+
}
|
|
366
|
+
),
|
|
367
|
+
/* @__PURE__ */ a(
|
|
368
|
+
"div",
|
|
369
|
+
{
|
|
370
|
+
style: {
|
|
371
|
+
padding: "12px 20px",
|
|
372
|
+
borderTop: "1px solid #e8e8e8",
|
|
373
|
+
display: "flex",
|
|
374
|
+
gap: 8,
|
|
375
|
+
background: "#fafafa"
|
|
376
|
+
},
|
|
377
|
+
children: [
|
|
378
|
+
/* @__PURE__ */ i(
|
|
379
|
+
"textarea",
|
|
380
|
+
{
|
|
381
|
+
style: {
|
|
382
|
+
flex: 1,
|
|
383
|
+
padding: "8px 12px",
|
|
384
|
+
border: "1px solid #d9d9d9",
|
|
385
|
+
borderRadius: 4,
|
|
386
|
+
resize: "none",
|
|
387
|
+
minHeight: 40,
|
|
388
|
+
maxHeight: 120,
|
|
389
|
+
fontSize: 13
|
|
390
|
+
},
|
|
391
|
+
placeholder: x.length > 0 ? `Type message. @${(M = x[0]) == null ? void 0 : M.displayName} to mention agent.` : "Type message...",
|
|
392
|
+
value: v,
|
|
393
|
+
onChange: (e) => b(e.target.value),
|
|
394
|
+
onKeyDown: (e) => {
|
|
395
|
+
e.key === "Enter" && !e.shiftKey && (e.preventDefault(), E());
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
),
|
|
399
|
+
/* @__PURE__ */ i(
|
|
400
|
+
"button",
|
|
401
|
+
{
|
|
402
|
+
style: {
|
|
403
|
+
padding: "8px 20px",
|
|
404
|
+
background: "#1677ff",
|
|
405
|
+
color: "#fff",
|
|
406
|
+
border: "none",
|
|
407
|
+
borderRadius: 4,
|
|
408
|
+
cursor: "pointer",
|
|
409
|
+
fontSize: 13
|
|
410
|
+
},
|
|
411
|
+
onClick: E,
|
|
412
|
+
children: "Send"
|
|
413
|
+
}
|
|
414
|
+
)
|
|
415
|
+
]
|
|
416
|
+
}
|
|
417
|
+
)
|
|
418
|
+
] }) : /* @__PURE__ */ i(
|
|
419
|
+
"div",
|
|
420
|
+
{
|
|
421
|
+
style: {
|
|
422
|
+
flex: 1,
|
|
423
|
+
display: "flex",
|
|
424
|
+
alignItems: "center",
|
|
425
|
+
justifyContent: "center",
|
|
426
|
+
color: "#999"
|
|
427
|
+
},
|
|
428
|
+
children: "Select or create a scenario instance to start"
|
|
429
|
+
}
|
|
430
|
+
) })
|
|
431
|
+
] });
|
|
432
|
+
}
|
|
433
|
+
export {
|
|
434
|
+
ee as default
|
|
435
|
+
};
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { jsxs as c, jsx as a } from "react/jsx-runtime";
|
|
2
|
+
import v, { useState as d, useEffect as _, useMemo as h } from "react";
|
|
3
|
+
import { useLocation as N } from "react-router-dom";
|
|
4
|
+
import { g as b, s as g } from "./ComponentDoc-BWciPDcn.js";
|
|
5
|
+
import { i as K, P as x } from "./schedule-CETzN_0H.js";
|
|
6
|
+
const E = "_banner_2v7mc_1", S = "_dot_2v7mc_18", f = "_text_2v7mc_26", A = "_retry_2v7mc_31", F = "_dismiss_2v7mc_44", P = "_details_2v7mc_57", k = "_method_2v7mc_85", C = "_status_2v7mc_86", D = "_statusNet_2v7mc_87", $ = "_url_2v7mc_88", e = {
|
|
7
|
+
banner: E,
|
|
8
|
+
dot: S,
|
|
9
|
+
text: f,
|
|
10
|
+
retry: A,
|
|
11
|
+
dismiss: F,
|
|
12
|
+
details: P,
|
|
13
|
+
method: k,
|
|
14
|
+
status: C,
|
|
15
|
+
statusNet: D,
|
|
16
|
+
url: $
|
|
17
|
+
}, B = () => {
|
|
18
|
+
const { pathname: i } = N(), [s, n] = d(b()), [l, m] = d(0);
|
|
19
|
+
_(() => g(n), []), _(() => {
|
|
20
|
+
m(0);
|
|
21
|
+
}, [i]);
|
|
22
|
+
const u = h(
|
|
23
|
+
() => s.filter((t) => t.route === i && t.at >= l),
|
|
24
|
+
[s, i, l]
|
|
25
|
+
), p = h(() => {
|
|
26
|
+
const t = /* @__PURE__ */ new Map();
|
|
27
|
+
return u.forEach((r) => {
|
|
28
|
+
const o = t.get(r.status) ?? { status: r.status, count: 0, urls: [] };
|
|
29
|
+
o.count += 1, o.urls.includes(r.url) || o.urls.push(r.url), t.set(r.status, o);
|
|
30
|
+
}), [...t.values()].sort((r, o) => r.status - o.status);
|
|
31
|
+
}, [u]);
|
|
32
|
+
if (u.length === 0) return null;
|
|
33
|
+
const y = p.map((t) => `${t.status === 0 ? "网络错误" : t.status} ×${t.count}`).join(" · ");
|
|
34
|
+
return /* @__PURE__ */ c("div", { className: e.banner, role: "alert", "data-testid": "page-api-error-notice", children: [
|
|
35
|
+
/* @__PURE__ */ a("span", { className: e.dot }),
|
|
36
|
+
/* @__PURE__ */ c("span", { className: e.text, children: [
|
|
37
|
+
"本页有 ",
|
|
38
|
+
u.length,
|
|
39
|
+
" 个接口失败(",
|
|
40
|
+
y,
|
|
41
|
+
"),页面可能不完整。"
|
|
42
|
+
] }),
|
|
43
|
+
/* @__PURE__ */ a("button", { type: "button", className: e.retry, onClick: () => location.reload(), children: "重试" }),
|
|
44
|
+
/* @__PURE__ */ c("details", { className: e.details, children: [
|
|
45
|
+
/* @__PURE__ */ a("summary", { children: "失败明细" }),
|
|
46
|
+
/* @__PURE__ */ a("ul", { children: u.map((t, r) => /* @__PURE__ */ c("li", { children: [
|
|
47
|
+
/* @__PURE__ */ a("span", { className: e.method, children: t.method }),
|
|
48
|
+
/* @__PURE__ */ a("span", { className: t.status === 0 ? e.statusNet : e.status, children: t.status === 0 ? "网络" : t.status }),
|
|
49
|
+
/* @__PURE__ */ a("span", { className: e.url, children: t.url })
|
|
50
|
+
] }, `${t.at}-${r}`)) })
|
|
51
|
+
] }),
|
|
52
|
+
/* @__PURE__ */ a(
|
|
53
|
+
"button",
|
|
54
|
+
{
|
|
55
|
+
type: "button",
|
|
56
|
+
className: e.dismiss,
|
|
57
|
+
title: "本页浏览期间不再显示",
|
|
58
|
+
onClick: () => m(Date.now() + 1),
|
|
59
|
+
children: "忽略"
|
|
60
|
+
}
|
|
61
|
+
)
|
|
62
|
+
] });
|
|
63
|
+
};
|
|
64
|
+
class T extends v.Component {
|
|
65
|
+
constructor() {
|
|
66
|
+
super(...arguments), this.state = { error: null, resetKey: this.props.resetKey };
|
|
67
|
+
}
|
|
68
|
+
static getDerivedStateFromError(s) {
|
|
69
|
+
return { error: s };
|
|
70
|
+
}
|
|
71
|
+
static getDerivedStateFromProps(s, n) {
|
|
72
|
+
return n.error && s.resetKey !== n.resetKey ? { error: null, resetKey: s.resetKey } : s.resetKey !== n.resetKey ? { resetKey: s.resetKey } : null;
|
|
73
|
+
}
|
|
74
|
+
render() {
|
|
75
|
+
const { error: s } = this.state;
|
|
76
|
+
if (s) {
|
|
77
|
+
const n = K(s);
|
|
78
|
+
return /* @__PURE__ */ a(
|
|
79
|
+
x,
|
|
80
|
+
{
|
|
81
|
+
error: s,
|
|
82
|
+
retry: () => this.setState({ error: null }),
|
|
83
|
+
retryText: n ? "重试加载" : "重试渲染"
|
|
84
|
+
}
|
|
85
|
+
);
|
|
86
|
+
}
|
|
87
|
+
return this.props.children;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
export {
|
|
91
|
+
B as P,
|
|
92
|
+
T as R
|
|
93
|
+
};
|