@yuku123/z-frontend-common 1.0.0 → 1.1.0
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/PagedTable-DyjNokXN.js +1211 -0
- package/dist/index.js +310 -1
- package/dist/ui.js +27 -0
- package/package.json +4 -1
- package/src/components/ui/CategoryDot.jsx +38 -0
- package/src/components/ui/DarkBanner.jsx +142 -0
- package/src/components/ui/EChartsChart.jsx +82 -0
- package/src/components/ui/EmptyState.jsx +94 -0
- package/src/components/ui/ErrorState.jsx +114 -0
- package/src/components/ui/FeatureCard.jsx +205 -0
- package/src/components/ui/GradientStatCard.jsx +196 -0
- package/src/components/ui/LoadingState.jsx +116 -0
- package/src/components/ui/PageHeader.jsx +143 -0
- package/src/components/ui/PagedTable.jsx +83 -0
- package/src/components/ui/SearchInput.jsx +111 -0
- package/src/components/ui/SectionHeader.jsx +76 -0
- package/src/components/ui/StatusBadge.jsx +66 -0
- package/src/components/ui/TableToolbar.jsx +58 -0
- package/src/components/ui/index.js +36 -0
- package/src/components/ui/tokens.js +224 -0
- package/src/index.js +2 -0
package/dist/index.js
CHANGED
|
@@ -1 +1,310 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import { C as xe, D as we, E as Ie, a as ke, b as Ce, F as be, G as Re, L as ve, P as ze, c as Me, R as Le, S as Ee, d as Oe, e as Be, T as je, f as Te, g as Ke, h as $e, l as De, n as Pe, p as qe, r as Fe, s as He, i as We } from "./PagedTable-DyjNokXN.js";
|
|
2
|
+
import { jsxs as h, jsx as r } from "react/jsx-runtime";
|
|
3
|
+
import { Layout as I, Spin as B, Menu as j, Dropdown as T, Avatar as K, Button as k, Tooltip as $, Card as D, Alert as P, Form as S, Input as v, message as p, Tag as q, Result as F } from "antd";
|
|
4
|
+
import { MenuUnfoldOutlined as H, MenuFoldOutlined as W, DownOutlined as N, LoginOutlined as G, UserOutlined as J, LockOutlined as Q } from "@ant-design/icons";
|
|
5
|
+
import { useNavigate as X, useLocation as Y, Outlet as Z } from "react-router-dom";
|
|
6
|
+
import { useState as z, Component as _ } from "react";
|
|
7
|
+
import U from "axios";
|
|
8
|
+
const { Header: V, Sider: A, Content: ee } = I;
|
|
9
|
+
function te(t, e = 0.85) {
|
|
10
|
+
const o = /^#?([0-9a-f]{6})$/i.exec(t || "");
|
|
11
|
+
if (!o) return t;
|
|
12
|
+
const d = parseInt(o[1], 16), u = Math.max(0, Math.min(255, Math.round((d >> 16 & 255) * e))), n = Math.max(0, Math.min(255, Math.round((d >> 8 & 255) * e))), a = Math.max(0, Math.min(255, Math.round((d & 255) * e)));
|
|
13
|
+
return "#" + (u << 16 | n << 8 | a).toString(16).padStart(6, "0");
|
|
14
|
+
}
|
|
15
|
+
function re({
|
|
16
|
+
menuItems: t = [],
|
|
17
|
+
appTitle: e = "One Company",
|
|
18
|
+
appShort: o = "OC",
|
|
19
|
+
appVersion: d,
|
|
20
|
+
appIcon: u,
|
|
21
|
+
appUser: n,
|
|
22
|
+
loginPath: a,
|
|
23
|
+
headerExtra: g,
|
|
24
|
+
loading: x = !1
|
|
25
|
+
}) {
|
|
26
|
+
const [i, m] = z(!1), y = X(), c = Y(), E = ({ key: f }) => {
|
|
27
|
+
y(f);
|
|
28
|
+
}, b = () => {
|
|
29
|
+
if (a) return a;
|
|
30
|
+
const f = t && t[0], l = f && f.key;
|
|
31
|
+
return typeof l == "string" && l.endsWith("/home") ? l.slice(0, -4) + "login" : "/login";
|
|
32
|
+
}, R = (f, l = []) => {
|
|
33
|
+
for (const s of f || [])
|
|
34
|
+
s != null && s.key && l.push(s.key), s != null && s.children && R(s.children, l);
|
|
35
|
+
return l;
|
|
36
|
+
}, O = (() => {
|
|
37
|
+
const f = R(t), l = c.pathname;
|
|
38
|
+
return f.filter((s) => l === s || l.startsWith(s + "/")).sort((s, w) => w.length - s.length)[0] || l;
|
|
39
|
+
})();
|
|
40
|
+
return /* @__PURE__ */ h(I, { style: { minHeight: "100vh" }, children: [
|
|
41
|
+
/* @__PURE__ */ h(A, { trigger: null, collapsible: !0, collapsed: i, children: [
|
|
42
|
+
/* @__PURE__ */ r("div", { style: {
|
|
43
|
+
height: 64,
|
|
44
|
+
display: "flex",
|
|
45
|
+
alignItems: "center",
|
|
46
|
+
justifyContent: "center"
|
|
47
|
+
}, children: (() => {
|
|
48
|
+
if (i) {
|
|
49
|
+
if (u) {
|
|
50
|
+
const { icon: f, color: l = "#7c3aed", label: s = e } = u, w = /* @__PURE__ */ r("div", { style: {
|
|
51
|
+
width: 36,
|
|
52
|
+
height: 36,
|
|
53
|
+
borderRadius: 9,
|
|
54
|
+
background: `linear-gradient(135deg, ${l}, ${te(l, 0.7)})`,
|
|
55
|
+
display: "flex",
|
|
56
|
+
alignItems: "center",
|
|
57
|
+
justifyContent: "center",
|
|
58
|
+
color: "#fff",
|
|
59
|
+
fontSize: 20,
|
|
60
|
+
boxShadow: "0 2px 6px rgba(0,0,0,0.25)",
|
|
61
|
+
overflow: "hidden"
|
|
62
|
+
}, children: f });
|
|
63
|
+
return /* @__PURE__ */ r($, { title: s, placement: "right", children: w });
|
|
64
|
+
}
|
|
65
|
+
return o;
|
|
66
|
+
}
|
|
67
|
+
return /* @__PURE__ */ h("span", { style: { color: "#fff", fontWeight: 600, fontSize: 16, whiteSpace: "nowrap" }, children: [
|
|
68
|
+
e,
|
|
69
|
+
d && /* @__PURE__ */ h("span", { style: {
|
|
70
|
+
color: "rgba(255,255,255,0.55)",
|
|
71
|
+
fontWeight: 400,
|
|
72
|
+
fontSize: 12,
|
|
73
|
+
marginLeft: 4
|
|
74
|
+
}, children: [
|
|
75
|
+
"@",
|
|
76
|
+
d
|
|
77
|
+
] })
|
|
78
|
+
] });
|
|
79
|
+
})() }),
|
|
80
|
+
x ? /* @__PURE__ */ r("div", { style: { padding: 16, textAlign: "center" }, children: /* @__PURE__ */ r(B, { size: "small" }) }) : /* @__PURE__ */ r(
|
|
81
|
+
j,
|
|
82
|
+
{
|
|
83
|
+
theme: "dark",
|
|
84
|
+
mode: "inline",
|
|
85
|
+
selectedKeys: [O],
|
|
86
|
+
items: t,
|
|
87
|
+
onClick: E
|
|
88
|
+
}
|
|
89
|
+
)
|
|
90
|
+
] }),
|
|
91
|
+
/* @__PURE__ */ h(I, { children: [
|
|
92
|
+
/* @__PURE__ */ h(V, { style: {
|
|
93
|
+
height: 48,
|
|
94
|
+
lineHeight: "48px",
|
|
95
|
+
padding: "0 16px",
|
|
96
|
+
background: "#fff",
|
|
97
|
+
display: "flex",
|
|
98
|
+
alignItems: "center",
|
|
99
|
+
justifyContent: "space-between",
|
|
100
|
+
borderBottom: "1px solid #f1f5f9"
|
|
101
|
+
}, children: [
|
|
102
|
+
/* @__PURE__ */ r("span", { onClick: () => m(!i), style: { fontSize: 18, cursor: "pointer" }, children: i ? /* @__PURE__ */ r(H, {}) : /* @__PURE__ */ r(W, {}) }),
|
|
103
|
+
/* @__PURE__ */ h("div", { style: { display: "flex", alignItems: "center", gap: 12 }, children: [
|
|
104
|
+
n && /* @__PURE__ */ r(
|
|
105
|
+
T,
|
|
106
|
+
{
|
|
107
|
+
menu: {
|
|
108
|
+
items: [
|
|
109
|
+
{ key: "profile", label: `${n.name}(${n.role || "用户"})`, disabled: !0 },
|
|
110
|
+
{ type: "divider" },
|
|
111
|
+
{
|
|
112
|
+
key: "logout",
|
|
113
|
+
label: "退出登录",
|
|
114
|
+
onClick: () => {
|
|
115
|
+
localStorage.removeItem("token"), localStorage.removeItem("userInfo"), window.location.href = b();
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
]
|
|
119
|
+
},
|
|
120
|
+
placement: "bottomRight",
|
|
121
|
+
children: /* @__PURE__ */ h("span", { style: { cursor: "pointer", display: "inline-flex", alignItems: "center", gap: 6 }, children: [
|
|
122
|
+
/* @__PURE__ */ r(K, { size: 28, style: { background: "#7c3aed" }, children: (n.name || "?").slice(0, 1).toUpperCase() }),
|
|
123
|
+
/* @__PURE__ */ r("span", { style: { fontSize: 13, color: "#0f172a" }, children: n.name }),
|
|
124
|
+
/* @__PURE__ */ r(N, { style: { fontSize: 10, color: "#94a3b8" } })
|
|
125
|
+
] })
|
|
126
|
+
}
|
|
127
|
+
),
|
|
128
|
+
!n && /* @__PURE__ */ r(
|
|
129
|
+
k,
|
|
130
|
+
{
|
|
131
|
+
type: "primary",
|
|
132
|
+
size: "small",
|
|
133
|
+
icon: /* @__PURE__ */ r(G, {}),
|
|
134
|
+
onClick: () => {
|
|
135
|
+
window.location.href = b();
|
|
136
|
+
},
|
|
137
|
+
children: "登录"
|
|
138
|
+
}
|
|
139
|
+
),
|
|
140
|
+
g
|
|
141
|
+
] })
|
|
142
|
+
] }),
|
|
143
|
+
/* @__PURE__ */ r(ee, { style: { margin: 16, padding: 24, background: "#fff", minHeight: 280 }, children: /* @__PURE__ */ r(Z, {}) })
|
|
144
|
+
] })
|
|
145
|
+
] });
|
|
146
|
+
}
|
|
147
|
+
function ne(t) {
|
|
148
|
+
return t && typeof t == "object" && "code" in t && "data" in t ? t.code !== 200 ? Promise.reject(new Error(t.message || "请求失败")) : t.data : t;
|
|
149
|
+
}
|
|
150
|
+
function oe(t, e = {}) {
|
|
151
|
+
const {
|
|
152
|
+
tokenKey: o = "token",
|
|
153
|
+
userInfoKey: d = "userInfo",
|
|
154
|
+
unauthorizedRedirect: u = "/login"
|
|
155
|
+
} = e;
|
|
156
|
+
return t.interceptors.request.use((n) => {
|
|
157
|
+
const a = localStorage.getItem(o);
|
|
158
|
+
return a && (n.headers.Authorization = `Bearer ${a}`), n;
|
|
159
|
+
}), t.interceptors.response.use(
|
|
160
|
+
(n) => ne(n.data),
|
|
161
|
+
(n) => {
|
|
162
|
+
var g;
|
|
163
|
+
const a = (g = n.response) == null ? void 0 : g.status;
|
|
164
|
+
return a === 401 ? (localStorage.removeItem(o), localStorage.removeItem(d), window.location.href = u) : a === 403 ? console.error("没有权限访问该资源") : a === 500 && console.error("服务器内部错误"), Promise.reject(n);
|
|
165
|
+
}
|
|
166
|
+
), t;
|
|
167
|
+
}
|
|
168
|
+
function C(t = {}) {
|
|
169
|
+
const e = U.create({
|
|
170
|
+
baseURL: t.baseURL ?? "/api",
|
|
171
|
+
timeout: t.timeout ?? 1e4
|
|
172
|
+
});
|
|
173
|
+
return oe(e, {
|
|
174
|
+
tokenKey: t.tokenKey,
|
|
175
|
+
userInfoKey: t.userInfoKey,
|
|
176
|
+
unauthorizedRedirect: t.unauthorizedRedirect
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
const M = C(), se = C();
|
|
180
|
+
function ae({
|
|
181
|
+
title: t = "统一管理平台",
|
|
182
|
+
mockAuth: e,
|
|
183
|
+
loginApi: o = "/auth/login",
|
|
184
|
+
redirectUrl: d = "/",
|
|
185
|
+
onSuccess: u
|
|
186
|
+
}) {
|
|
187
|
+
const [n, a] = z(!1), g = (i) => {
|
|
188
|
+
localStorage.setItem("token", e ? "mock-" + e.username : (i == null ? void 0 : i.token) || "token"), localStorage.setItem("userInfo", JSON.stringify(i || {})), p.success("登录成功" + (e ? "(mock 模式,待 CTC/SSO 接入)" : "")), u ? u(i) : window.location.href = d;
|
|
189
|
+
}, x = async (i) => {
|
|
190
|
+
var m, y;
|
|
191
|
+
a(!0);
|
|
192
|
+
try {
|
|
193
|
+
if (e) {
|
|
194
|
+
i.username === e.username && i.password === e.password ? g(e.user) : p.error("用户名或密码错误");
|
|
195
|
+
return;
|
|
196
|
+
}
|
|
197
|
+
const c = await M.post(o, i);
|
|
198
|
+
c != null && c.token ? (localStorage.setItem("token", c.token), localStorage.setItem("userInfo", JSON.stringify(c.user || c)), p.success("登录成功"), u ? u(c) : window.location.href = d) : p.error("登录失败:未获取到 token");
|
|
199
|
+
} catch (c) {
|
|
200
|
+
p.error(((y = (m = c.response) == null ? void 0 : m.data) == null ? void 0 : y.message) || c.message || "登录失败");
|
|
201
|
+
} finally {
|
|
202
|
+
a(!1);
|
|
203
|
+
}
|
|
204
|
+
};
|
|
205
|
+
return /* @__PURE__ */ r("div", { style: {
|
|
206
|
+
height: "100vh",
|
|
207
|
+
display: "flex",
|
|
208
|
+
justifyContent: "center",
|
|
209
|
+
alignItems: "center",
|
|
210
|
+
background: "#f0f2f5"
|
|
211
|
+
}, children: /* @__PURE__ */ h(D, { title: t, style: { width: 400 }, children: [
|
|
212
|
+
e && /* @__PURE__ */ r(
|
|
213
|
+
P,
|
|
214
|
+
{
|
|
215
|
+
type: "info",
|
|
216
|
+
showIcon: !0,
|
|
217
|
+
style: { marginBottom: 16 },
|
|
218
|
+
message: `Mock 模式:用户名 ${e.username} / 密码 ${e.password}`
|
|
219
|
+
}
|
|
220
|
+
),
|
|
221
|
+
/* @__PURE__ */ h(S, { onFinish: x, size: "large", children: [
|
|
222
|
+
/* @__PURE__ */ r(S.Item, { name: "username", rules: [{ required: !0, message: "请输入用户名" }], children: /* @__PURE__ */ r(v, { prefix: /* @__PURE__ */ r(J, {}), placeholder: "用户名" }) }),
|
|
223
|
+
/* @__PURE__ */ r(S.Item, { name: "password", rules: [{ required: !0, message: "请输入密码" }], children: /* @__PURE__ */ r(v.Password, { prefix: /* @__PURE__ */ r(Q, {}), placeholder: "密码" }) }),
|
|
224
|
+
/* @__PURE__ */ r(S.Item, { children: /* @__PURE__ */ r(k, { type: "primary", htmlType: "submit", loading: n, block: !0, children: "登 录" }) })
|
|
225
|
+
] })
|
|
226
|
+
] }) });
|
|
227
|
+
}
|
|
228
|
+
const L = {
|
|
229
|
+
1: { color: "green", text: "正常" },
|
|
230
|
+
0: { color: "red", text: "禁用" },
|
|
231
|
+
pending: { color: "orange", text: "待处理" },
|
|
232
|
+
approved: { color: "blue", text: "已通过" },
|
|
233
|
+
rejected: { color: "red", text: "已拒绝" }
|
|
234
|
+
};
|
|
235
|
+
function ie({ status: t, map: e }) {
|
|
236
|
+
const o = (e == null ? void 0 : e[t]) || L[t] || { color: "default", text: String(t) };
|
|
237
|
+
return /* @__PURE__ */ r(q, { color: o.color, children: o.text });
|
|
238
|
+
}
|
|
239
|
+
class le extends _ {
|
|
240
|
+
constructor(e) {
|
|
241
|
+
super(e), this.state = { hasError: !1, error: null, errorInfo: null }, this.handleReset = () => {
|
|
242
|
+
this.setState({ hasError: !1, error: null, errorInfo: null }), typeof this.props.onReset == "function" && this.props.onReset();
|
|
243
|
+
};
|
|
244
|
+
}
|
|
245
|
+
static getDerivedStateFromError(e) {
|
|
246
|
+
return { hasError: !0, error: e };
|
|
247
|
+
}
|
|
248
|
+
componentDidCatch(e, o) {
|
|
249
|
+
console.error("[ErrorBoundary] caught error:", e, o), this.setState({ errorInfo: o });
|
|
250
|
+
}
|
|
251
|
+
render() {
|
|
252
|
+
var e;
|
|
253
|
+
return this.state.hasError ? /* @__PURE__ */ r(
|
|
254
|
+
F,
|
|
255
|
+
{
|
|
256
|
+
status: "error",
|
|
257
|
+
title: "页面出错了",
|
|
258
|
+
subTitle: String(((e = this.state.error) == null ? void 0 : e.message) || this.state.error),
|
|
259
|
+
extra: /* @__PURE__ */ r(k, { type: "primary", onClick: this.handleReset, children: "重试" })
|
|
260
|
+
}
|
|
261
|
+
) : this.props.children;
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
const me = {
|
|
265
|
+
AppLayout: re,
|
|
266
|
+
StatusTag: ie,
|
|
267
|
+
defaultStatusMap: L,
|
|
268
|
+
LoginPage: ae,
|
|
269
|
+
ErrorBoundary: le,
|
|
270
|
+
request: M,
|
|
271
|
+
authRequest: se,
|
|
272
|
+
createRequest: C
|
|
273
|
+
};
|
|
274
|
+
export {
|
|
275
|
+
re as AppLayout,
|
|
276
|
+
xe as CategoryDot,
|
|
277
|
+
we as DarkBanner,
|
|
278
|
+
Ie as EChartsChart,
|
|
279
|
+
ke as EmptyState,
|
|
280
|
+
le as ErrorBoundary,
|
|
281
|
+
Ce as ErrorState,
|
|
282
|
+
be as FeatureCard,
|
|
283
|
+
Re as GradientStatCard,
|
|
284
|
+
ve as LoadingState,
|
|
285
|
+
ae as LoginPage,
|
|
286
|
+
ze as PageHeader,
|
|
287
|
+
Me as PagedTable,
|
|
288
|
+
Le as RefreshButton,
|
|
289
|
+
Ee as SearchInput,
|
|
290
|
+
Oe as SectionHeader,
|
|
291
|
+
Be as StatusBadge,
|
|
292
|
+
ie as StatusTag,
|
|
293
|
+
je as TableToolbar,
|
|
294
|
+
Te as antdTheme,
|
|
295
|
+
se as authRequest,
|
|
296
|
+
Ke as brand,
|
|
297
|
+
C as createRequest,
|
|
298
|
+
me as default,
|
|
299
|
+
L as defaultStatusMap,
|
|
300
|
+
$e as fontSize,
|
|
301
|
+
De as lift,
|
|
302
|
+
Pe as neutral,
|
|
303
|
+
qe as palette,
|
|
304
|
+
Fe as radius,
|
|
305
|
+
M as request,
|
|
306
|
+
oe as setupInterceptors,
|
|
307
|
+
He as shadow,
|
|
308
|
+
We as space,
|
|
309
|
+
ne as unwrapResponse
|
|
310
|
+
};
|
package/dist/ui.js
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { C as e, D as t, E as r, a as d, b as n, F as o, G as S, L as h, P as i, c as l, R as g, S as p, d as u, e as C, T as b, f, g as T, h as c, l as E, n as m, p as B, r as D, s as P, i as y } from "./PagedTable-DyjNokXN.js";
|
|
2
|
+
export {
|
|
3
|
+
e as CategoryDot,
|
|
4
|
+
t as DarkBanner,
|
|
5
|
+
r as EChartsChart,
|
|
6
|
+
d as EmptyState,
|
|
7
|
+
n as ErrorState,
|
|
8
|
+
o as FeatureCard,
|
|
9
|
+
S as GradientStatCard,
|
|
10
|
+
h as LoadingState,
|
|
11
|
+
i as PageHeader,
|
|
12
|
+
l as PagedTable,
|
|
13
|
+
g as RefreshButton,
|
|
14
|
+
p as SearchInput,
|
|
15
|
+
u as SectionHeader,
|
|
16
|
+
C as StatusBadge,
|
|
17
|
+
b as TableToolbar,
|
|
18
|
+
f as antdTheme,
|
|
19
|
+
T as brand,
|
|
20
|
+
c as fontSize,
|
|
21
|
+
E as lift,
|
|
22
|
+
m as neutral,
|
|
23
|
+
B as palette,
|
|
24
|
+
D as radius,
|
|
25
|
+
P as shadow,
|
|
26
|
+
y as space
|
|
27
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yuku123/z-frontend-common",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "z-opc 全仓共享前端基座 — AppLayout(§1/§11/§12/§15/§16) + LoginPage(mockAuth 双模式) + EmptyState/StatusTag/ErrorBoundary + createRequest 工厂。lead 008 前端开发规范唯一承载仓",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -10,6 +10,9 @@
|
|
|
10
10
|
".": {
|
|
11
11
|
"types": "./dist/index.d.ts",
|
|
12
12
|
"default": "./dist/index.js"
|
|
13
|
+
},
|
|
14
|
+
"./ui": {
|
|
15
|
+
"default": "./dist/ui.js"
|
|
13
16
|
}
|
|
14
17
|
},
|
|
15
18
|
"files": [
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import {palette} from './tokens'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* 分类圆点 - 借鉴 wenming7 分类标识
|
|
5
|
+
*
|
|
6
|
+
* 用法:
|
|
7
|
+
* <CategoryDot color="pink" /> // 仅圆点
|
|
8
|
+
* <CategoryDot color="blue" label="对话" /> // 圆点 + 文字
|
|
9
|
+
* <CategoryDot color="green" size={10} /> // 自定义大小
|
|
10
|
+
*
|
|
11
|
+
* @param {Object} props
|
|
12
|
+
* @param {string} props.color - 配色 (pink|blue|green|orange|violet|cyan|red|yellow)
|
|
13
|
+
* @param {string} [props.label] - 可选标签文字
|
|
14
|
+
* @param {number} [props.size] - 圆点直径 (默认 8)
|
|
15
|
+
*/
|
|
16
|
+
export default function CategoryDot({color = 'blue', label, size = 8}) {
|
|
17
|
+
const c = palette[color] || palette.blue
|
|
18
|
+
return (
|
|
19
|
+
<span style={{
|
|
20
|
+
display: 'inline-flex',
|
|
21
|
+
alignItems: 'center',
|
|
22
|
+
gap: 8,
|
|
23
|
+
fontSize: 14,
|
|
24
|
+
fontWeight: 600,
|
|
25
|
+
color: '#111827',
|
|
26
|
+
}}>
|
|
27
|
+
<span style={{
|
|
28
|
+
width: size,
|
|
29
|
+
height: size,
|
|
30
|
+
borderRadius: '50%',
|
|
31
|
+
background: c.bg,
|
|
32
|
+
boxShadow: `0 0 0 3px ${c.soft}`,
|
|
33
|
+
flexShrink: 0,
|
|
34
|
+
}}/>
|
|
35
|
+
{label && <span>{label}</span>}
|
|
36
|
+
</span>
|
|
37
|
+
)
|
|
38
|
+
}
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import {radius, shadow} from './tokens'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* 深色 CTA 横幅 - 借鉴 wenming7 "FOR DEVELOPERS" 区
|
|
5
|
+
*
|
|
6
|
+
* 视觉:
|
|
7
|
+
* ┌──────────────────────────────────────────────┐
|
|
8
|
+
* │ [标签] │
|
|
9
|
+
* │ 把你的想法做成产品 │ ← 深色渐变背景
|
|
10
|
+
* │ 副标题/描述文案 │
|
|
11
|
+
* │ [行动按钮 →] │
|
|
12
|
+
* └──────────────────────────────────────────────┘
|
|
13
|
+
*
|
|
14
|
+
* @param {Object} props
|
|
15
|
+
* @param {string} [props.tag] - 顶部小标签 (如 "FOR DEVELOPERS")
|
|
16
|
+
* @param {string} props.title - 主标题
|
|
17
|
+
* @param {string} [props.description] - 描述
|
|
18
|
+
* @param {string} [props.buttonText] - 按钮文案
|
|
19
|
+
* @param {string} [props.buttonHref] - 跳转路径
|
|
20
|
+
*/
|
|
21
|
+
export default function DarkBanner({
|
|
22
|
+
tag,
|
|
23
|
+
title,
|
|
24
|
+
description,
|
|
25
|
+
buttonText,
|
|
26
|
+
buttonHref,
|
|
27
|
+
onButtonClick,
|
|
28
|
+
}) {
|
|
29
|
+
return (
|
|
30
|
+
<div style={{
|
|
31
|
+
position: 'relative',
|
|
32
|
+
borderRadius: radius.lg,
|
|
33
|
+
padding: '40px 48px',
|
|
34
|
+
background: 'linear-gradient(135deg, #0f172a 0%, #1e293b 50%, #312e81 100%)',
|
|
35
|
+
color: '#ffffff',
|
|
36
|
+
overflow: 'hidden',
|
|
37
|
+
boxShadow: shadow.lg,
|
|
38
|
+
}}>
|
|
39
|
+
{/* 装饰光晕 */}
|
|
40
|
+
<div style={{
|
|
41
|
+
position: 'absolute',
|
|
42
|
+
top: -64,
|
|
43
|
+
right: -64,
|
|
44
|
+
width: 200,
|
|
45
|
+
height: 200,
|
|
46
|
+
borderRadius: '50%',
|
|
47
|
+
background: 'radial-gradient(circle, rgba(139, 92, 246, 0.4) 0%, transparent 70%)',
|
|
48
|
+
pointerEvents: 'none',
|
|
49
|
+
}}/>
|
|
50
|
+
<div style={{
|
|
51
|
+
position: 'absolute',
|
|
52
|
+
bottom: -48,
|
|
53
|
+
left: '30%',
|
|
54
|
+
width: 160,
|
|
55
|
+
height: 160,
|
|
56
|
+
borderRadius: '50%',
|
|
57
|
+
background: 'radial-gradient(circle, rgba(59, 130, 246, 0.3) 0%, transparent 70%)',
|
|
58
|
+
pointerEvents: 'none',
|
|
59
|
+
}}/>
|
|
60
|
+
|
|
61
|
+
<div style={{
|
|
62
|
+
position: 'relative',
|
|
63
|
+
display: 'flex',
|
|
64
|
+
alignItems: 'center',
|
|
65
|
+
justifyContent: 'space-between',
|
|
66
|
+
gap: 32,
|
|
67
|
+
flexWrap: 'wrap',
|
|
68
|
+
}}>
|
|
69
|
+
<div style={{flex: 1, minWidth: 240}}>
|
|
70
|
+
{tag && (
|
|
71
|
+
<div style={{
|
|
72
|
+
fontSize: 11,
|
|
73
|
+
fontWeight: 600,
|
|
74
|
+
letterSpacing: '0.12em',
|
|
75
|
+
color: '#a5b4fc',
|
|
76
|
+
textTransform: 'uppercase',
|
|
77
|
+
marginBottom: 12,
|
|
78
|
+
}}>
|
|
79
|
+
{tag}
|
|
80
|
+
</div>
|
|
81
|
+
)}
|
|
82
|
+
<div style={{
|
|
83
|
+
fontSize: 24,
|
|
84
|
+
fontWeight: 700,
|
|
85
|
+
lineHeight: 1.3,
|
|
86
|
+
marginBottom: 8,
|
|
87
|
+
}}>
|
|
88
|
+
{title}
|
|
89
|
+
</div>
|
|
90
|
+
{description && (
|
|
91
|
+
<div style={{
|
|
92
|
+
fontSize: 14,
|
|
93
|
+
color: 'rgba(255, 255, 255, 0.7)',
|
|
94
|
+
lineHeight: 1.6,
|
|
95
|
+
maxWidth: 540,
|
|
96
|
+
}}>
|
|
97
|
+
{description}
|
|
98
|
+
</div>
|
|
99
|
+
)}
|
|
100
|
+
</div>
|
|
101
|
+
|
|
102
|
+
{(buttonText && (buttonHref || onButtonClick)) && (
|
|
103
|
+
<a
|
|
104
|
+
href={buttonHref || '#'}
|
|
105
|
+
onClick={(e) => {
|
|
106
|
+
if (onButtonClick) {
|
|
107
|
+
e.preventDefault()
|
|
108
|
+
onButtonClick()
|
|
109
|
+
}
|
|
110
|
+
}}
|
|
111
|
+
style={{
|
|
112
|
+
display: 'inline-flex',
|
|
113
|
+
alignItems: 'center',
|
|
114
|
+
gap: 8,
|
|
115
|
+
padding: '12px 24px',
|
|
116
|
+
background: 'linear-gradient(135deg, #10b981 0%, #059669 100%)',
|
|
117
|
+
color: '#ffffff',
|
|
118
|
+
borderRadius: 999,
|
|
119
|
+
fontSize: 14,
|
|
120
|
+
fontWeight: 600,
|
|
121
|
+
textDecoration: 'none',
|
|
122
|
+
boxShadow: '0 4px 12px rgba(16, 185, 129, 0.4)',
|
|
123
|
+
transition: 'transform 150ms ease, box-shadow 150ms ease',
|
|
124
|
+
whiteSpace: 'nowrap',
|
|
125
|
+
}}
|
|
126
|
+
onMouseEnter={(e) => {
|
|
127
|
+
e.currentTarget.style.transform = 'translateY(-1px)'
|
|
128
|
+
e.currentTarget.style.boxShadow = '0 6px 16px rgba(16, 185, 129, 0.5)'
|
|
129
|
+
}}
|
|
130
|
+
onMouseLeave={(e) => {
|
|
131
|
+
e.currentTarget.style.transform = 'translateY(0)'
|
|
132
|
+
e.currentTarget.style.boxShadow = '0 4px 12px rgba(16, 185, 129, 0.4)'
|
|
133
|
+
}}
|
|
134
|
+
>
|
|
135
|
+
{buttonText}
|
|
136
|
+
<span>→</span>
|
|
137
|
+
</a>
|
|
138
|
+
)}
|
|
139
|
+
</div>
|
|
140
|
+
</div>
|
|
141
|
+
)
|
|
142
|
+
}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import {useEffect, useRef} from 'react'
|
|
2
|
+
import * as echarts from 'echarts/core'
|
|
3
|
+
import {BarChart, LineChart, PieChart} from 'echarts/charts'
|
|
4
|
+
import {GridComponent, LegendComponent, TitleComponent, TooltipComponent,} from 'echarts/components'
|
|
5
|
+
import {CanvasRenderer} from 'echarts/renderers'
|
|
6
|
+
|
|
7
|
+
// 只注册常用图表, 减小 bundle
|
|
8
|
+
echarts.use([
|
|
9
|
+
LineChart, PieChart, BarChart,
|
|
10
|
+
GridComponent, TooltipComponent, LegendComponent, TitleComponent,
|
|
11
|
+
CanvasRenderer,
|
|
12
|
+
])
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* EChartsChart - 安全包装 echarts 实例, 自动处理初始化/销毁/resize.
|
|
16
|
+
*
|
|
17
|
+
* 修复 z-opc 后台原 Schedule Dashboard 的交互问题:
|
|
18
|
+
* 1. 内存泄漏: 切换路由时 echarts 实例没 dispose, 多次进入页面会重复绑定 DOM
|
|
19
|
+
* 2. resize 监听器没 cleanup, 每次进入页面都新增一个
|
|
20
|
+
* 3. 颜色硬编码, 主题不一致
|
|
21
|
+
*
|
|
22
|
+
* 用法:
|
|
23
|
+
* <EChartsChart option={...} height={300} />
|
|
24
|
+
*
|
|
25
|
+
* @param {Object} props
|
|
26
|
+
* @param {Object} props.option - echarts option
|
|
27
|
+
* @param {number|string} [props.height] - 高度 (默认 300)
|
|
28
|
+
* @param {string} [props.className]
|
|
29
|
+
* @param {Object} [props.style]
|
|
30
|
+
*/
|
|
31
|
+
export default function EChartsChart({
|
|
32
|
+
option,
|
|
33
|
+
height = 300,
|
|
34
|
+
className,
|
|
35
|
+
style,
|
|
36
|
+
}) {
|
|
37
|
+
const containerRef = useRef(null)
|
|
38
|
+
const instanceRef = useRef(null)
|
|
39
|
+
|
|
40
|
+
useEffect(() => {
|
|
41
|
+
if (!containerRef.current) return
|
|
42
|
+
instanceRef.current = echarts.init(containerRef.current, null, {renderer: 'canvas'})
|
|
43
|
+
|
|
44
|
+
let resizeObserver
|
|
45
|
+
const onResize = () => instanceRef.current?.resize()
|
|
46
|
+
if (typeof ResizeObserver !== 'undefined') {
|
|
47
|
+
resizeObserver = new ResizeObserver(onResize)
|
|
48
|
+
resizeObserver.observe(containerRef.current)
|
|
49
|
+
} else {
|
|
50
|
+
window.addEventListener('resize', onResize)
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
return () => {
|
|
54
|
+
if (resizeObserver) resizeObserver.disconnect()
|
|
55
|
+
else window.removeEventListener('resize', onResize)
|
|
56
|
+
if (instanceRef.current) {
|
|
57
|
+
instanceRef.current.dispose()
|
|
58
|
+
instanceRef.current = null
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}, [])
|
|
62
|
+
|
|
63
|
+
useEffect(() => {
|
|
64
|
+
if (instanceRef.current && option) {
|
|
65
|
+
instanceRef.current.setOption(option, {notMerge: true})
|
|
66
|
+
}
|
|
67
|
+
}, [option])
|
|
68
|
+
|
|
69
|
+
return (
|
|
70
|
+
<div
|
|
71
|
+
ref={containerRef}
|
|
72
|
+
className={className}
|
|
73
|
+
role="img"
|
|
74
|
+
aria-label="数据可视化图表"
|
|
75
|
+
style={{
|
|
76
|
+
width: '100%',
|
|
77
|
+
height,
|
|
78
|
+
...style,
|
|
79
|
+
}}
|
|
80
|
+
/>
|
|
81
|
+
)
|
|
82
|
+
}
|