@arcblock/ux 3.4.6 → 3.4.7
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/lib/AnimationWaiter/index.js +54 -48
- package/lib/Theme/theme.js +48 -48
- package/lib/Util/logger.js +11 -8
- package/lib/hooks/use-clock.js +2 -2
- package/lib/package.json.js +1 -1
- package/lib/withTracker/index.js +19 -17
- package/package.json +15 -9
- package/src/AnimationWaiter/index.jsx +25 -15
- package/src/Theme/theme.ts +4 -4
- package/src/Util/logger.ts +17 -6
- package/src/hooks/use-clock.tsx +2 -2
- package/src/withTracker/index.tsx +11 -3
|
@@ -1,92 +1,98 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { useState as l, useRef as
|
|
3
|
-
import { useTheme as
|
|
1
|
+
import { jsxs as T, jsx as s } from "react/jsx-runtime";
|
|
2
|
+
import { lazy as M, useState as l, useRef as z, useEffect as m, Suspense as E } from "react";
|
|
3
|
+
import { useTheme as F, Skeleton as P } from "@mui/material";
|
|
4
4
|
import n from "prop-types";
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
|
|
8
|
-
function
|
|
9
|
-
animationData:
|
|
10
|
-
size:
|
|
5
|
+
import R from "lodash/noop";
|
|
6
|
+
import { styled as W } from "../Theme/index.js";
|
|
7
|
+
const q = M(() => import("react-lottie-player"));
|
|
8
|
+
function B({
|
|
9
|
+
animationData: c = null,
|
|
10
|
+
size: o = 256,
|
|
11
11
|
message: r = "",
|
|
12
12
|
messageDuration: f = 5e3,
|
|
13
|
-
messageLoop:
|
|
13
|
+
messageLoop: v = !0,
|
|
14
14
|
tips: a = [],
|
|
15
15
|
tipsDuration: u = 5e3,
|
|
16
|
-
maybeDuration:
|
|
16
|
+
maybeDuration: x = 12e4,
|
|
17
17
|
speed: h = 1,
|
|
18
|
-
increaseSpeed:
|
|
19
|
-
...
|
|
18
|
+
increaseSpeed: I = 0,
|
|
19
|
+
...k
|
|
20
20
|
}) {
|
|
21
|
-
const g =
|
|
22
|
-
Array.isArray(r) || (r = [r]),
|
|
23
|
-
|
|
21
|
+
const g = F(), [d, N] = l(0), [y, A] = l(h), [w, S] = l(0), [O, j] = l(null), [C, p] = l(!c), L = z((/* @__PURE__ */ new Date()).getTime());
|
|
22
|
+
Array.isArray(r) || (r = [r]), m(() => {
|
|
23
|
+
c || (p(!0), (async () => {
|
|
24
24
|
try {
|
|
25
25
|
const e = await (g.palette.mode === "dark" ? import("./dark-animation.json.js") : import("./default-animation.json.js"));
|
|
26
|
-
|
|
26
|
+
j(e.default || e), p(!1);
|
|
27
27
|
} catch (e) {
|
|
28
28
|
console.error("Failed to load animation:", e), p(!1);
|
|
29
29
|
}
|
|
30
30
|
})());
|
|
31
|
-
}, [
|
|
31
|
+
}, [c, g.palette.mode]), m(() => {
|
|
32
32
|
if (!r)
|
|
33
33
|
return;
|
|
34
34
|
let t = 0;
|
|
35
35
|
const e = setInterval(() => {
|
|
36
|
-
t++, t >= r.length && (
|
|
36
|
+
t++, t >= r.length && (v ? t = 0 : t = r.length - 1), S(t);
|
|
37
37
|
}, f);
|
|
38
38
|
return () => {
|
|
39
39
|
clearInterval(e);
|
|
40
40
|
};
|
|
41
|
-
}, [r, f]),
|
|
41
|
+
}, [r, f]), m(() => {
|
|
42
42
|
if (!a.length)
|
|
43
|
-
return
|
|
43
|
+
return R;
|
|
44
44
|
const t = setTimeout(() => {
|
|
45
45
|
let e = d + 1;
|
|
46
46
|
e >= a.length && (e = 0), N(e);
|
|
47
47
|
}, u);
|
|
48
48
|
return () => clearTimeout(t);
|
|
49
|
-
}, [a, u, d]),
|
|
49
|
+
}, [a, u, d]), m(() => {
|
|
50
50
|
const t = setTimeout(() => {
|
|
51
|
-
let i = ((/* @__PURE__ */ new Date()).getTime() -
|
|
51
|
+
let i = ((/* @__PURE__ */ new Date()).getTime() - L.current) / x;
|
|
52
52
|
i > 1 && (i = 1);
|
|
53
|
-
const
|
|
54
|
-
|
|
53
|
+
const $ = h + I * i;
|
|
54
|
+
A($);
|
|
55
55
|
}, 1e3);
|
|
56
56
|
return () => clearTimeout(t);
|
|
57
57
|
}, [y]);
|
|
58
|
-
const
|
|
58
|
+
const D = (t) => {
|
|
59
59
|
let e = "message-before";
|
|
60
60
|
return w === t ? e = "show-message" : w < t && (e = "message-after"), e;
|
|
61
|
-
};
|
|
62
|
-
return /* @__PURE__ */
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
61
|
+
}, b = /* @__PURE__ */ s("div", { style: { width: o, height: o, display: "flex", justifyContent: "center", alignItems: "center" }, children: /* @__PURE__ */ s(P, { variant: "rounded", width: o * 0.4, height: o * 0.4 }) });
|
|
62
|
+
return /* @__PURE__ */ T(G, { ...k, children: [
|
|
63
|
+
C ? (
|
|
64
|
+
// 当正在加载默认动画时直接展示 fallback
|
|
65
|
+
b
|
|
66
|
+
) : (
|
|
67
|
+
// 否则使用 Suspense 包裹懒加载的 Lottie,Suspense 会在 Lottie 本身未加载完成时展示 fallback
|
|
68
|
+
/* @__PURE__ */ s(E, { fallback: b, children: /* @__PURE__ */ s(
|
|
69
|
+
q,
|
|
70
|
+
{
|
|
71
|
+
loop: !0,
|
|
72
|
+
animationData: c || O,
|
|
73
|
+
play: !0,
|
|
74
|
+
speed: y,
|
|
75
|
+
style: {
|
|
76
|
+
width: o,
|
|
77
|
+
height: o
|
|
78
|
+
}
|
|
73
79
|
}
|
|
74
|
-
}
|
|
80
|
+
) })
|
|
75
81
|
),
|
|
76
|
-
r && /* @__PURE__ */
|
|
77
|
-
const i =
|
|
78
|
-
return /* @__PURE__ */
|
|
82
|
+
r && /* @__PURE__ */ s("div", { className: "waiter-message", children: r.map((t, e) => {
|
|
83
|
+
const i = D(e);
|
|
84
|
+
return /* @__PURE__ */ T(
|
|
79
85
|
"div",
|
|
80
86
|
{
|
|
81
87
|
children: [
|
|
82
|
-
/* @__PURE__ */
|
|
83
|
-
/* @__PURE__ */
|
|
88
|
+
/* @__PURE__ */ s("span", { className: `message-block ${i}`, children: t }),
|
|
89
|
+
/* @__PURE__ */ s("span", { className: `placeholder-message ${i}`, children: t })
|
|
84
90
|
]
|
|
85
91
|
},
|
|
86
92
|
e
|
|
87
93
|
);
|
|
88
94
|
}) }),
|
|
89
|
-
a.length ? /* @__PURE__ */
|
|
95
|
+
a.length ? /* @__PURE__ */ s("div", { className: "waiter-tips-container", children: a.map((t, e) => /* @__PURE__ */ s(
|
|
90
96
|
"div",
|
|
91
97
|
{
|
|
92
98
|
className: `waiter-tips-block ${d === e ? "show-tips" : ""}`,
|
|
@@ -96,7 +102,7 @@ function W({
|
|
|
96
102
|
)) }) : ""
|
|
97
103
|
] });
|
|
98
104
|
}
|
|
99
|
-
|
|
105
|
+
B.propTypes = {
|
|
100
106
|
animationData: n.oneOfType([n.object, n.oneOf([null])]),
|
|
101
107
|
size: n.oneOfType([n.number, n.string]),
|
|
102
108
|
message: n.oneOfType([n.string, n.arrayOf(n.node)]),
|
|
@@ -108,7 +114,7 @@ W.propTypes = {
|
|
|
108
114
|
maybeDuration: n.number,
|
|
109
115
|
increaseSpeed: n.number
|
|
110
116
|
};
|
|
111
|
-
const
|
|
117
|
+
const G = W("div")`
|
|
112
118
|
display: flex;
|
|
113
119
|
justify-content: center;
|
|
114
120
|
align-items: center;
|
|
@@ -179,5 +185,5 @@ const q = R("div")`
|
|
|
179
185
|
}
|
|
180
186
|
`;
|
|
181
187
|
export {
|
|
182
|
-
|
|
188
|
+
B as default
|
|
183
189
|
};
|
package/lib/Theme/theme.js
CHANGED
|
@@ -1,64 +1,64 @@
|
|
|
1
|
-
import { createTheme as
|
|
2
|
-
import
|
|
3
|
-
import { DEFAULT_FONTS as
|
|
1
|
+
import { createTheme as f, responsiveFontSizes as A } from "@mui/material";
|
|
2
|
+
import _ from "webfontloader";
|
|
3
|
+
import { DEFAULT_FONTS as b, getDefaultThemePrefer as C, mergeThemeOptions as d, getBlockletThemeOptions as h, mergeAllThemeOptions as k, BLOCKLET_THEME_DARK as x, BLOCKLET_THEME_LIGHT as E } from "@blocklet/theme";
|
|
4
4
|
import { mergeThemeOptions as Q, mergeAllThemeOptions as V } from "@blocklet/theme";
|
|
5
|
-
import { cleanedObj as
|
|
5
|
+
import { cleanedObj as m } from "../Util/index.js";
|
|
6
6
|
import "@fontsource/roboto/latin-400.css";
|
|
7
7
|
import "@fontsource/roboto/latin-500.css";
|
|
8
8
|
import "@fontsource/roboto/latin-700.css";
|
|
9
9
|
import "@fontsource/roboto/latin-ext-400.css";
|
|
10
10
|
import "@fontsource/roboto/latin-ext-500.css";
|
|
11
11
|
import "@fontsource/roboto/latin-ext-700.css";
|
|
12
|
-
function
|
|
12
|
+
function D(e) {
|
|
13
13
|
return e && typeof e == "object" && e.palette && typeof e.palette.getContrastText == "function";
|
|
14
14
|
}
|
|
15
15
|
function R(e) {
|
|
16
|
-
return
|
|
16
|
+
return D(e) && e.__isUxTheme__ === !0;
|
|
17
17
|
}
|
|
18
|
-
function
|
|
18
|
+
function u(e, t = /* @__PURE__ */ new Set()) {
|
|
19
19
|
return !e || typeof e != "object" || (typeof e.fontFamily == "string" && e.fontFamily.replace(/"/g, "").split(",").map((o) => o.trim()).filter(Boolean).forEach((o) => t.add(o)), Object.values(e).forEach((o) => {
|
|
20
|
-
typeof o == "object" &&
|
|
20
|
+
typeof o == "object" && u(o, t);
|
|
21
21
|
})), t;
|
|
22
22
|
}
|
|
23
|
-
const
|
|
24
|
-
function
|
|
25
|
-
const t = e.filter((
|
|
23
|
+
const a = new Set(b.concat("inherit"));
|
|
24
|
+
function w(e) {
|
|
25
|
+
const t = e.filter((r) => !a.has(r));
|
|
26
26
|
if (t.length === 0)
|
|
27
27
|
return Promise.resolve(!0);
|
|
28
|
-
t.forEach((
|
|
28
|
+
t.forEach((r) => a.add(r));
|
|
29
29
|
const o = t.length - 1;
|
|
30
|
-
return t[o] = `${t[o]}&display=swap`, new Promise((
|
|
31
|
-
|
|
30
|
+
return t[o] = `${t[o]}&display=swap`, new Promise((r) => {
|
|
31
|
+
_.load({
|
|
32
32
|
google: {
|
|
33
33
|
families: t
|
|
34
34
|
},
|
|
35
|
-
active: () =>
|
|
36
|
-
inactive: () =>
|
|
37
|
-
fontinactive: (
|
|
38
|
-
|
|
35
|
+
active: () => r(!0),
|
|
36
|
+
inactive: () => r(!0),
|
|
37
|
+
fontinactive: (n, i) => {
|
|
38
|
+
a.delete(n), console.warn(`font ${n} ${i} download failed`);
|
|
39
39
|
}
|
|
40
40
|
});
|
|
41
41
|
});
|
|
42
42
|
}
|
|
43
|
-
function
|
|
44
|
-
return e === "dark" ?
|
|
43
|
+
function T(e = "light") {
|
|
44
|
+
return e === "dark" ? x : E;
|
|
45
45
|
}
|
|
46
|
-
function
|
|
46
|
+
function v(e) {
|
|
47
47
|
let t = null;
|
|
48
48
|
return () => {
|
|
49
49
|
if (t) return t;
|
|
50
|
-
const o =
|
|
51
|
-
return t =
|
|
50
|
+
const o = d(T(e), h(e));
|
|
51
|
+
return t = f(o), t;
|
|
52
52
|
};
|
|
53
53
|
}
|
|
54
|
-
const
|
|
54
|
+
const p = ({ palette: e, components: t, overrides: o, ...r }) => ({
|
|
55
55
|
palette: e,
|
|
56
56
|
components: {
|
|
57
57
|
...o,
|
|
58
58
|
...t
|
|
59
59
|
},
|
|
60
|
-
...
|
|
61
|
-
}),
|
|
60
|
+
...r
|
|
61
|
+
}), L = {
|
|
62
62
|
themeName: "ArcBlock",
|
|
63
63
|
pageWidth: "md",
|
|
64
64
|
disableBlockletTheme: !1,
|
|
@@ -83,25 +83,24 @@ const m = ({ palette: e, components: t, overrides: o, ...n }) => ({
|
|
|
83
83
|
danger: "#D0021B",
|
|
84
84
|
lightGrey: "#BCBCBC"
|
|
85
85
|
}
|
|
86
|
-
},
|
|
87
|
-
const t =
|
|
88
|
-
(
|
|
89
|
-
|
|
90
|
-
),
|
|
86
|
+
}, U = (...e) => {
|
|
87
|
+
const t = C(), o = v(t), r = e.reduce(
|
|
88
|
+
(O, s) => d(O, p(typeof s == "function" ? s(o()) : s)),
|
|
89
|
+
p(L)
|
|
90
|
+
), n = r.mode || r.palette?.mode || t, i = h(n), g = T(n), { disableBlockletTheme: F } = r, y = k(
|
|
91
91
|
[
|
|
92
|
-
|
|
93
|
-
!
|
|
94
|
-
|
|
92
|
+
g,
|
|
93
|
+
!F && m(i),
|
|
94
|
+
m(r),
|
|
95
95
|
// 确保 mode 跟 prefer 一致
|
|
96
96
|
{
|
|
97
|
-
mode:
|
|
98
|
-
palette: { mode:
|
|
97
|
+
mode: n,
|
|
98
|
+
palette: { mode: n }
|
|
99
99
|
}
|
|
100
100
|
].filter(Boolean)
|
|
101
|
-
),
|
|
102
|
-
|
|
103
|
-
const
|
|
104
|
-
return D(Array.from(y)), O(s, {
|
|
101
|
+
), l = f(y);
|
|
102
|
+
l.__isUxTheme__ = !0;
|
|
103
|
+
const c = A(l, {
|
|
105
104
|
breakpoints: ["xs", "sm", "md", "lg"],
|
|
106
105
|
disableAlign: !1,
|
|
107
106
|
factor: 3,
|
|
@@ -120,17 +119,18 @@ const m = ({ palette: e, components: t, overrides: o, ...n }) => ({
|
|
|
120
119
|
"button",
|
|
121
120
|
"overline"
|
|
122
121
|
]
|
|
123
|
-
});
|
|
124
|
-
|
|
122
|
+
}), B = u(c.typography);
|
|
123
|
+
return w(Array.from(B)), c;
|
|
124
|
+
}, W = U;
|
|
125
125
|
export {
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
126
|
+
u as collectFontFamilies,
|
|
127
|
+
U as create,
|
|
128
|
+
T as createDefaultThemeOptions,
|
|
129
129
|
W as createTheme,
|
|
130
130
|
Q as deepmerge,
|
|
131
131
|
V as deepmergeAll,
|
|
132
|
-
|
|
132
|
+
D as isTheme,
|
|
133
133
|
R as isUxTheme,
|
|
134
|
-
|
|
135
|
-
|
|
134
|
+
v as lazyCreateDefaultTheme,
|
|
135
|
+
w as loadFonts
|
|
136
136
|
};
|
package/lib/Util/logger.js
CHANGED
|
@@ -1,18 +1,21 @@
|
|
|
1
1
|
import n from "debug";
|
|
2
|
-
const
|
|
2
|
+
const d = n;
|
|
3
|
+
let t = !1;
|
|
4
|
+
const u = () => {
|
|
5
|
+
t || (t = !0, window.blocklet?.ENABLE_DEBUG_TMP === "false" ? n.disable() : window.blocklet?.ENABLE_DEBUG_TMP && n.enable(window.blocklet?.ENABLE_DEBUG_TMP));
|
|
6
|
+
}, b = (i) => (u(), new Proxy(window.console, {
|
|
3
7
|
get(r, e) {
|
|
4
|
-
return (...
|
|
8
|
+
return (...o) => {
|
|
5
9
|
try {
|
|
6
|
-
return ["log", "debug", "info", "warn", "error"].includes(e) ? r[e](
|
|
10
|
+
return ["log", "debug", "info", "warn", "error"].includes(e) ? r[e](i, ...o) : r[e] instanceof Function ? r[e](...o) : r[e];
|
|
7
11
|
} catch (l) {
|
|
8
|
-
console.error(`Logger error in ${
|
|
12
|
+
console.error(`Logger error in ${i}:`, l);
|
|
9
13
|
return;
|
|
10
14
|
}
|
|
11
15
|
};
|
|
12
16
|
}
|
|
13
|
-
});
|
|
14
|
-
window.blocklet?.ENABLE_DEBUG_TMP === "false" ? n.disable() : window.blocklet?.ENABLE_DEBUG_TMP && n.enable(window.blocklet?.ENABLE_DEBUG_TMP);
|
|
17
|
+
}));
|
|
15
18
|
export {
|
|
16
|
-
|
|
17
|
-
|
|
19
|
+
d as createDebug,
|
|
20
|
+
b as createLogger
|
|
18
21
|
};
|
package/lib/hooks/use-clock.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { useCallback as p, useState as l, useEffect as d } from "react";
|
|
2
2
|
import e from "dayjs";
|
|
3
|
+
import "dayjs/locale/zh-cn";
|
|
4
|
+
import "dayjs/locale/en";
|
|
3
5
|
import h from "dayjs/plugin/utc";
|
|
4
6
|
import T from "dayjs/plugin/timezone";
|
|
5
7
|
import z from "dayjs/plugin/localizedFormat";
|
|
6
|
-
import "dayjs/locale/zh-cn";
|
|
7
|
-
import "dayjs/locale/en";
|
|
8
8
|
import { formatToDatetime as I } from "../Util/index.js";
|
|
9
9
|
e.extend(h);
|
|
10
10
|
e.extend(T);
|
package/lib/package.json.js
CHANGED
package/lib/withTracker/index.js
CHANGED
|
@@ -1,26 +1,28 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { useLocation as
|
|
3
|
-
import { useMount as
|
|
4
|
-
import
|
|
5
|
-
import { default as
|
|
1
|
+
import { jsx as f } from "react/jsx-runtime";
|
|
2
|
+
import { useLocation as u } from "react-router-dom";
|
|
3
|
+
import { useMount as l, useDeepCompareEffect as d } from "ahooks";
|
|
4
|
+
import i from "react-ga4";
|
|
5
|
+
import { default as E } from "react-ga4";
|
|
6
6
|
import { googleAnalyticsMeasurementId as n } from "./env.js";
|
|
7
|
-
|
|
8
|
-
const
|
|
7
|
+
let r = !1;
|
|
8
|
+
const c = () => {
|
|
9
|
+
n && !r && (i.initialize(n), r = !0);
|
|
10
|
+
}, x = (m) => {
|
|
9
11
|
const a = (o, t = document.title) => {
|
|
10
|
-
n &&
|
|
11
|
-
},
|
|
12
|
-
n &&
|
|
12
|
+
c(), n && i.send({ hitType: "pageview", page: o, title: t });
|
|
13
|
+
}, s = (o, t, e, p) => {
|
|
14
|
+
c(), n && i.event({ category: o, action: t, label: e, value: p, transport: "beacon" });
|
|
13
15
|
};
|
|
14
|
-
return window.trackPage = a, window.trackEvent =
|
|
15
|
-
const e =
|
|
16
|
-
return
|
|
16
|
+
return window.trackPage = a, window.trackEvent = s, function(t) {
|
|
17
|
+
const e = u();
|
|
18
|
+
return l(() => {
|
|
17
19
|
a(e.pathname);
|
|
18
|
-
}),
|
|
20
|
+
}), d(() => {
|
|
19
21
|
a(e.pathname);
|
|
20
|
-
}, [e.pathname]), /* @__PURE__ */
|
|
22
|
+
}, [e.pathname]), /* @__PURE__ */ f(m, { ...t });
|
|
21
23
|
};
|
|
22
24
|
};
|
|
23
25
|
export {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
+
E as ReactGA,
|
|
27
|
+
x as default
|
|
26
28
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@arcblock/ux",
|
|
3
|
-
"version": "3.4.
|
|
3
|
+
"version": "3.4.7",
|
|
4
4
|
"description": "Common used react components for arcblock products",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -30,6 +30,12 @@
|
|
|
30
30
|
"bugs": {
|
|
31
31
|
"url": "https://github.com/ArcBlock/ux/issues"
|
|
32
32
|
},
|
|
33
|
+
"sideEffects": [
|
|
34
|
+
"**/*.css",
|
|
35
|
+
"**/*.scss",
|
|
36
|
+
"**/*.svg?react",
|
|
37
|
+
"**/*.svg"
|
|
38
|
+
],
|
|
33
39
|
"publishConfig": {
|
|
34
40
|
"access": "public"
|
|
35
41
|
},
|
|
@@ -68,16 +74,16 @@
|
|
|
68
74
|
"react": "^19.0.0",
|
|
69
75
|
"react-router-dom": "^6.22.3"
|
|
70
76
|
},
|
|
71
|
-
"gitHead": "
|
|
77
|
+
"gitHead": "eb0fca0015ba4ee80affb3b03d47505c45f8ec1c",
|
|
72
78
|
"dependencies": {
|
|
73
|
-
"@arcblock/bridge": "3.4.
|
|
74
|
-
"@arcblock/did": "^1.28.
|
|
79
|
+
"@arcblock/bridge": "3.4.7",
|
|
80
|
+
"@arcblock/did": "^1.28.5",
|
|
75
81
|
"@arcblock/did-motif": "^1.1.14",
|
|
76
|
-
"@arcblock/icons": "3.4.
|
|
77
|
-
"@arcblock/nft-display": "3.4.
|
|
78
|
-
"@arcblock/react-hooks": "3.4.
|
|
82
|
+
"@arcblock/icons": "3.4.7",
|
|
83
|
+
"@arcblock/nft-display": "3.4.7",
|
|
84
|
+
"@arcblock/react-hooks": "3.4.7",
|
|
79
85
|
"@blocklet/js-sdk": "^1.17.7",
|
|
80
|
-
"@blocklet/theme": "3.4.
|
|
86
|
+
"@blocklet/theme": "3.4.7",
|
|
81
87
|
"@fontsource/roboto": "~5.1.1",
|
|
82
88
|
"@fontsource/ubuntu-mono": "^5.2.6",
|
|
83
89
|
"@iconify-icons/logos": "^1.2.36",
|
|
@@ -85,7 +91,7 @@
|
|
|
85
91
|
"@iconify-icons/mdi": "^1.2.48",
|
|
86
92
|
"@iconify-icons/tabler": "^1.2.95",
|
|
87
93
|
"@iconify/react": "^5.2.1",
|
|
88
|
-
"@ocap/mcrypto": "^1.28.
|
|
94
|
+
"@ocap/mcrypto": "^1.28.5",
|
|
89
95
|
"@solana/qr-code-styling": "^1.6.0",
|
|
90
96
|
"@types/dompurify": "^3.2.0",
|
|
91
97
|
"@types/mui-datatables": "^4.3.12",
|
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
import { useState, useEffect, useRef } from 'react';
|
|
1
|
+
import { lazy, Suspense, useState, useEffect, useRef } from 'react';
|
|
2
2
|
import { Skeleton } from '@mui/material';
|
|
3
3
|
|
|
4
4
|
import PropTypes from 'prop-types';
|
|
5
|
-
import Lottie from 'react-lottie-player';
|
|
6
5
|
import noop from 'lodash/noop';
|
|
7
6
|
|
|
8
7
|
import { styled, useTheme } from '../Theme';
|
|
9
8
|
|
|
9
|
+
const Lottie = lazy(() => import('react-lottie-player'));
|
|
10
|
+
|
|
10
11
|
/**
|
|
11
12
|
* 用于长时间等待的用的动画组件
|
|
12
13
|
* 动画会随着时间的变化而逐步加快播放速度,好适应用户的等待心理
|
|
@@ -147,24 +148,33 @@ export default function AnimationWaiter({
|
|
|
147
148
|
return className;
|
|
148
149
|
};
|
|
149
150
|
|
|
151
|
+
const fallback = (
|
|
152
|
+
<div style={{ width: size, height: size, display: 'flex', justifyContent: 'center', alignItems: 'center' }}>
|
|
153
|
+
<Skeleton variant="rounded" width={size * 0.4} height={size * 0.4} />
|
|
154
|
+
</div>
|
|
155
|
+
);
|
|
156
|
+
|
|
150
157
|
return (
|
|
151
158
|
<Container {...rest}>
|
|
152
159
|
{isLoading ? (
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
</div>
|
|
160
|
+
// 当正在加载默认动画时直接展示 fallback
|
|
161
|
+
fallback
|
|
156
162
|
) : (
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
163
|
+
// 否则使用 Suspense 包裹懒加载的 Lottie,Suspense 会在 Lottie 本身未加载完成时展示 fallback
|
|
164
|
+
<Suspense fallback={fallback}>
|
|
165
|
+
<Lottie
|
|
166
|
+
loop
|
|
167
|
+
animationData={animationData || defaultAnimation}
|
|
168
|
+
play
|
|
169
|
+
speed={currentSpeed}
|
|
170
|
+
style={{
|
|
171
|
+
width: size,
|
|
172
|
+
height: size,
|
|
173
|
+
}}
|
|
174
|
+
/>
|
|
175
|
+
</Suspense>
|
|
167
176
|
)}
|
|
177
|
+
|
|
168
178
|
{message && (
|
|
169
179
|
<div className="waiter-message">
|
|
170
180
|
{message.map((text, index) => {
|
package/src/Theme/theme.ts
CHANGED
|
@@ -186,10 +186,6 @@ export const create = (...args: Array<UxThemeOptions | ((baseTheme: Theme) => Ux
|
|
|
186
186
|
const theme = _createTheme(mergedThemeOptions);
|
|
187
187
|
theme.__isUxTheme__ = true;
|
|
188
188
|
|
|
189
|
-
// 异步加载字体
|
|
190
|
-
const fonts = collectFontFamilies(theme.typography);
|
|
191
|
-
loadFonts(Array.from(fonts));
|
|
192
|
-
|
|
193
189
|
/**
|
|
194
190
|
* 支持响应式字体,theme.typography.$variant 中会添加 @media 分支,比如
|
|
195
191
|
* {
|
|
@@ -222,6 +218,10 @@ export const create = (...args: Array<UxThemeOptions | ((baseTheme: Theme) => Ux
|
|
|
222
218
|
],
|
|
223
219
|
});
|
|
224
220
|
|
|
221
|
+
// 异步加载字体
|
|
222
|
+
const fonts = collectFontFamilies(enhanced.typography);
|
|
223
|
+
loadFonts(Array.from(fonts));
|
|
224
|
+
|
|
225
225
|
return enhanced;
|
|
226
226
|
};
|
|
227
227
|
|
package/src/Util/logger.ts
CHANGED
|
@@ -3,7 +3,24 @@ import debug from 'debug';
|
|
|
3
3
|
|
|
4
4
|
export const createDebug = debug;
|
|
5
5
|
|
|
6
|
+
let debugInitialized = false;
|
|
7
|
+
|
|
8
|
+
const initializeDebug = () => {
|
|
9
|
+
if (debugInitialized) {
|
|
10
|
+
return;
|
|
11
|
+
}
|
|
12
|
+
debugInitialized = true;
|
|
13
|
+
|
|
14
|
+
if (window.blocklet?.ENABLE_DEBUG_TMP === 'false') {
|
|
15
|
+
debug.disable();
|
|
16
|
+
} else if (window.blocklet?.ENABLE_DEBUG_TMP) {
|
|
17
|
+
debug.enable(window.blocklet?.ENABLE_DEBUG_TMP);
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
|
|
6
21
|
export const createLogger = (namespace: string) => {
|
|
22
|
+
initializeDebug();
|
|
23
|
+
|
|
7
24
|
return new Proxy(window.console, {
|
|
8
25
|
get(target, prop: keyof Console) {
|
|
9
26
|
return (...args: any[]) => {
|
|
@@ -25,9 +42,3 @@ export const createLogger = (namespace: string) => {
|
|
|
25
42
|
},
|
|
26
43
|
});
|
|
27
44
|
};
|
|
28
|
-
|
|
29
|
-
if (window.blocklet?.ENABLE_DEBUG_TMP === 'false') {
|
|
30
|
-
debug.disable();
|
|
31
|
-
} else if (window.blocklet?.ENABLE_DEBUG_TMP) {
|
|
32
|
-
debug.enable(window.blocklet?.ENABLE_DEBUG_TMP);
|
|
33
|
-
}
|
package/src/hooks/use-clock.tsx
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { useState, useEffect, useCallback } from 'react';
|
|
2
2
|
import dayjs from 'dayjs';
|
|
3
|
+
import 'dayjs/locale/zh-cn';
|
|
4
|
+
import 'dayjs/locale/en';
|
|
3
5
|
import utc from 'dayjs/plugin/utc';
|
|
4
6
|
import timezonePlugin from 'dayjs/plugin/timezone';
|
|
5
7
|
import localizedFormat from 'dayjs/plugin/localizedFormat';
|
|
6
|
-
import 'dayjs/locale/zh-cn';
|
|
7
|
-
import 'dayjs/locale/en';
|
|
8
8
|
|
|
9
9
|
import { formatToDatetime } from '../Util';
|
|
10
10
|
|
|
@@ -3,19 +3,27 @@ import { useMount, useDeepCompareEffect } from 'ahooks';
|
|
|
3
3
|
import ReactGA from 'react-ga4';
|
|
4
4
|
import { googleAnalyticsMeasurementId } from './env';
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
let isInitialized = false;
|
|
7
|
+
|
|
8
|
+
const initializeGA = () => {
|
|
9
|
+
if (googleAnalyticsMeasurementId && !isInitialized) {
|
|
10
|
+
ReactGA.initialize(googleAnalyticsMeasurementId);
|
|
11
|
+
isInitialized = true;
|
|
12
|
+
}
|
|
13
|
+
};
|
|
9
14
|
|
|
10
15
|
export { ReactGA };
|
|
16
|
+
|
|
11
17
|
export default <P extends object>(WrappedComponent: React.ComponentType<P>) => {
|
|
12
18
|
const trackPage = (page: string, title = document.title) => {
|
|
19
|
+
initializeGA();
|
|
13
20
|
if (googleAnalyticsMeasurementId) {
|
|
14
21
|
ReactGA.send({ hitType: 'pageview', page, title });
|
|
15
22
|
}
|
|
16
23
|
};
|
|
17
24
|
|
|
18
25
|
const trackEvent = (category: string, action: string, label: string, value: number) => {
|
|
26
|
+
initializeGA();
|
|
19
27
|
if (googleAnalyticsMeasurementId) {
|
|
20
28
|
ReactGA.event({ category, action, label, value, transport: 'beacon' });
|
|
21
29
|
}
|