@blocklet/ui-react 3.0.38 → 3.0.41
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/Dashboard/index.js +52 -53
- package/lib/Footer/links.js +4 -3
- package/lib/Header/index.d.ts +0 -1
- package/lib/Header/index.js +96 -86
- package/lib/common/header-addons.d.ts +1 -3
- package/lib/common/header-addons.js +51 -112
- package/lib/common/wizard-modal.d.ts +3 -1
- package/lib/common/wizard-modal.js +61 -52
- package/package.json +5 -5
- package/src/Dashboard/index.jsx +0 -1
- package/src/Footer/Footer.stories.jsx +2 -1
- package/src/Footer/links.jsx +1 -0
- package/src/Header/index.tsx +32 -9
- package/src/common/header-addons.jsx +8 -78
- package/src/common/wizard-modal.jsx +12 -3
- package/src/common/wizard-example.md +0 -168
|
@@ -1,132 +1,71 @@
|
|
|
1
|
-
import { jsx as
|
|
1
|
+
import { jsx as s, Fragment as v } from "react/jsx-runtime";
|
|
2
2
|
import "iconify-icon";
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
6
|
-
import
|
|
7
|
-
import {
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
import {
|
|
12
|
-
import
|
|
13
|
-
import
|
|
14
|
-
import
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
addons: i = null,
|
|
22
|
-
showDomainWarningDialog: y = !0,
|
|
23
|
-
sessionManagerProps: w = { showRole: !0 },
|
|
24
|
-
showWizard: T = !1
|
|
3
|
+
import r from "prop-types";
|
|
4
|
+
import { use as b, createElement as k } from "react";
|
|
5
|
+
import { SessionContext as w } from "@arcblock/did-connect/lib/Session";
|
|
6
|
+
import L from "@arcblock/ux/lib/Config/theme-mode-toggle";
|
|
7
|
+
import { useLocaleContext as N } from "@arcblock/ux/lib/Locale/context";
|
|
8
|
+
import T from "@arcblock/ux/lib/Locale/selector";
|
|
9
|
+
import C from "@arcblock/ux/lib/SessionBlocklet";
|
|
10
|
+
import R from "@arcblock/ux/lib/SessionUser";
|
|
11
|
+
import { getLocalizedNavigation as S, filterNavByRole as M } from "../blocklets.js";
|
|
12
|
+
import { SessionManagerProps as B } from "../types.js";
|
|
13
|
+
import D from "./domain-warning.js";
|
|
14
|
+
import P from "./notification-addon.js";
|
|
15
|
+
const j = () => !!(window?.blocklet?.navigation ?? []).find((o) => o.id === "/userCenter/notification");
|
|
16
|
+
function x({
|
|
17
|
+
formattedBlocklet: l,
|
|
18
|
+
addons: o = null,
|
|
19
|
+
showDomainWarningDialog: m = !0,
|
|
20
|
+
sessionManagerProps: u = { showRole: !0 }
|
|
25
21
|
}) {
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
if (i && typeof i != "function")
|
|
40
|
-
return Array.isArray(i) ? i : [i];
|
|
41
|
-
let o = [];
|
|
42
|
-
if ($() && o.push(/* @__PURE__ */ e(H, { session: n.session }, "notification-addon")), k && r && z.length > 1 && o.push(/* @__PURE__ */ e(P, { showText: !1 }, "locale-selector")), o.push(/* @__PURE__ */ e(j, {}, "theme-mode-toggle")), T && o.push(
|
|
43
|
-
/* @__PURE__ */ e(
|
|
44
|
-
M,
|
|
45
|
-
{
|
|
46
|
-
title: b("setup.wizardTooltip"),
|
|
47
|
-
open: t,
|
|
48
|
-
placement: "bottom",
|
|
49
|
-
arrow: !0,
|
|
50
|
-
children: /* @__PURE__ */ e(
|
|
51
|
-
R,
|
|
52
|
-
{
|
|
53
|
-
size: "small",
|
|
54
|
-
onClick: () => {
|
|
55
|
-
p(!0), c(!1);
|
|
56
|
-
},
|
|
57
|
-
sx: {
|
|
58
|
-
display: { xs: "none", md: "flex" },
|
|
59
|
-
color: "text.secondary",
|
|
60
|
-
...t && {
|
|
61
|
-
backgroundColor: "action.hover",
|
|
62
|
-
"@keyframes pulse": {
|
|
63
|
-
"0%": { opacity: 0.8 },
|
|
64
|
-
"50%": { opacity: 0.5 },
|
|
65
|
-
"100%": { opacity: 0.8 }
|
|
66
|
-
},
|
|
67
|
-
animation: "pulse 2s infinite"
|
|
68
|
-
}
|
|
69
|
-
},
|
|
70
|
-
children: /* @__PURE__ */ e("iconify-icon", { icon: B, height: 20 })
|
|
71
|
-
}
|
|
72
|
-
)
|
|
73
|
-
},
|
|
74
|
-
`wizard-toggle-${t}`
|
|
75
|
-
),
|
|
76
|
-
/* @__PURE__ */ e(
|
|
77
|
-
V,
|
|
78
|
-
{
|
|
79
|
-
show: d,
|
|
80
|
-
onChangeVisible: (a) => {
|
|
81
|
-
p(a), !a && d && c(!0);
|
|
82
|
-
},
|
|
83
|
-
onFinished: () => {
|
|
84
|
-
p(!1), c(!1);
|
|
85
|
-
}
|
|
86
|
-
},
|
|
87
|
-
"wizard-modal"
|
|
88
|
-
)
|
|
89
|
-
), A && n) {
|
|
90
|
-
const a = [];
|
|
91
|
-
v && (f ? f.slice(0, 5) : []).forEach((l) => {
|
|
92
|
-
a.push({
|
|
93
|
-
label: l.title,
|
|
94
|
-
icon: l.icon ? /* @__PURE__ */ e("iconify-icon", { icon: l.icon, height: 24, style: { marginRight: 8 } }) : null,
|
|
22
|
+
const n = b(w), { locale: i, languages: p } = N() || {}, { enableConnect: g = !0, enableLocale: d = !0 } = l, h = !!n?.session?.user;
|
|
23
|
+
let a = S(l?.navigation?.sessionManager, i) || [];
|
|
24
|
+
a = M(a, n?.session?.user?.role);
|
|
25
|
+
const c = (() => {
|
|
26
|
+
if (o && typeof o != "function")
|
|
27
|
+
return Array.isArray(o) ? o : [o];
|
|
28
|
+
let e = [];
|
|
29
|
+
if (j() && e.push(/* @__PURE__ */ s(P, { session: n.session }, "notification-addon")), d && i && p.length > 1 && e.push(/* @__PURE__ */ s(T, { showText: !1 }, "locale-selector")), e.push(/* @__PURE__ */ s(L, {}, "theme-mode-toggle")), g && n) {
|
|
30
|
+
const f = [];
|
|
31
|
+
h && (a ? a.slice(0, 5) : []).forEach((t) => {
|
|
32
|
+
f.push({
|
|
33
|
+
label: t.title,
|
|
34
|
+
icon: t.icon ? /* @__PURE__ */ s("iconify-icon", { icon: t.icon, height: 24, style: { marginRight: 8 } }) : null,
|
|
95
35
|
component: "a",
|
|
96
|
-
href:
|
|
97
|
-
key:
|
|
36
|
+
href: t.link,
|
|
37
|
+
key: t.link
|
|
98
38
|
});
|
|
99
|
-
}),
|
|
100
|
-
/* @__PURE__ */
|
|
101
|
-
|
|
39
|
+
}), e.push(/* @__PURE__ */ s(C, { session: n.session, locale: i }, "session-blocklet")), e.push(
|
|
40
|
+
/* @__PURE__ */ s(
|
|
41
|
+
R,
|
|
102
42
|
{
|
|
103
43
|
session: n.session,
|
|
104
|
-
locale:
|
|
105
|
-
menu:
|
|
44
|
+
locale: i,
|
|
45
|
+
menu: f,
|
|
106
46
|
showRole: !0,
|
|
107
|
-
...
|
|
47
|
+
...u
|
|
108
48
|
},
|
|
109
49
|
"session-user"
|
|
110
50
|
)
|
|
111
51
|
);
|
|
112
52
|
}
|
|
113
|
-
return typeof
|
|
114
|
-
})(),
|
|
115
|
-
|
|
116
|
-
...
|
|
53
|
+
return typeof o == "function" && (e = o(e) || []), e;
|
|
54
|
+
})(), y = Array.isArray(c) ? c : [c], A = [
|
|
55
|
+
m ? /* @__PURE__ */ s(D, { session: n?.session, locale: i }) : null,
|
|
56
|
+
...y
|
|
117
57
|
].filter(Boolean);
|
|
118
|
-
return
|
|
58
|
+
return k(v, null, ...A);
|
|
119
59
|
}
|
|
120
|
-
|
|
121
|
-
formattedBlocklet:
|
|
60
|
+
x.propTypes = {
|
|
61
|
+
formattedBlocklet: r.object.isRequired,
|
|
122
62
|
// 需要考虑 定制的 addons 与内置的 连接钱包/选择语言 addons 共存的情况
|
|
123
63
|
// - PropTypes.func: 可以把自定义 addons 插在 session-manager 或 locale-selector (如果存在的话) 前/中/后
|
|
124
64
|
// - PropTypes.node: 将 addons 原样传给 UX Header 组件
|
|
125
|
-
addons:
|
|
126
|
-
sessionManagerProps:
|
|
127
|
-
showDomainWarningDialog:
|
|
128
|
-
showWizard: s.bool
|
|
65
|
+
addons: r.oneOfType([r.func, r.node]),
|
|
66
|
+
sessionManagerProps: B,
|
|
67
|
+
showDomainWarningDialog: r.bool
|
|
129
68
|
};
|
|
130
69
|
export {
|
|
131
|
-
|
|
70
|
+
x as default
|
|
132
71
|
};
|
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
import { default as PropTypes } from 'prop-types';
|
|
2
|
-
declare function WizardModal({ onFinished, show, onChangeVisible }: {
|
|
2
|
+
declare function WizardModal({ onFinished, show, onChangeVisible, loadingText, }: {
|
|
3
3
|
onFinished?: (() => void) | undefined;
|
|
4
4
|
show?: boolean | undefined;
|
|
5
5
|
onChangeVisible?: (() => void) | undefined;
|
|
6
|
+
loadingText?: string | undefined;
|
|
6
7
|
}): import("react/jsx-runtime").JSX.Element | null;
|
|
7
8
|
declare namespace WizardModal {
|
|
8
9
|
namespace propTypes {
|
|
9
10
|
let onFinished: PropTypes.Requireable<(...args: any[]) => any>;
|
|
10
11
|
let show: PropTypes.Requireable<boolean>;
|
|
11
12
|
let onChangeVisible: PropTypes.Requireable<(...args: any[]) => any>;
|
|
13
|
+
let loadingText: PropTypes.Requireable<PropTypes.ReactNodeLike>;
|
|
12
14
|
}
|
|
13
15
|
}
|
|
14
16
|
export default WizardModal;
|
|
@@ -1,46 +1,51 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { useLocaleContext as
|
|
3
|
-
import { useTheme as
|
|
4
|
-
import
|
|
5
|
-
import { useState as
|
|
6
|
-
import { withQuery as
|
|
7
|
-
const
|
|
8
|
-
function
|
|
9
|
-
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
1
|
+
import { jsxs as x, jsx as i } from "react/jsx-runtime";
|
|
2
|
+
import { useLocaleContext as P } from "@arcblock/ux/lib/Locale/context";
|
|
3
|
+
import { useTheme as T, useMediaQuery as j, Dialog as D, Box as R, CircularProgress as E, Typography as M } from "@mui/material";
|
|
4
|
+
import a from "prop-types";
|
|
5
|
+
import { useState as g, useRef as h, useEffect as s } from "react";
|
|
6
|
+
import { withQuery as A, joinURL as F } from "ufo";
|
|
7
|
+
const b = "/.well-known/service/wizard/bind-account";
|
|
8
|
+
function B({
|
|
9
|
+
onFinished: y = () => {
|
|
10
|
+
},
|
|
11
|
+
show: o = !1,
|
|
12
|
+
onChangeVisible: v = () => {
|
|
13
|
+
},
|
|
14
|
+
loadingText: l = ""
|
|
15
|
+
}) {
|
|
16
|
+
const [r, n] = g(o), [c, d] = g(!1), [C, u] = g(() => localStorage.getItem("wizard-current-url") || b), z = h(y), f = h(), m = h(null), { locale: I } = P(), L = T(), p = j(L.breakpoints.down("sm"));
|
|
17
|
+
if (z.current = y, f.current = () => {
|
|
18
|
+
if (m.current?.contentWindow)
|
|
14
19
|
try {
|
|
15
|
-
const t = new URL(
|
|
16
|
-
localStorage.setItem("wizard-current-url", t),
|
|
20
|
+
const t = new URL(m.current.contentWindow.location.href).pathname;
|
|
21
|
+
localStorage.setItem("wizard-current-url", t), u(t);
|
|
17
22
|
} catch (e) {
|
|
18
|
-
|
|
23
|
+
u(b), console.warn("Failed to save wizard URL:", e);
|
|
19
24
|
}
|
|
20
|
-
localStorage.setItem("wizard-completed", "true"), n(!1),
|
|
21
|
-
},
|
|
25
|
+
localStorage.setItem("wizard-completed", "true"), n(!1), v(!1);
|
|
26
|
+
}, s(() => {
|
|
22
27
|
o !== r && n(o);
|
|
23
|
-
}, [o]),
|
|
24
|
-
!r &&
|
|
25
|
-
}, [r]),
|
|
28
|
+
}, [o]), s(() => {
|
|
29
|
+
!r && c && d(!1);
|
|
30
|
+
}, [r]), s(() => {
|
|
26
31
|
const e = (t) => {
|
|
27
32
|
if (t.origin !== window.location.origin)
|
|
28
33
|
return;
|
|
29
|
-
const { type:
|
|
30
|
-
switch (
|
|
34
|
+
const { type: k, data: U } = t.data || {};
|
|
35
|
+
switch (k) {
|
|
31
36
|
case "wizard.loaded":
|
|
32
|
-
|
|
37
|
+
d(!0);
|
|
33
38
|
break;
|
|
34
39
|
case "wizard.finished": {
|
|
35
|
-
n(!1),
|
|
36
|
-
const
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
}) :
|
|
40
|
+
n(!1), u(b), localStorage.removeItem("wizard-current-url"), localStorage.setItem("wizard-completed", "true");
|
|
41
|
+
const w = z.current?.(U);
|
|
42
|
+
w instanceof Promise ? w.then((W) => {
|
|
43
|
+
W !== !1 && window.location.reload();
|
|
44
|
+
}) : w !== !1 && window.location.reload();
|
|
40
45
|
break;
|
|
41
46
|
}
|
|
42
47
|
case "wizard.close": {
|
|
43
|
-
|
|
48
|
+
f.current();
|
|
44
49
|
break;
|
|
45
50
|
}
|
|
46
51
|
}
|
|
@@ -48,21 +53,21 @@ function D({ onFinished: b = () => {
|
|
|
48
53
|
return window.addEventListener("message", e), () => {
|
|
49
54
|
window.removeEventListener("message", e);
|
|
50
55
|
};
|
|
51
|
-
}, []),
|
|
56
|
+
}, []), s(() => {
|
|
52
57
|
localStorage.getItem("wizard-completed") || n(!0);
|
|
53
58
|
}, []), !r)
|
|
54
59
|
return null;
|
|
55
|
-
const
|
|
56
|
-
locale:
|
|
60
|
+
const S = A(F(window.location.origin, C), {
|
|
61
|
+
locale: I
|
|
57
62
|
});
|
|
58
|
-
return /* @__PURE__ */
|
|
59
|
-
|
|
63
|
+
return /* @__PURE__ */ x(
|
|
64
|
+
D,
|
|
60
65
|
{
|
|
61
66
|
open: r,
|
|
62
|
-
onClose: () =>
|
|
67
|
+
onClose: () => f.current(),
|
|
63
68
|
fullWidth: !0,
|
|
64
|
-
maxWidth:
|
|
65
|
-
fullScreen:
|
|
69
|
+
maxWidth: p ? !1 : "md",
|
|
70
|
+
fullScreen: p,
|
|
66
71
|
slotProps: {
|
|
67
72
|
paper: {
|
|
68
73
|
sx: {
|
|
@@ -70,7 +75,7 @@ function D({ onFinished: b = () => {
|
|
|
70
75
|
borderRadius: 0,
|
|
71
76
|
position: "relative",
|
|
72
77
|
overflow: "hidden",
|
|
73
|
-
...
|
|
78
|
+
...p ? { borderRadius: 0 } : {
|
|
74
79
|
borderRadius: 1,
|
|
75
80
|
height: "max(800px, 80vh)"
|
|
76
81
|
}
|
|
@@ -83,11 +88,11 @@ function D({ onFinished: b = () => {
|
|
|
83
88
|
}
|
|
84
89
|
},
|
|
85
90
|
children: [
|
|
86
|
-
/* @__PURE__ */
|
|
91
|
+
/* @__PURE__ */ i(
|
|
87
92
|
"iframe",
|
|
88
93
|
{
|
|
89
|
-
ref:
|
|
90
|
-
src:
|
|
94
|
+
ref: m,
|
|
95
|
+
src: S,
|
|
91
96
|
title: "Setup Wizard",
|
|
92
97
|
style: {
|
|
93
98
|
width: "100%",
|
|
@@ -95,14 +100,14 @@ function D({ onFinished: b = () => {
|
|
|
95
100
|
border: 0,
|
|
96
101
|
padding: 0,
|
|
97
102
|
margin: 0,
|
|
98
|
-
opacity:
|
|
103
|
+
opacity: c ? 1 : 0,
|
|
99
104
|
transition: "opacity 0.3s ease-in-out"
|
|
100
105
|
},
|
|
101
|
-
onLoad: () =>
|
|
106
|
+
onLoad: () => d(!0)
|
|
102
107
|
}
|
|
103
108
|
),
|
|
104
|
-
|
|
105
|
-
|
|
109
|
+
c ? null : /* @__PURE__ */ i(
|
|
110
|
+
R,
|
|
106
111
|
{
|
|
107
112
|
sx: {
|
|
108
113
|
position: "absolute",
|
|
@@ -115,18 +120,22 @@ function D({ onFinished: b = () => {
|
|
|
115
120
|
alignItems: "center",
|
|
116
121
|
bgcolor: "background.paper"
|
|
117
122
|
},
|
|
118
|
-
children: /* @__PURE__ */
|
|
123
|
+
children: /* @__PURE__ */ x(R, { sx: { display: "flex", alignItems: "center", flexDirection: "column", gap: 1 }, children: [
|
|
124
|
+
/* @__PURE__ */ i(E, {}),
|
|
125
|
+
typeof l == "string" ? /* @__PURE__ */ i(M, { variant: "body1", children: l }) : l
|
|
126
|
+
] })
|
|
119
127
|
}
|
|
120
128
|
)
|
|
121
129
|
]
|
|
122
130
|
}
|
|
123
131
|
);
|
|
124
132
|
}
|
|
125
|
-
|
|
126
|
-
onFinished:
|
|
127
|
-
show:
|
|
128
|
-
onChangeVisible:
|
|
133
|
+
B.propTypes = {
|
|
134
|
+
onFinished: a.func,
|
|
135
|
+
show: a.bool,
|
|
136
|
+
onChangeVisible: a.func,
|
|
137
|
+
loadingText: a.node
|
|
129
138
|
};
|
|
130
139
|
export {
|
|
131
|
-
|
|
140
|
+
B as default
|
|
132
141
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blocklet/ui-react",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.41",
|
|
4
4
|
"description": "Some useful front-end web components that can be used in Blocklets.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -35,9 +35,9 @@
|
|
|
35
35
|
"dependencies": {
|
|
36
36
|
"@abtnode/constant": "^1.16.46",
|
|
37
37
|
"@abtnode/util": "^1.16.46",
|
|
38
|
-
"@arcblock/bridge": "3.0.
|
|
39
|
-
"@arcblock/icons": "3.0.
|
|
40
|
-
"@arcblock/react-hooks": "3.0.
|
|
38
|
+
"@arcblock/bridge": "3.0.41",
|
|
39
|
+
"@arcblock/icons": "3.0.41",
|
|
40
|
+
"@arcblock/react-hooks": "3.0.41",
|
|
41
41
|
"@arcblock/ws": "^1.21.0",
|
|
42
42
|
"@blocklet/constant": "^1.16.46",
|
|
43
43
|
"@blocklet/did-space-react": "^1.1.11",
|
|
@@ -91,5 +91,5 @@
|
|
|
91
91
|
"jest": "^29.7.0",
|
|
92
92
|
"unbuild": "^2.0.0"
|
|
93
93
|
},
|
|
94
|
-
"gitHead": "
|
|
94
|
+
"gitHead": "e4bf7c421b39bfc7b969653e580047629e5338b5"
|
|
95
95
|
}
|
package/src/Dashboard/index.jsx
CHANGED
|
@@ -4,6 +4,7 @@ import SocialMediaIcons from './demo/social-media-icons';
|
|
|
4
4
|
import Copyright from './demo/copyright';
|
|
5
5
|
import Footer from './demo/footer';
|
|
6
6
|
import ArcblockSite from './demo/arcblock-site';
|
|
7
|
+
import AigneSite from './demo/aigne-site';
|
|
7
8
|
|
|
8
9
|
export default {
|
|
9
10
|
title: 'Blocklet-UI-React/Footer',
|
|
@@ -29,4 +30,4 @@ ArcblockSite.argTypes = {
|
|
|
29
30
|
locale: { control: 'select', options: ['en', 'zh'] },
|
|
30
31
|
};
|
|
31
32
|
|
|
32
|
-
export { Brand, Links, SocialMediaIcons, Copyright, Footer, ArcblockSite };
|
|
33
|
+
export { Brand, Links, SocialMediaIcons, Copyright, Footer, ArcblockSite, AigneSite };
|
package/src/Footer/links.jsx
CHANGED
package/src/Header/index.tsx
CHANGED
|
@@ -4,7 +4,7 @@ import { withErrorBoundary } from 'react-error-boundary';
|
|
|
4
4
|
import { ErrorFallback } from '@arcblock/ux/lib/ErrorBoundary';
|
|
5
5
|
import { styled, useTheme, deepmerge, ThemeProvider } from '@arcblock/ux/lib/Theme';
|
|
6
6
|
import { ResponsiveHeader } from '@arcblock/ux/lib/Header';
|
|
7
|
-
import NavMenu, { Products } from '@arcblock/ux/lib/NavMenu';
|
|
7
|
+
import NavMenu, { Products, ProductsType } from '@arcblock/ux/lib/NavMenu';
|
|
8
8
|
import { useLocaleContext } from '@arcblock/ux/lib/Locale/context';
|
|
9
9
|
import { translate } from '@arcblock/ux/lib/Locale/util';
|
|
10
10
|
import useBlockletLogo from '@arcblock/ux/lib/hooks/use-blocklet-logo';
|
|
@@ -93,7 +93,6 @@ type HeaderProps = {
|
|
|
93
93
|
align?: 'left' | 'right';
|
|
94
94
|
maxWidth?: false | Breakpoint;
|
|
95
95
|
showDomainWarningDialog?: boolean;
|
|
96
|
-
showWizard?: boolean;
|
|
97
96
|
};
|
|
98
97
|
|
|
99
98
|
/**
|
|
@@ -111,7 +110,6 @@ function Header({
|
|
|
111
110
|
theme: themeOverrides = undefined,
|
|
112
111
|
hideNavMenu = false,
|
|
113
112
|
showDomainWarningDialog = true,
|
|
114
|
-
showWizard = false,
|
|
115
113
|
...rest
|
|
116
114
|
}: HeaderProps & Omit<BoxProps, keyof HeaderProps>) {
|
|
117
115
|
useWalletHiddenTopbar();
|
|
@@ -135,6 +133,34 @@ function Header({
|
|
|
135
133
|
theme: themeOverrides,
|
|
136
134
|
});
|
|
137
135
|
|
|
136
|
+
// 显示 Products 导航
|
|
137
|
+
const { productsOrder, productsType } = useMemo<{
|
|
138
|
+
productsOrder: number | null;
|
|
139
|
+
productsType: ProductsType | null;
|
|
140
|
+
}>(() => {
|
|
141
|
+
let { USE_ARCBLOCK_THEME, USE_AIGNE_THEME } = formattedBlocklet;
|
|
142
|
+
USE_ARCBLOCK_THEME = parseInt(USE_ARCBLOCK_THEME, 10);
|
|
143
|
+
USE_AIGNE_THEME = parseInt(USE_AIGNE_THEME, 10);
|
|
144
|
+
|
|
145
|
+
if (isFinite(USE_AIGNE_THEME)) {
|
|
146
|
+
return {
|
|
147
|
+
productsOrder: USE_AIGNE_THEME,
|
|
148
|
+
productsType: 'AIGNE',
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
if (isFinite(USE_ARCBLOCK_THEME)) {
|
|
152
|
+
return {
|
|
153
|
+
productsOrder: USE_ARCBLOCK_THEME,
|
|
154
|
+
productsType: 'ARCBLOCK',
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
return {
|
|
159
|
+
productsOrder: null,
|
|
160
|
+
productsType: null,
|
|
161
|
+
};
|
|
162
|
+
}, [formattedBlocklet]);
|
|
163
|
+
|
|
138
164
|
if (!formattedBlocklet.appName) {
|
|
139
165
|
return null;
|
|
140
166
|
}
|
|
@@ -142,13 +168,11 @@ function Header({
|
|
|
142
168
|
const parsedNavigation = parseNavigation(navigation);
|
|
143
169
|
const { navItems, activeId } = parsedNavigation;
|
|
144
170
|
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
if (isFinite(productsNavOrder)) {
|
|
148
|
-
navItems.splice(productsNavOrder, 0, {
|
|
171
|
+
if (productsType && Number.isInteger(productsOrder)) {
|
|
172
|
+
navItems.splice(productsOrder, 0, {
|
|
149
173
|
label: t('products'),
|
|
150
174
|
// eslint-disable-next-line react/no-unstable-nested-components
|
|
151
|
-
children: (
|
|
175
|
+
children: () => <Products type={productsType} />,
|
|
152
176
|
});
|
|
153
177
|
}
|
|
154
178
|
|
|
@@ -166,7 +190,6 @@ function Header({
|
|
|
166
190
|
// @ts-ignore
|
|
167
191
|
sessionManagerProps={sessionManagerProps}
|
|
168
192
|
showDomainWarningDialog={showDomainWarningDialog}
|
|
169
|
-
showWizard={showWizard}
|
|
170
193
|
/>
|
|
171
194
|
);
|
|
172
195
|
|
|
@@ -1,24 +1,21 @@
|
|
|
1
1
|
import 'iconify-icon';
|
|
2
2
|
|
|
3
|
-
import { use, createElement, useState, useEffect } from 'react';
|
|
4
3
|
import PropTypes from 'prop-types';
|
|
5
|
-
import {
|
|
6
|
-
import WandIcon from '@iconify-icons/tabler/wand';
|
|
4
|
+
import { createElement, use } from 'react';
|
|
7
5
|
|
|
8
6
|
// FIXME: 直接从 react 中 import Fragment 可能会在 vite 下出错,先暂时从 react/jsx-runtime 导入 Fragment 来跳过这个问题
|
|
9
|
-
import { Fragment } from 'react/jsx-runtime';
|
|
10
7
|
import { SessionContext } from '@arcblock/did-connect/lib/Session';
|
|
11
|
-
import SessionUser from '@arcblock/ux/lib/SessionUser';
|
|
12
|
-
import SessionBlocklet from '@arcblock/ux/lib/SessionBlocklet';
|
|
13
|
-
import LocaleSelector from '@arcblock/ux/lib/Locale/selector';
|
|
14
|
-
import { useLocaleContext } from '@arcblock/ux/lib/Locale/context';
|
|
15
8
|
import ThemeModeToggle from '@arcblock/ux/lib/Config/theme-mode-toggle';
|
|
9
|
+
import { useLocaleContext } from '@arcblock/ux/lib/Locale/context';
|
|
10
|
+
import LocaleSelector from '@arcblock/ux/lib/Locale/selector';
|
|
11
|
+
import SessionBlocklet from '@arcblock/ux/lib/SessionBlocklet';
|
|
12
|
+
import SessionUser from '@arcblock/ux/lib/SessionUser';
|
|
13
|
+
import { Fragment } from 'react/jsx-runtime';
|
|
16
14
|
|
|
15
|
+
import { filterNavByRole, getLocalizedNavigation } from '../blocklets';
|
|
17
16
|
import { SessionManagerProps } from '../types';
|
|
18
|
-
import { getLocalizedNavigation, filterNavByRole } from '../blocklets';
|
|
19
|
-
import NotificationAddon from './notification-addon';
|
|
20
17
|
import DomainWarning from './domain-warning';
|
|
21
|
-
import
|
|
18
|
+
import NotificationAddon from './notification-addon';
|
|
22
19
|
|
|
23
20
|
const hasNotification = () => {
|
|
24
21
|
const navigations = window?.blocklet?.navigation ?? [];
|
|
@@ -31,25 +28,7 @@ export default function HeaderAddons({
|
|
|
31
28
|
addons = null,
|
|
32
29
|
showDomainWarningDialog = true,
|
|
33
30
|
sessionManagerProps = { showRole: true },
|
|
34
|
-
showWizard = false,
|
|
35
31
|
}) {
|
|
36
|
-
const [wizardOpen, setWizardOpen] = useState(false);
|
|
37
|
-
const [showTooltip, setShowTooltip] = useState(false);
|
|
38
|
-
const { t } = useLocaleContext();
|
|
39
|
-
|
|
40
|
-
// 处理 tooltip 倒计时
|
|
41
|
-
useEffect(() => {
|
|
42
|
-
let timer;
|
|
43
|
-
if (showTooltip) {
|
|
44
|
-
timer = setTimeout(() => {
|
|
45
|
-
setShowTooltip(false);
|
|
46
|
-
}, 3000); // 3秒后自动隐藏
|
|
47
|
-
}
|
|
48
|
-
return () => {
|
|
49
|
-
if (timer) clearTimeout(timer);
|
|
50
|
-
};
|
|
51
|
-
}, [showTooltip]);
|
|
52
|
-
|
|
53
32
|
const sessionCtx = use(SessionContext);
|
|
54
33
|
const { locale, languages } = useLocaleContext() || {};
|
|
55
34
|
const { enableConnect = true, enableLocale = true } = formattedBlocklet;
|
|
@@ -77,54 +56,6 @@ export default function HeaderAddons({
|
|
|
77
56
|
// 切换明暗主题
|
|
78
57
|
addonsArray.push(<ThemeModeToggle key="theme-mode-toggle" />);
|
|
79
58
|
|
|
80
|
-
// Wizard 开关
|
|
81
|
-
if (showWizard) {
|
|
82
|
-
addonsArray.push(
|
|
83
|
-
<Tooltip
|
|
84
|
-
key={`wizard-toggle-${showTooltip}`}
|
|
85
|
-
title={t('setup.wizardTooltip')}
|
|
86
|
-
open={showTooltip}
|
|
87
|
-
placement="bottom"
|
|
88
|
-
arrow>
|
|
89
|
-
<IconButton
|
|
90
|
-
size="small"
|
|
91
|
-
onClick={() => {
|
|
92
|
-
setWizardOpen(true);
|
|
93
|
-
setShowTooltip(false); // 点击后隐藏 tooltip
|
|
94
|
-
}}
|
|
95
|
-
sx={{
|
|
96
|
-
display: { xs: 'none', md: 'flex' },
|
|
97
|
-
color: 'text.secondary',
|
|
98
|
-
...(showTooltip && {
|
|
99
|
-
backgroundColor: 'action.hover',
|
|
100
|
-
'@keyframes pulse': {
|
|
101
|
-
'0%': { opacity: 0.8 },
|
|
102
|
-
'50%': { opacity: 0.5 },
|
|
103
|
-
'100%': { opacity: 0.8 },
|
|
104
|
-
},
|
|
105
|
-
animation: 'pulse 2s infinite',
|
|
106
|
-
}),
|
|
107
|
-
}}>
|
|
108
|
-
<iconify-icon icon={WandIcon} height={20} />
|
|
109
|
-
</IconButton>
|
|
110
|
-
</Tooltip>,
|
|
111
|
-
<WizardModal
|
|
112
|
-
key="wizard-modal"
|
|
113
|
-
show={wizardOpen}
|
|
114
|
-
onChangeVisible={(visible) => {
|
|
115
|
-
setWizardOpen(visible);
|
|
116
|
-
if (!visible && wizardOpen) {
|
|
117
|
-
setShowTooltip(true);
|
|
118
|
-
}
|
|
119
|
-
}}
|
|
120
|
-
onFinished={() => {
|
|
121
|
-
setWizardOpen(false);
|
|
122
|
-
setShowTooltip(false);
|
|
123
|
-
}}
|
|
124
|
-
/>
|
|
125
|
-
);
|
|
126
|
-
}
|
|
127
|
-
|
|
128
59
|
// 启用了连接钱包并且检测到了 session context
|
|
129
60
|
if (enableConnect && sessionCtx) {
|
|
130
61
|
const menu = [];
|
|
@@ -180,5 +111,4 @@ HeaderAddons.propTypes = {
|
|
|
180
111
|
addons: PropTypes.oneOfType([PropTypes.func, PropTypes.node]),
|
|
181
112
|
sessionManagerProps: SessionManagerProps,
|
|
182
113
|
showDomainWarningDialog: PropTypes.bool,
|
|
183
|
-
showWizard: PropTypes.bool,
|
|
184
114
|
};
|