@yuku123/z-team-component 0.2.103 → 0.2.105
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-B0ML82u0.js +542 -0
- package/dist/ComponentDoc-C_289lsE.js +8035 -0
- package/dist/InvitationManagementPage-D2ezz4ZQ.js +495 -0
- package/dist/OnboardingPage-BXsJ-kcJ.js +393 -0
- package/dist/ScheduledTasks-Cn8BsDkN.js +12127 -0
- package/dist/SystemShell-gcfNlt2L.js +688 -0
- package/dist/_commonjsHelpers-B52_cu2H.js +26 -0
- package/dist/admin-logs-B6K1DwRL.js +198 -0
- package/dist/api-BdP8mK8v.js +101 -0
- package/dist/api-DxSgE7qw.js +20 -0
- package/dist/browser-jb_PFvU3.js +1538 -0
- package/dist/createWorkspaceWsHandler-DcNA1pfi.js +13142 -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-54iTaRVW.js +316 -0
- package/dist/index-BCw3Oxp1.js +42049 -0
- package/dist/index-BDq0ofl2.js +348 -0
- package/dist/index-BN-o5nZM.js +8 -0
- package/dist/index-B_LJRFsK.js +339 -0
- package/dist/index-Bf1K9zpk.js +112 -0
- package/dist/index-BfMFQ6RD.js +169 -0
- package/dist/index-BohoJQPr.js +7631 -0
- package/dist/index-C-8n6xxK.js +93 -0
- package/dist/index-C815hPWS.js +430 -0
- package/dist/index-C8m8s-SU.js +479 -0
- package/dist/index-CXJXSmhB.js +2217 -0
- package/dist/index-CdugR2_4.js +5892 -0
- package/dist/index-CeCsncoT.js +913 -0
- package/dist/index-CgCB0-yK.js +1645 -0
- package/dist/index-Cjddvrij.js +2699 -0
- package/dist/index-D487Inba.js +315 -0
- package/dist/index-DK71mfJn.js +999 -0
- package/dist/index-DLHcoHS9.js +189 -0
- package/dist/index-DUiFk01c.js +178 -0
- package/dist/index-DWsfQMp8.js +208 -0
- package/dist/index-DgN13A-E.js +10169 -0
- package/dist/index-DhDdFRHC.js +279 -0
- package/dist/index-DpLamT1r.js +574 -0
- package/dist/index-Dpii3P5J.js +1302 -0
- package/dist/index-DszzQwsc.js +956 -0
- package/dist/index-HJ3Kt-NT.js +358 -0
- package/dist/index-Nj-dlFKY.js +242 -0
- package/dist/index-ZuYJoo9E.js +118 -0
- package/dist/index-etyS3HY2.js +142 -0
- package/dist/index-jIh52A4c.js +132 -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/instance-p-ezisoS.js +216 -0
- package/dist/menuPermission-u3Gd_c8S.js +60 -0
- package/dist/mobile-client-O3yr9h6t.js +24 -0
- package/dist/pages.js +21 -0
- package/dist/send-default-agent-team-message-BhIV6T6O.js +35 -0
- package/dist/spark-md5-Dld54a-T.js +178 -0
- package/dist/sso-user-Ib1jhF7t.js +43 -0
- package/dist/training-D3Uy5K_M.js +450 -0
- package/dist/webide-BGQnArzY.js +5233 -0
- package/dist/z-team-component.css +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
function d() {
|
|
2
|
+
if (typeof window > "u") return null;
|
|
3
|
+
try {
|
|
4
|
+
const t = localStorage.getItem("USER_INFO");
|
|
5
|
+
if (t) return JSON.parse(t);
|
|
6
|
+
const a = localStorage.getItem("userInfo") || localStorage.getItem("user_info");
|
|
7
|
+
if (!a) return null;
|
|
8
|
+
const n = JSON.parse(a), r = {
|
|
9
|
+
name: String(n.nickname || n.name || ""),
|
|
10
|
+
jobNumber: String(n.userId || n.jobNumber || ""),
|
|
11
|
+
username: String(n.username || n.account || n.name || ""),
|
|
12
|
+
staffId: typeof n.userId == "number" ? n.userId : Number(n.userId) || 0
|
|
13
|
+
};
|
|
14
|
+
return localStorage.setItem("USER_INFO", JSON.stringify(r)), window.USER_INFO = r, r;
|
|
15
|
+
} catch {
|
|
16
|
+
return null;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
async function m() {
|
|
20
|
+
const t = () => {
|
|
21
|
+
localStorage.removeItem("USER_INFO"), window.USER_INFO = void 0;
|
|
22
|
+
};
|
|
23
|
+
try {
|
|
24
|
+
const a = new AbortController(), n = setTimeout(() => a.abort(), 1500), r = await fetch("/kapi/z-ctc/api/ctc/authn/whoami", {
|
|
25
|
+
method: "GET",
|
|
26
|
+
credentials: "include",
|
|
27
|
+
headers: { Accept: "application/json" },
|
|
28
|
+
signal: a.signal
|
|
29
|
+
});
|
|
30
|
+
if (clearTimeout(n), r.status === 401) {
|
|
31
|
+
const s = await u();
|
|
32
|
+
return s ? { kind: "authenticated", user: s } : (t(), { kind: "unauthenticated" });
|
|
33
|
+
}
|
|
34
|
+
if (!r.ok) {
|
|
35
|
+
const s = await u();
|
|
36
|
+
return s ? { kind: "authenticated", user: s } : { kind: "unavailable" };
|
|
37
|
+
}
|
|
38
|
+
const e = await r.json();
|
|
39
|
+
if (!e.success || !e.data)
|
|
40
|
+
return t(), { kind: "unauthenticated" };
|
|
41
|
+
const o = e.data.user_id ?? e.data.userId, i = {
|
|
42
|
+
name: e.data.nickname || e.data.username,
|
|
43
|
+
jobNumber: o != null ? String(o) : "",
|
|
44
|
+
username: e.data.username
|
|
45
|
+
};
|
|
46
|
+
localStorage.setItem("USER_INFO", JSON.stringify(i)), localStorage.setItem(
|
|
47
|
+
"ctcUrl",
|
|
48
|
+
encodeURIComponent(window.location.origin)
|
|
49
|
+
), window.USER_INFO = i;
|
|
50
|
+
const c = localStorage.getItem("token") || localStorage.getItem("z_team_token");
|
|
51
|
+
c && localStorage.setItem("token", c);
|
|
52
|
+
const l = {
|
|
53
|
+
userId: o,
|
|
54
|
+
id: o,
|
|
55
|
+
userName: e.data.username,
|
|
56
|
+
username: e.data.username,
|
|
57
|
+
nickname: e.data.nickname
|
|
58
|
+
};
|
|
59
|
+
return localStorage.setItem("userInfo", JSON.stringify(l)), { kind: "authenticated", user: i };
|
|
60
|
+
} catch {
|
|
61
|
+
const a = await u();
|
|
62
|
+
return a ? { kind: "authenticated", user: a } : (t(), { kind: "unavailable" });
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
async function u() {
|
|
66
|
+
if (typeof window > "u") return null;
|
|
67
|
+
let t = null;
|
|
68
|
+
try {
|
|
69
|
+
t = localStorage.getItem("token") || localStorage.getItem("z_team_token");
|
|
70
|
+
} catch {
|
|
71
|
+
return null;
|
|
72
|
+
}
|
|
73
|
+
if (!t || !t.trim()) return null;
|
|
74
|
+
try {
|
|
75
|
+
const a = new AbortController(), n = setTimeout(() => a.abort(), 2e3), r = await fetch("/kapi/z-ctc/api/ctc/authn/whoami", {
|
|
76
|
+
method: "GET",
|
|
77
|
+
headers: {
|
|
78
|
+
Accept: "application/json",
|
|
79
|
+
Authorization: `Bearer ${t.trim()}`
|
|
80
|
+
},
|
|
81
|
+
signal: a.signal
|
|
82
|
+
});
|
|
83
|
+
if (clearTimeout(n), !r.ok) return null;
|
|
84
|
+
const e = await r.json();
|
|
85
|
+
if (!e.success || !e.data) return null;
|
|
86
|
+
const o = e.data.user_id ?? e.data.userId, i = {
|
|
87
|
+
name: e.data.nickname || e.data.username,
|
|
88
|
+
jobNumber: o != null ? String(o) : "",
|
|
89
|
+
username: e.data.username
|
|
90
|
+
};
|
|
91
|
+
localStorage.setItem("USER_INFO", JSON.stringify(i)), localStorage.setItem(
|
|
92
|
+
"ctcUrl",
|
|
93
|
+
encodeURIComponent(window.location.origin)
|
|
94
|
+
), window.USER_INFO = i;
|
|
95
|
+
const c = {
|
|
96
|
+
userId: o,
|
|
97
|
+
id: o,
|
|
98
|
+
userName: e.data.username,
|
|
99
|
+
username: e.data.username,
|
|
100
|
+
nickname: e.data.nickname
|
|
101
|
+
};
|
|
102
|
+
return localStorage.setItem("userInfo", JSON.stringify(c)), i;
|
|
103
|
+
} catch {
|
|
104
|
+
return null;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
function f() {
|
|
108
|
+
const t = new URL(window.location.href);
|
|
109
|
+
t.searchParams.has("_from_login") || t.searchParams.set("_from_login", "1");
|
|
110
|
+
const a = `/login?redirect=${encodeURIComponent(t.toString())}`;
|
|
111
|
+
window.location.href = a;
|
|
112
|
+
}
|
|
113
|
+
export {
|
|
114
|
+
m as f,
|
|
115
|
+
f as r,
|
|
116
|
+
d as s
|
|
117
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import * as o from "echarts/core";
|
|
2
|
+
import { BarChart as r, LineChart as e, PieChart as n } from "echarts/charts";
|
|
3
|
+
import { GridComponent as t, LegendComponent as m, MarkLineComponent as p, TitleComponent as i, TooltipComponent as a, GraphicComponent as C } from "echarts/components";
|
|
4
|
+
import { CanvasRenderer as h } from "echarts/renderers";
|
|
5
|
+
o.use([
|
|
6
|
+
r,
|
|
7
|
+
e,
|
|
8
|
+
n,
|
|
9
|
+
t,
|
|
10
|
+
m,
|
|
11
|
+
p,
|
|
12
|
+
i,
|
|
13
|
+
a,
|
|
14
|
+
C,
|
|
15
|
+
h
|
|
16
|
+
]);
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
function i(t) {
|
|
2
|
+
if (typeof t == "string")
|
|
3
|
+
return t;
|
|
4
|
+
const { pathname: o = "", search: n = "", hash: r = "" } = t, e = n && !n.startsWith("?") ? `?${n}` : n, a = r && !r.startsWith("#") ? `#${r}` : r;
|
|
5
|
+
return `${o}${e}${a}`;
|
|
6
|
+
}
|
|
7
|
+
function s() {
|
|
8
|
+
try {
|
|
9
|
+
window.dispatchEvent(new PopStateEvent("popstate"));
|
|
10
|
+
} catch {
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
const w = {
|
|
14
|
+
/** 当前 location(与 umi/history 形状保持一致) */
|
|
15
|
+
get location() {
|
|
16
|
+
return window.location;
|
|
17
|
+
},
|
|
18
|
+
/** 跳转到新地址(pushState + 通知 Router) */
|
|
19
|
+
push(t, o) {
|
|
20
|
+
window.history.pushState(o ?? {}, "", i(t)), s();
|
|
21
|
+
},
|
|
22
|
+
/** 替换当前地址(replaceState + 通知 Router) */
|
|
23
|
+
replace(t, o) {
|
|
24
|
+
window.history.replaceState(o ?? {}, "", i(t)), s();
|
|
25
|
+
},
|
|
26
|
+
/** 历史栈移动 */
|
|
27
|
+
go(t) {
|
|
28
|
+
window.history.go(t);
|
|
29
|
+
},
|
|
30
|
+
/** 后退 */
|
|
31
|
+
back() {
|
|
32
|
+
window.history.back();
|
|
33
|
+
},
|
|
34
|
+
/** 前进 */
|
|
35
|
+
forward() {
|
|
36
|
+
window.history.forward();
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
export {
|
|
40
|
+
w as h
|
|
41
|
+
};
|
|
@@ -0,0 +1,316 @@
|
|
|
1
|
+
import { a as h, f as _, B as N, v as A, t as g } from "./ComponentDoc-C_289lsE.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
|
+
};
|