@yuku123/z-team-component 0.2.101 → 0.2.103

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 (58) hide show
  1. package/package.json +1 -1
  2. package/dist/ChangeLogView-C5CT7IdD.js +0 -542
  3. package/dist/ComponentDoc-_6l967G1.js +0 -8035
  4. package/dist/InvitationManagementPage-aVNAFNfh.js +0 -495
  5. package/dist/OnboardingPage-eguTk0Fr.js +0 -393
  6. package/dist/ScheduledTasks-fQkpSLxv.js +0 -12127
  7. package/dist/SystemShell-CcjFqtAl.js +0 -688
  8. package/dist/_commonjsHelpers-B52_cu2H.js +0 -26
  9. package/dist/admin-logs-3ZODCEOd.js +0 -198
  10. package/dist/api-Cxg9p973.js +0 -20
  11. package/dist/browser-jb_PFvU3.js +0 -1538
  12. package/dist/createWorkspaceWsHandler-DGSUlhxe.js +0 -13142
  13. package/dist/ctc-sso-DtJHC-2M.js +0 -117
  14. package/dist/echarts-B1OU1xr4.js +0 -16
  15. package/dist/history-BlrA1eaW.js +0 -41
  16. package/dist/index-9pP8ZkkO.js +0 -913
  17. package/dist/index-BK7D0ag2.js +0 -142
  18. package/dist/index-BQvWAcy_.js +0 -814
  19. package/dist/index-BZCQSW-G.js +0 -1222
  20. package/dist/index-B_LJRFsK.js +0 -339
  21. package/dist/index-BdAkIs1M.js +0 -42049
  22. package/dist/index-Bn-5kryj.js +0 -2217
  23. package/dist/index-BohoJQPr.js +0 -7631
  24. package/dist/index-Bxeg6bYj.js +0 -315
  25. package/dist/index-C6Y3uiLo.js +0 -316
  26. package/dist/index-C815hPWS.js +0 -430
  27. package/dist/index-CJRhmIZt.js +0 -132
  28. package/dist/index-CRuyEQHz.js +0 -242
  29. package/dist/index-CUgTpa_y.js +0 -10132
  30. package/dist/index-Cl8xxWPn.js +0 -93
  31. package/dist/index-CuXeGlOh.js +0 -5892
  32. package/dist/index-Cxecr-Dh.js +0 -8
  33. package/dist/index-CyXYKCpO.js +0 -178
  34. package/dist/index-D1xldtWw.js +0 -479
  35. package/dist/index-DH85SI_i.js +0 -574
  36. package/dist/index-DJ52X07p.js +0 -1640
  37. package/dist/index-DLmDAaE2.js +0 -169
  38. package/dist/index-DTRobC4q.js +0 -956
  39. package/dist/index-DWsfQMp8.js +0 -208
  40. package/dist/index-DdeHvY0_.js +0 -112
  41. package/dist/index-DhDdFRHC.js +0 -279
  42. package/dist/index-DjokMbUK.js +0 -434
  43. package/dist/index-DyKLLFs9.js +0 -2699
  44. package/dist/index-J7unHx4K.js +0 -118
  45. package/dist/index-t0s2Lph_.js +0 -189
  46. package/dist/index.js +0 -10
  47. package/dist/index.module-CAa-2T7m.js +0 -72
  48. package/dist/index.module-UI0iz8K0.js +0 -42
  49. package/dist/instance-120oH-2S.js +0 -216
  50. package/dist/menuPermission-qZTza4Oq.js +0 -60
  51. package/dist/mobile-client-O3yr9h6t.js +0 -24
  52. package/dist/pages.js +0 -21
  53. package/dist/send-default-agent-team-message-DrfWKH9j.js +0 -35
  54. package/dist/spark-md5-Dld54a-T.js +0 -178
  55. package/dist/sso-user-DXwW5eLV.js +0 -43
  56. package/dist/training-D3P1cMiu.js +0 -450
  57. package/dist/webide-D_OZQdjo.js +0 -5233
  58. package/dist/z-team-component.css +0 -1
@@ -1,315 +0,0 @@
1
- import { jsx as t, jsxs as l } from "react/jsx-runtime";
2
- import { f as ie, r as z } from "./ctc-sso-DtJHC-2M.js";
3
- import { r as ne, h as X, s as oe } from "./sso-user-DXwW5eLV.js";
4
- import { CheckCircleFilled as le, QuestionCircleOutlined as ce, CloseOutlined as me } from "@ant-design/icons";
5
- import { message as k, Result as de, Button as D, Spin as G, Input as ue, Image as fe } from "antd";
6
- import pe from "query-string";
7
- import { useState as f, useRef as Y, useMemo as K, useCallback as w, useEffect as V } from "react";
8
- import { useLocation as ge } from "react-router-dom";
9
- import { h as W } from "./history-BlrA1eaW.js";
10
- import { d as c, o as he, h as be, j as _e } from "./ComponentDoc-_6l967G1.js";
11
- /* empty css */
12
- import { b as ye } from "./mobile-client-O3yr9h6t.js";
13
- import { a as ve, s as we } from "./send-default-agent-team-message-DrfWKH9j.js";
14
- const Ne = 5e3, E = 9, Ce = 10 * 1024 * 1024, Se = /^image\//i, Ie = /\.(png|jpe?g|gif|bmp|webp)$/i;
15
- function Pe(a) {
16
- return a.type && Se.test(a.type) ? !0 : Ie.test(a.name || "");
17
- }
18
- function ke(a) {
19
- var o;
20
- if (!((o = a == null ? void 0 : a.items) != null && o.length))
21
- return [];
22
- const m = [];
23
- for (let p = 0; p < a.items.length; p += 1) {
24
- const d = a.items[p];
25
- if (d.kind === "file" && d.type.startsWith("image/")) {
26
- const N = d.getAsFile();
27
- N && m.push(N);
28
- }
29
- }
30
- return m;
31
- }
32
- function Ee(a) {
33
- return {
34
- id: `${Date.now()}-${Math.random().toString(36).slice(2, 9)}`,
35
- file: a,
36
- previewUrl: URL.createObjectURL(a)
37
- };
38
- }
39
- function Q(a) {
40
- URL.revokeObjectURL(a.previewUrl);
41
- }
42
- function Ue(a) {
43
- return a.map((m) => m.file);
44
- }
45
- const J = 30;
46
- function Xe() {
47
- const a = ge(), m = pe.parse(a.search), o = String(
48
- m.scenarioCode ?? m.scenario_code ?? ""
49
- ).trim(), p = c((e) => e.expandProject), d = c((e) => e.updateCurrentUser), [N, H] = f(!1), [_, Z] = f(""), [y, U] = f([]), [M, R] = f("form"), [j, T] = f(""), [A, g] = f("正在登录…"), [B, F] = f([]), P = Y(!1), x = Y(y);
50
- x.current = y;
51
- const C = K(() => o ? "" : "缺少参数 scenarioCode", [o]), S = w((e, r) => {
52
- F((n) => [...n, e]), g(r);
53
- }, []), ee = (e) => new Promise((r) => {
54
- window.setTimeout(r, e);
55
- });
56
- V(() => {
57
- if (C)
58
- return;
59
- let e = !1, r = 0;
60
- const n = 100;
61
- let i = !1, s = 0;
62
- const v = 3;
63
- return (() => {
64
- if (e)
65
- return;
66
- const u = async () => {
67
- if (e)
68
- return;
69
- let h = ne();
70
- if ((!h || !X(h)) && !i) {
71
- i = !0;
72
- try {
73
- const b = await ie();
74
- b.kind === "authenticated" ? h = b.user : b.kind === "unauthenticated" && (s += 1);
75
- } catch {
76
- } finally {
77
- i = !1;
78
- }
79
- }
80
- if (h && X(h)) {
81
- d(oe(h));
82
- const b = c.getState().token;
83
- try {
84
- const se = await _e(b);
85
- e || d(se);
86
- } catch {
87
- !e && b && (localStorage.removeItem("z_team_token"), c.setState({ token: "" }));
88
- } finally {
89
- e || (H(!0), g(""));
90
- }
91
- return;
92
- }
93
- if (s >= v) {
94
- z();
95
- return;
96
- }
97
- if (r += 1, r >= n) {
98
- z();
99
- return;
100
- }
101
- window.setTimeout(() => void u(), 150);
102
- };
103
- u();
104
- })(), () => {
105
- e = !0;
106
- };
107
- }, [C, d]);
108
- const te = w(
109
- async (e, r) => {
110
- if (P.current)
111
- return;
112
- P.current = !0, R("loading"), F([]), g("正在按场景创建工程…");
113
- const n = e.slice(0, J), i = c.getState().token;
114
- try {
115
- let s = [];
116
- r.length > 0 && (g("正在上传图片…"), s = await he(r));
117
- const v = ve(e, s), I = await be(
118
- {
119
- name: n,
120
- description: v,
121
- workspace_path: n,
122
- scenario_code: o
123
- },
124
- i
125
- );
126
- S("工程已创建", "正在打开协作区…"), g("正在同步工程列表…"), await p(I);
127
- const u = c.getState();
128
- u.currentProject && await u.refreshProjectPanels(
129
- String(u.currentProject.id),
130
- u.projectSwitchSeq,
131
- !1
132
- ), S("协作区已就绪", "正在发送协作消息…"), await we(
133
- I.id,
134
- e,
135
- i,
136
- c.getState().members,
137
- s
138
- ), await c.getState().loadMessages(), S("协作消息已发送", "即将进入工作台…"), g("即将进入工作台…"), await ee(2e3), W.replace(
139
- ye({
140
- projectId: I.id,
141
- search: a.search
142
- })
143
- );
144
- } catch (s) {
145
- P.current = !1, R("form");
146
- const v = s instanceof Error ? s.message : String(s);
147
- T(v || "创建工程失败");
148
- }
149
- },
150
- [S, p, a.search, o]
151
- ), L = w((e) => {
152
- e.length && U((r) => {
153
- const n = E - r.length;
154
- if (n <= 0)
155
- return k.warning(`最多粘贴 ${E} 张图片`), r;
156
- const i = [...r];
157
- for (const s of e.slice(0, n)) {
158
- if (!Pe(s)) {
159
- k.warning("仅支持粘贴图片");
160
- continue;
161
- }
162
- if (s.size > Ce) {
163
- k.warning("单张图片不能超过 10MB");
164
- continue;
165
- }
166
- i.push(Ee(s));
167
- }
168
- return i;
169
- });
170
- }, []), re = w((e) => {
171
- U((r) => {
172
- const n = r.find((i) => i.id === e);
173
- return n && Q(n), r.filter((i) => i.id !== e);
174
- });
175
- }, []);
176
- V(() => () => {
177
- x.current.forEach(Q);
178
- }, []);
179
- const ae = w(
180
- (e) => {
181
- const r = ke(e.clipboardData);
182
- r.length > 0 && (e.preventDefault(), L(r));
183
- },
184
- [L]
185
- ), $ = () => {
186
- const e = _.trim();
187
- e && (T(""), te(e, Ue(y)));
188
- }, O = K(() => {
189
- const e = _.trim().slice(0, J);
190
- return `场景 ${o}${e ? ` · ${e}` : ""}`;
191
- }, [_, o]);
192
- if (C || j && M === "form")
193
- return /* @__PURE__ */ t("div", { className: "build-by-form-page", children: /* @__PURE__ */ t(
194
- de,
195
- {
196
- status: "error",
197
- title: "无法继续",
198
- subTitle: C || j,
199
- extra: /* @__PURE__ */ t(
200
- D,
201
- {
202
- type: "primary",
203
- onClick: () => W.replace("/workspace"),
204
- children: "返回工作台"
205
- }
206
- )
207
- }
208
- ) });
209
- if (!N)
210
- return /* @__PURE__ */ t("div", { className: "build-by-form-page", children: /* @__PURE__ */ t("div", { className: "build-by-form-page__shell", children: /* @__PURE__ */ t("div", { className: "build-by-form-page__panel", children: /* @__PURE__ */ l("div", { className: "build-by-form-page__loading", children: [
211
- /* @__PURE__ */ t(G, { size: "large" }),
212
- /* @__PURE__ */ t("p", { className: "build-by-form-page__step", children: A || "正在登录…" })
213
- ] }) }) }) });
214
- if (M === "loading")
215
- return /* @__PURE__ */ t("div", { className: "build-by-form-page", children: /* @__PURE__ */ t("div", { className: "build-by-form-page__shell", children: /* @__PURE__ */ t("div", { className: "build-by-form-page__panel", children: /* @__PURE__ */ l("div", { className: "build-by-form-page__loading", children: [
216
- /* @__PURE__ */ t(G, { size: "large" }),
217
- /* @__PURE__ */ t("p", { className: "build-by-form-page__step", children: A }),
218
- O ? /* @__PURE__ */ t("p", { className: "build-by-form-page__meta", children: O }) : null,
219
- B.length > 0 ? /* @__PURE__ */ t("ul", { className: "build-by-form-page__done-list", children: B.map((e, r) => /* @__PURE__ */ l(
220
- "li",
221
- {
222
- className: "build-by-form-page__done-item",
223
- children: [
224
- /* @__PURE__ */ t(le, { className: "build-by-form-page__done-icon" }),
225
- /* @__PURE__ */ t("span", { children: e })
226
- ]
227
- },
228
- `${r}-${e}`
229
- )) }) : null
230
- ] }) }) }) });
231
- const q = !!_.trim();
232
- return /* @__PURE__ */ t("div", { className: "build-by-form-page", children: /* @__PURE__ */ t("div", { className: "build-by-form-page__shell", children: /* @__PURE__ */ l("div", { className: "build-by-form-page__panel", children: [
233
- /* @__PURE__ */ l("div", { className: "build-by-form-page__header", children: [
234
- /* @__PURE__ */ t("div", { className: "build-by-form-page__icon", "aria-hidden": !0, children: /* @__PURE__ */ t(ce, {}) }),
235
- /* @__PURE__ */ l("div", { children: [
236
- /* @__PURE__ */ t("h1", { className: "build-by-form-page__title", children: "描述你的问题" }),
237
- /* @__PURE__ */ t("p", { className: "build-by-form-page__subtitle", children: "提交后将创建协作空间,并把问题发送给智能体" })
238
- ] })
239
- ] }),
240
- /* @__PURE__ */ l("div", { className: "build-by-form-page__field", onPaste: ae, children: [
241
- /* @__PURE__ */ t(
242
- "label",
243
- {
244
- className: "build-by-form-page__label",
245
- htmlFor: "build-by-form-question",
246
- children: "请描述问题"
247
- }
248
- ),
249
- /* @__PURE__ */ t(
250
- ue.TextArea,
251
- {
252
- id: "build-by-form-question",
253
- className: "build-by-form-page__textarea",
254
- value: _,
255
- onChange: (e) => Z(e.target.value),
256
- onKeyDown: (e) => {
257
- (e.metaKey || e.ctrlKey) && e.key === "Enter" && q && (e.preventDefault(), $());
258
- },
259
- placeholder: "请尽量描述清楚现象、期望结果或相关背景…(可在输入框内 Ctrl+V 粘贴图片)",
260
- autoSize: { minRows: 6, maxRows: 14 },
261
- maxLength: Ne,
262
- showCount: !0,
263
- autoFocus: !0
264
- }
265
- ),
266
- y.length > 0 ? /* @__PURE__ */ t("ul", { className: "build-by-form-page__preview-list", children: y.map((e) => /* @__PURE__ */ l(
267
- "li",
268
- {
269
- className: "build-by-form-page__preview-item",
270
- children: [
271
- /* @__PURE__ */ t(
272
- fe,
273
- {
274
- src: e.previewUrl,
275
- alt: "粘贴的图片",
276
- className: "build-by-form-page__preview-img",
277
- preview: { mask: "预览" }
278
- }
279
- ),
280
- /* @__PURE__ */ t(
281
- "button",
282
- {
283
- type: "button",
284
- className: "build-by-form-page__preview-remove",
285
- "aria-label": "移除图片",
286
- onClick: () => re(e.id),
287
- children: /* @__PURE__ */ t(me, {})
288
- }
289
- )
290
- ]
291
- },
292
- e.id
293
- )) }) : /* @__PURE__ */ l("p", { className: "build-by-form-page__paste-hint", children: [
294
- "支持 Ctrl+V / ⌘+V 粘贴图片,最多 ",
295
- E,
296
- " 张"
297
- ] })
298
- ] }),
299
- /* @__PURE__ */ t(
300
- D,
301
- {
302
- type: "primary",
303
- block: !0,
304
- size: "large",
305
- className: "build-by-form-page__submit",
306
- disabled: !q,
307
- onClick: $,
308
- children: "确认并开始"
309
- }
310
- )
311
- ] }) }) });
312
- }
313
- export {
314
- Xe as default
315
- };
@@ -1,316 +0,0 @@
1
- import { a as h, f as _, B as N, v as A, t as g } from "./ComponentDoc-_6l967G1.js";
2
- import { jsx as p, jsxs as I } from "react/jsx-runtime";
3
- import { useMemo as S, useState as C, useEffect as G, Component as L } from "react";
4
- function $(t) {
5
- if (t == null) return !0;
6
- const e = String(t).trim();
7
- return e === "" || e === "0";
8
- }
9
- function b(t) {
10
- const e = (i) => {
11
- if (typeof i != "string" || !i.trim()) return [];
12
- try {
13
- const s = JSON.parse(i);
14
- return Array.isArray(s) ? s.filter((d) => typeof d == "string") : [];
15
- } catch {
16
- return [];
17
- }
18
- }, n = (i) => {
19
- if (typeof i != "string" || !i.trim()) return [];
20
- try {
21
- const s = JSON.parse(i);
22
- return Array.isArray(s) ? s.filter(
23
- (d) => !!d && typeof d == "object" && typeof d.type == "string"
24
- ) : [];
25
- } catch {
26
- return [];
27
- }
28
- }, r = () => {
29
- const i = t.assigneeUserIds;
30
- let s = null;
31
- if (Array.isArray(i))
32
- s = i;
33
- else if (typeof i == "string" && i.trim())
34
- try {
35
- const o = JSON.parse(i);
36
- s = Array.isArray(o) ? o : null;
37
- } catch {
38
- s = i.split(",");
39
- }
40
- if (s) {
41
- const o = s.map((u) => String(u ?? "").trim()).filter(Boolean);
42
- if (o.length > 0) return Array.from(new Set(o));
43
- }
44
- const d = t.assigneeUserId == null ? "" : String(t.assigneeUserId);
45
- return d.trim() ? [d.trim()] : [];
46
- }, c = (i) => {
47
- const s = t.assignees, d = Array.isArray(s) ? s.map((o) => {
48
- const u = o ?? {}, m = String(u.userId ?? "").trim();
49
- return m ? { userId: m, name: String(u.name ?? "").trim() || m } : null;
50
- }).filter((o) => o != null) : [];
51
- return d.length > 0 ? d : i.map((o) => ({ userId: o, name: o }));
52
- }, l = r();
53
- return {
54
- id: g(t.id),
55
- projectId: t.projectId == null ? null : g(t.projectId),
56
- userId: String(t.userId ?? ""),
57
- title: String(t.title ?? ""),
58
- detail: t.detail == null ? null : String(t.detail),
59
- status: t.status ?? "TODO",
60
- priority: t.priority ?? "MEDIUM",
61
- dueDate: t.dueDate == null ? null : String(t.dueDate).slice(0, 10),
62
- assigneeUserId: l[0] ?? null,
63
- assigneeUserIds: l,
64
- assignees: c(l),
65
- projectTitle: t.projectTitle == null || !String(t.projectTitle).trim() ? null : String(t.projectTitle),
66
- tags: e(t.tags),
67
- links: n(t.links),
68
- parentId: $(t.parentId) ? "" : g(t.parentId),
69
- sortOrder: t.sortOrder == null ? 0 : Number(t.sortOrder),
70
- completedAt: t.completedAt == null ? null : String(t.completedAt),
71
- completedBy: t.completedBy == null ? null : String(t.completedBy),
72
- createByName: t.createByName == null ? null : String(t.createByName),
73
- updateTime: t.updateTime == null ? null : String(t.updateTime),
74
- agentId: t.agentId == null ? null : g(t.agentId),
75
- agentSessionId: t.agentSessionId == null ? null : g(t.agentSessionId)
76
- };
77
- }
78
- function B(t) {
79
- const e = t ?? {};
80
- return {
81
- id: g(e.id),
82
- userId: String(e.userId ?? ""),
83
- title: String(e.title ?? ""),
84
- icon: e.icon == null ? null : String(e.icon),
85
- description: e.description == null ? null : String(e.description),
86
- visibility: e.visibility === "shared" ? "shared" : "private",
87
- sortOrder: e.sortOrder == null ? 0 : Number(e.sortOrder),
88
- extraInfo: e.extraInfo == null ? null : String(e.extraInfo),
89
- createByName: e.createByName == null ? null : String(e.createByName)
90
- };
91
- }
92
- function O(t) {
93
- const e = t ?? {}, n = Array.isArray(e.memberDetails) ? e.memberDetails : [];
94
- return {
95
- ...B(e),
96
- openCount: e.openCount == null ? 0 : Number(e.openCount),
97
- memberDetails: n.map((r) => {
98
- const c = r ?? {}, l = String(c.userId ?? "").trim();
99
- return l ? { userId: l, userName: String(c.userName ?? "").trim() || l } : null;
100
- }).filter((r) => r != null)
101
- };
102
- }
103
- async function et(t = "") {
104
- const e = t ? `?token=${encodeURIComponent(t)}` : "", n = await h(`${N}/todo/projects${e}`, _), r = await A(n, "获取待办项目失败");
105
- return {
106
- owned: ((r == null ? void 0 : r.owned) ?? []).map(O),
107
- joined: ((r == null ? void 0 : r.joined) ?? []).map(O)
108
- };
109
- }
110
- async function nt(t = {}, e = "") {
111
- const n = new URLSearchParams();
112
- e && n.set("token", e), t.view && n.set("view", t.view), t.projectId != null && n.set("projectId", String(t.projectId)), t.status && n.set("status", t.status), t.keyword && n.set("keyword", t.keyword);
113
- const r = n.toString() ? `?${n.toString()}` : "", c = await h(`${N}/todo/items${r}`, _);
114
- return (await A(
115
- c,
116
- "获取事项失败"
117
- ) ?? []).map(b);
118
- }
119
- async function rt(t, e = "") {
120
- const n = e ? `?token=${encodeURIComponent(e)}` : "", r = await h(`${N}/todo/items${n}`, {
121
- ..._,
122
- method: "POST",
123
- headers: { "Content-Type": "application/json" },
124
- body: JSON.stringify(t)
125
- }), c = await A(r, "新建事项失败");
126
- return b(c);
127
- }
128
- const D = {
129
- RUNTIME_MONITOR_VIEW: ["RUNTIME_MONITOR_MANAGE"],
130
- EVALUATION_VIEW: ["EVALUATION_MANAGE"],
131
- COLLABORATION_VIEW: [
132
- "AGENT_MANAGE",
133
- "SKILL_MANAGE",
134
- "SCENARIO_MANAGE",
135
- "PROFILE_MANAGE",
136
- "TAG_MANAGE",
137
- "TOOL_MANAGE"
138
- ],
139
- EVOLUTION_VIEW: ["EVOLUTION_MANAGE"],
140
- OPS_CONFIG_VIEW: [
141
- "OPS_CONFIG_MANAGE",
142
- "ONCALL_MANAGE",
143
- "ANNOUNCEMENT_MANAGE",
144
- "OPS_REPORT_MANAGE"
145
- ],
146
- KNOWLEDGE_VIEW: ["KNOWLEDGE_MANAGE"],
147
- WEBIDE_VIEW: ["WEBIDE_MANAGE"]
148
- };
149
- function it(t, e) {
150
- var r;
151
- if (!t) return !1;
152
- if (t.is_global_admin || (r = t.permissions) != null && r.includes(e)) return !0;
153
- const n = D[e];
154
- return !!(n != null && n.some((c) => {
155
- var l;
156
- return (l = t.permissions) == null ? void 0 : l.includes(c);
157
- }));
158
- }
159
- const P = "_wrap_2gcw5_1", U = "_card_2gcw5_9", R = "_badge_2gcw5_19", V = "_title_2gcw5_41", W = "_desc_2gcw5_48", v = "_actions_2gcw5_55", x = "_primary_2gcw5_63", z = "_secondary_2gcw5_75", F = "_details_2gcw5_90", J = "_pre_2gcw5_102", w = "_copy_2gcw5_117", K = "_compact_2gcw5_127", a = {
160
- wrap: P,
161
- card: U,
162
- badge: R,
163
- title: V,
164
- desc: W,
165
- actions: v,
166
- primary: x,
167
- secondary: z,
168
- details: F,
169
- pre: J,
170
- copy: w,
171
- compact: K
172
- };
173
- function H(t) {
174
- const e = t, n = `${(e == null ? void 0 : e.name) ?? ""} ${(e == null ? void 0 : e.message) ?? ""} ${typeof t == "string" ? t : ""}`;
175
- return /ChunkLoadError|Loading chunk|Failed to fetch dynamically imported module|Importing a module script failed|error loading dynamically imported module/i.test(n);
176
- }
177
- function Y(t) {
178
- const { status: e, error: n } = t;
179
- return e === 401 ? {
180
- kind: "unauthorized",
181
- status: e,
182
- badge: "401",
183
- title: "登录已失效",
184
- description: "当前会话已过期或未建立,请重新登录后继续。重登后会回到这个页面。"
185
- } : e === 403 ? {
186
- kind: "forbidden",
187
- status: e,
188
- badge: "403",
189
- title: "没有访问权限",
190
- description: "当前账号无权访问该功能。如需开通,请联系管理员分配权限。"
191
- } : e === 404 ? {
192
- kind: "not-found",
193
- status: e,
194
- badge: "404",
195
- title: "功能接口未就绪",
196
- description: "这个页面要用的后端接口还没有部署,或前后端路径对不上。可以重试;若持续如此,请把技术详情发给运维确认版本。"
197
- } : e && e >= 500 ? {
198
- kind: "server",
199
- status: e,
200
- badge: String(e),
201
- title: "服务暂时不可用",
202
- description: "后端返回了错误。稍后重试;如果反复出现,请把技术详情发给运维。"
203
- } : e === 0 ? {
204
- kind: "network",
205
- status: e,
206
- badge: "!",
207
- title: "网络不可用",
208
- description: "请求没有到达后端。请检查网络,或确认本地后端服务是否已启动。"
209
- } : H(n) ? {
210
- kind: "chunk",
211
- badge: "⟳",
212
- title: "页面资源加载失败",
213
- description: "可能刚发布了新版本,旧页面资源已被替换。刷新页面即可拿到新资源。"
214
- } : n != null ? {
215
- kind: "render",
216
- badge: "!",
217
- title: "页面渲染出错",
218
- description: "这个页面遇到了未预期的错误,已被拦截,不影响其他页面。可以重试;仍然失败请把技术详情发给研发。"
219
- } : {
220
- kind: "unknown",
221
- badge: "!",
222
- title: "页面加载失败",
223
- description: "发生了未知错误。请重试,或返回首页换个入口再试。"
224
- };
225
- }
226
- function Q(t, e) {
227
- const n = [];
228
- if (n.push(`页面:${typeof location < "u" ? location.pathname + location.search : "-"}`), n.push(`时间:${(/* @__PURE__ */ new Date()).toISOString()}`), t != null && n.push(`HTTP:${t}`), e != null) {
229
- const r = e;
230
- r != null && r.name && n.push(`错误名:${String(r.name)}`), r != null && r.message && n.push(`消息:${String(r.message)}`), r != null && r.stack ? n.push(`堆栈:
231
- ${String(r.stack)}`) : typeof e != "object" && n.push(`原文:${String(e)}`);
232
- }
233
- return n.join(`
234
- `).slice(0, 4e3);
235
- }
236
- const X = ({
237
- status: t,
238
- error: e,
239
- title: n,
240
- description: r,
241
- retry: c,
242
- retryText: l,
243
- extra: i,
244
- showHome: s = !0,
245
- compact: d = !1,
246
- className: o
247
- }) => {
248
- const u = S(() => Y({ status: t, error: e }), [t, e]), [m, f] = C(!1), E = S(() => Q(t, e), [t, e]);
249
- G(() => {
250
- if (!m) return;
251
- const y = setTimeout(() => f(!1), 2e3);
252
- return () => clearTimeout(y);
253
- }, [m]);
254
- const T = async () => {
255
- try {
256
- await navigator.clipboard.writeText(E), f(!0);
257
- } catch {
258
- f(!1);
259
- }
260
- }, k = () => {
261
- const y = encodeURIComponent(location.pathname + location.search);
262
- location.assign(`/login?redirect=${y}`);
263
- }, M = () => c ? /* @__PURE__ */ p("button", { type: "button", className: a.primary, onClick: c, children: l || "重试" }) : u.kind === "chunk" ? /* @__PURE__ */ p("button", { type: "button", className: a.primary, onClick: () => location.reload(), children: "刷新页面" }) : u.kind === "unauthorized" ? /* @__PURE__ */ p("button", { type: "button", className: a.primary, onClick: k, children: "重新登录" }) : null, j = e != null || t != null;
264
- return /* @__PURE__ */ p(
265
- "div",
266
- {
267
- className: [a.wrap, d ? a.compact : "", o || ""].filter(Boolean).join(" "),
268
- role: "alert",
269
- "data-error-kind": u.kind,
270
- children: /* @__PURE__ */ I("div", { className: a.card, children: [
271
- /* @__PURE__ */ p("div", { className: a.badge, "data-kind": u.kind, children: u.badge }),
272
- /* @__PURE__ */ p("h2", { className: a.title, children: n || u.title }),
273
- /* @__PURE__ */ p("p", { className: a.desc, children: r || u.description }),
274
- /* @__PURE__ */ I("div", { className: a.actions, children: [
275
- M(),
276
- i,
277
- s && u.kind !== "unauthorized" && /* @__PURE__ */ p("a", { className: a.secondary, href: "/", children: "返回首页" })
278
- ] }),
279
- j && /* @__PURE__ */ I("details", { className: a.details, children: [
280
- /* @__PURE__ */ p("summary", { children: "技术详情" }),
281
- /* @__PURE__ */ p("pre", { className: a.pre, children: E }),
282
- /* @__PURE__ */ p("button", { type: "button", className: a.copy, onClick: T, children: m ? "已复制" : "复制详情" })
283
- ] })
284
- ] })
285
- }
286
- );
287
- };
288
- class st extends L {
289
- constructor(e) {
290
- super(e), this.state = { hasError: !1, error: null };
291
- }
292
- static getDerivedStateFromError(e) {
293
- return { hasError: !0, error: e };
294
- }
295
- componentDidCatch(e, n) {
296
- console.error("[ErrorBoundary]", e, n.componentStack);
297
- }
298
- render() {
299
- return this.state.hasError ? this.props.fallback ? this.props.fallback : /* @__PURE__ */ p(
300
- X,
301
- {
302
- error: this.state.error,
303
- retry: () => this.setState({ hasError: !1, error: null })
304
- }
305
- ) : this.props.children;
306
- }
307
- }
308
- export {
309
- st as E,
310
- X as P,
311
- nt as a,
312
- rt as c,
313
- et as f,
314
- it as h,
315
- H as i
316
- };