@blocklet/ui-react 3.1.48 → 3.1.49
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/.aigne/doc-smith/config.yaml +76 -0
- package/.aigne/doc-smith/history.yaml +9 -0
- package/.aigne/doc-smith/output/structure-plan.json +249 -0
- package/.aigne/doc-smith/upload-cache.yaml +528 -0
- package/docs/_sidebar.md +19 -0
- package/docs/components-component-management-blocklet-studio.ja.md +194 -0
- package/docs/components-component-management-blocklet-studio.md +194 -0
- package/docs/components-component-management-blocklet-studio.zh-TW.md +194 -0
- package/docs/components-component-management-blocklet-studio.zh.md +194 -0
- package/docs/components-component-management-component-installer.ja.md +256 -0
- package/docs/components-component-management-component-installer.md +256 -0
- package/docs/components-component-management-component-installer.zh-TW.md +256 -0
- package/docs/components-component-management-component-installer.zh.md +256 -0
- package/docs/components-component-management.ja.md +59 -0
- package/docs/components-component-management.md +59 -0
- package/docs/components-component-management.zh-TW.md +59 -0
- package/docs/components-component-management.zh.md +59 -0
- package/docs/components-layout-dashboard.ja.md +231 -0
- package/docs/components-layout-dashboard.md +231 -0
- package/docs/components-layout-dashboard.zh-TW.md +231 -0
- package/docs/components-layout-dashboard.zh.md +231 -0
- package/docs/components-layout-footer.ja.md +165 -0
- package/docs/components-layout-footer.md +165 -0
- package/docs/components-layout-footer.zh-TW.md +165 -0
- package/docs/components-layout-footer.zh.md +165 -0
- package/docs/components-layout-header.ja.md +233 -0
- package/docs/components-layout-header.md +233 -0
- package/docs/components-layout-header.zh-TW.md +233 -0
- package/docs/components-layout-header.zh.md +233 -0
- package/docs/components-layout.ja.md +50 -0
- package/docs/components-layout.md +50 -0
- package/docs/components-layout.zh-TW.md +50 -0
- package/docs/components-layout.zh.md +50 -0
- package/docs/components-notifications.ja.md +173 -0
- package/docs/components-notifications.md +173 -0
- package/docs/components-notifications.zh-TW.md +174 -0
- package/docs/components-notifications.zh.md +173 -0
- package/docs/components-user-management-user-center.ja.md +183 -0
- package/docs/components-user-management-user-center.md +183 -0
- package/docs/components-user-management-user-center.zh-TW.md +183 -0
- package/docs/components-user-management-user-center.zh.md +183 -0
- package/docs/components-user-management-user-sessions.ja.md +164 -0
- package/docs/components-user-management-user-sessions.md +164 -0
- package/docs/components-user-management-user-sessions.zh-TW.md +164 -0
- package/docs/components-user-management-user-sessions.zh.md +164 -0
- package/docs/components-user-management.ja.md +76 -0
- package/docs/components-user-management.md +76 -0
- package/docs/components-user-management.zh-TW.md +76 -0
- package/docs/components-user-management.zh.md +76 -0
- package/docs/components-utilities-icon.ja.md +106 -0
- package/docs/components-utilities-icon.md +106 -0
- package/docs/components-utilities-icon.zh-TW.md +106 -0
- package/docs/components-utilities-icon.zh.md +106 -0
- package/docs/components-utilities.ja.md +136 -0
- package/docs/components-utilities.md +136 -0
- package/docs/components-utilities.zh-TW.md +136 -0
- package/docs/components-utilities.zh.md +136 -0
- package/docs/components.ja.md +27 -0
- package/docs/components.md +27 -0
- package/docs/components.zh-TW.md +27 -0
- package/docs/components.zh.md +27 -0
- package/docs/core-concepts.ja.md +164 -0
- package/docs/core-concepts.md +164 -0
- package/docs/core-concepts.zh-TW.md +164 -0
- package/docs/core-concepts.zh.md +164 -0
- package/docs/getting-started.ja.md +132 -0
- package/docs/getting-started.md +132 -0
- package/docs/getting-started.zh-TW.md +132 -0
- package/docs/getting-started.zh.md +132 -0
- package/docs/hooks-api.ja.md +214 -0
- package/docs/hooks-api.md +214 -0
- package/docs/hooks-api.zh-TW.md +214 -0
- package/docs/hooks-api.zh.md +214 -0
- package/docs/how-to-guides.ja.md +413 -0
- package/docs/how-to-guides.md +413 -0
- package/docs/how-to-guides.zh-TW.md +413 -0
- package/docs/how-to-guides.zh.md +413 -0
- package/docs/overview.ja.md +91 -0
- package/docs/overview.md +91 -0
- package/docs/overview.zh-TW.md +91 -0
- package/docs/overview.zh.md +91 -0
- package/glossary.md +12 -0
- package/lib/Dashboard/index.js +46 -42
- package/lib/Footer/index.js +51 -36
- package/lib/Header/index.js +48 -44
- package/lib/UserCenter/components/settings.js +1 -0
- package/lib/UserCenter/components/user-center.js +133 -133
- package/lib/blocklets.d.ts +13 -2
- package/lib/blocklets.js +40 -40
- package/lib/common/header-addons.js +37 -33
- package/package.json +7 -7
- package/src/Dashboard/index.jsx +8 -3
- package/src/Footer/index.jsx +22 -4
- package/src/Header/index.tsx +7 -2
- package/src/UserCenter/components/settings.tsx +1 -0
- package/src/UserCenter/components/user-center.tsx +6 -6
- package/src/blocklets.js +18 -9
- package/src/common/header-addons.jsx +7 -2
|
@@ -1,27 +1,27 @@
|
|
|
1
1
|
import { jsx as r, jsxs as m } from "react/jsx-runtime";
|
|
2
|
-
import { use as
|
|
3
|
-
import { Box as d, Typography as
|
|
4
|
-
import { useMemoizedFn as
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import { SessionContext as
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
import
|
|
12
|
-
import { useConfirm as
|
|
13
|
-
import { translate as
|
|
2
|
+
import { use as ye, useMemo as ke, isValidElement as Y, cloneElement as Z, Children as Ce } from "react";
|
|
3
|
+
import { Box as d, Typography as Pe, CircularProgress as Se, Divider as Me } from "@mui/material";
|
|
4
|
+
import { useMemoizedFn as C, useCreation as c, useRequest as ee } from "ahooks";
|
|
5
|
+
import De from "p-wait-for";
|
|
6
|
+
import re from "react-helmet";
|
|
7
|
+
import { SessionContext as Te } from "@arcblock/did-connect-react/lib/Session";
|
|
8
|
+
import Fe from "@arcblock/ux/lib/Tabs";
|
|
9
|
+
import te from "@arcblock/ux/lib/Empty";
|
|
10
|
+
import ze from "@arcblock/ux/lib/Button";
|
|
11
|
+
import We from "@arcblock/ux/lib/Result";
|
|
12
|
+
import { useConfirm as Ae } from "@arcblock/ux/lib/Dialog";
|
|
13
|
+
import { translate as Le } from "@arcblock/ux/lib/Locale/util";
|
|
14
14
|
import { useLocaleContext as Ue } from "@arcblock/ux/lib/Locale/context";
|
|
15
|
-
import { ErrorFallback as
|
|
16
|
-
import { styled as
|
|
17
|
-
import
|
|
18
|
-
import { joinURL as
|
|
19
|
-
import { isSupportFollow as
|
|
20
|
-
import { PROFILE_URL as
|
|
21
|
-
import
|
|
22
|
-
import
|
|
23
|
-
import { translations as
|
|
24
|
-
import
|
|
15
|
+
import { ErrorFallback as Be } from "@arcblock/ux/lib/ErrorBoundary";
|
|
16
|
+
import { styled as de } from "@arcblock/ux/lib/Theme";
|
|
17
|
+
import Ie from "lodash/cloneDeep";
|
|
18
|
+
import { joinURL as P, getQuery as je, withoutTrailingSlash as ie, withQuery as oe } from "ufo";
|
|
19
|
+
import { isSupportFollow as He } from "@arcblock/ux/lib/Util";
|
|
20
|
+
import { PROFILE_URL as S } from "@arcblock/ux/lib/Util/constant";
|
|
21
|
+
import Ne from "../../Footer/index.js";
|
|
22
|
+
import ne from "../../Header/index.js";
|
|
23
|
+
import { translations as Ee } from "../libs/locales.js";
|
|
24
|
+
import se from "./user-info/user-basic-info.js";
|
|
25
25
|
import "@mui/icons-material";
|
|
26
26
|
import "@iconify/react";
|
|
27
27
|
import "@arcblock/ux/lib/DID";
|
|
@@ -32,17 +32,17 @@ import "@iconify-icons/material-symbols/settings-input-antenna-rounded";
|
|
|
32
32
|
import "@arcblock/ux/lib/RelativeTime";
|
|
33
33
|
import "@arcblock/ux/lib/UserCard/Content/shorten-label";
|
|
34
34
|
import "./user-info/switch-role.js";
|
|
35
|
-
import { formatBlockletInfo as
|
|
36
|
-
import
|
|
37
|
-
import
|
|
38
|
-
import { client as
|
|
39
|
-
import
|
|
40
|
-
import { ConfigUserSpaceProvider as
|
|
41
|
-
import
|
|
42
|
-
import
|
|
43
|
-
import { UserFollowersProvider as
|
|
44
|
-
import
|
|
45
|
-
const
|
|
35
|
+
import { formatBlockletInfo as _e, getLink as M, getLocalizedNavigation as Oe } from "../../blocklets.js";
|
|
36
|
+
import Re from "./passport.js";
|
|
37
|
+
import $e from "./settings.js";
|
|
38
|
+
import { client as le } from "../../libs/client.js";
|
|
39
|
+
import qe from "../../hooks/use-mobile.js";
|
|
40
|
+
import { ConfigUserSpaceProvider as Ge } from "../../contexts/config-user-space.js";
|
|
41
|
+
import Qe from "./storage/index.js";
|
|
42
|
+
import Ve from "./nft.js";
|
|
43
|
+
import { UserFollowersProvider as ae } from "../../contexts/user-followers.js";
|
|
44
|
+
import Je from "./fallback.js";
|
|
45
|
+
const F = P(S, "/nfts"), z = P(S, "/settings"), W = P(S, "/did-spaces"), ue = P(S, "/user-followers"), ce = de(d)(({ theme: v }) => ({
|
|
46
46
|
flex: 1,
|
|
47
47
|
boxSizing: "border-box",
|
|
48
48
|
padding: "0 16px",
|
|
@@ -56,7 +56,7 @@ const T = C(P, "/nfts"), F = C(P, "/settings"), z = C(P, "/did-spaces"), ae = C(
|
|
|
56
56
|
[v.breakpoints.up("md")]: {
|
|
57
57
|
flexDirection: "row"
|
|
58
58
|
}
|
|
59
|
-
})),
|
|
59
|
+
})), A = de(d)(({ theme: v }) => ({
|
|
60
60
|
overflow: "hidden",
|
|
61
61
|
flex: "revert",
|
|
62
62
|
[v.breakpoints.up("md")]: {
|
|
@@ -68,45 +68,45 @@ const T = C(P, "/nfts"), F = C(P, "/settings"), z = C(P, "/did-spaces"), ae = C(
|
|
|
68
68
|
}
|
|
69
69
|
}
|
|
70
70
|
}));
|
|
71
|
-
function
|
|
71
|
+
function Or({
|
|
72
72
|
children: v,
|
|
73
|
-
notLoginContent:
|
|
73
|
+
notLoginContent: L = null,
|
|
74
74
|
currentTab: b,
|
|
75
75
|
contentProps: U = {},
|
|
76
|
-
disableAutoRedirect:
|
|
77
|
-
hideFooter:
|
|
78
|
-
headerProps:
|
|
79
|
-
footerProps:
|
|
80
|
-
userDid:
|
|
81
|
-
stickySidebar:
|
|
82
|
-
embed:
|
|
76
|
+
disableAutoRedirect: B = !1,
|
|
77
|
+
hideFooter: fe = !1,
|
|
78
|
+
headerProps: pe = {},
|
|
79
|
+
footerProps: me = {},
|
|
80
|
+
userDid: D = void 0,
|
|
81
|
+
stickySidebar: I = !1,
|
|
82
|
+
embed: j = !1,
|
|
83
83
|
onlyProfile: y = !1,
|
|
84
84
|
// 只显示 profile 页面,用于 ArcSphere 只需要显示 Profile 的内容
|
|
85
|
-
onDestroySelf:
|
|
85
|
+
onDestroySelf: he = void 0
|
|
86
86
|
}) {
|
|
87
|
-
const { locale: h } = Ue(), l =
|
|
88
|
-
if (
|
|
89
|
-
return
|
|
90
|
-
const e = window.location.href, t =
|
|
87
|
+
const { locale: h, defaultLocale: k } = Ue(), l = qe({ key: "md" }), p = C((e, t = {}) => Le(Ee, e, h, "en", t)), o = ye(Te)?.session, x = c(() => {
|
|
88
|
+
if (D)
|
|
89
|
+
return D;
|
|
90
|
+
const e = window.location.href, t = je(e);
|
|
91
91
|
return t?.did ? Array.isArray(t.did) ? t.did[0] : t.did : o?.user?.did;
|
|
92
|
-
}, [o?.user?.did,
|
|
92
|
+
}, [o?.user?.did, D]), i = c(() => o?.user ? x === o?.user?.did : !1, [x, o?.user?.did]), w = ke(() => He(), []), n = ee(
|
|
93
93
|
// eslint-disable-next-line consistent-return
|
|
94
94
|
async () => {
|
|
95
|
-
if (await
|
|
95
|
+
if (await De(() => o?.initialized), i)
|
|
96
96
|
return o.user;
|
|
97
97
|
if (x)
|
|
98
|
-
return
|
|
98
|
+
return le.user.getUserPublicInfo({ did: x });
|
|
99
99
|
},
|
|
100
100
|
{
|
|
101
101
|
refreshDeps: [x, i, o?.initialized, o?.user]
|
|
102
102
|
}
|
|
103
|
-
),
|
|
104
|
-
async () => n.data && b ? await
|
|
103
|
+
), H = C(() => i ? o.refresh() : n.refresh()), g = ee(
|
|
104
|
+
async () => n.data && b ? await le.user.getUserPrivacyConfig({ did: x }) : null,
|
|
105
105
|
{
|
|
106
106
|
refreshDeps: [x, n.data, b],
|
|
107
107
|
loadingDelay: 300
|
|
108
108
|
}
|
|
109
|
-
), { confirmHolder:
|
|
109
|
+
), { confirmHolder: N } = Ae({
|
|
110
110
|
fullScreen: l,
|
|
111
111
|
sx: {
|
|
112
112
|
".MuiDialog-paper": {
|
|
@@ -126,27 +126,27 @@ function _r({
|
|
|
126
126
|
}
|
|
127
127
|
}
|
|
128
128
|
}
|
|
129
|
-
}),
|
|
130
|
-
const e =
|
|
129
|
+
}), E = c(() => {
|
|
130
|
+
const e = Ie(window.blocklet);
|
|
131
131
|
try {
|
|
132
|
-
return
|
|
132
|
+
return _e(e);
|
|
133
133
|
} catch (t) {
|
|
134
134
|
return console.error("Failed to format blocklet info", t, e), e;
|
|
135
135
|
}
|
|
136
|
-
}, []),
|
|
136
|
+
}, []), _ = c(() => {
|
|
137
137
|
const e = {
|
|
138
138
|
label: p("common.nft"),
|
|
139
139
|
protected: !1,
|
|
140
140
|
isPrivate: !1,
|
|
141
141
|
// true: 隐私数据,仅自己可见
|
|
142
|
-
value:
|
|
143
|
-
url:
|
|
142
|
+
value: F,
|
|
143
|
+
url: M(F, h, k)
|
|
144
144
|
}, t = {
|
|
145
145
|
label: p("userFollowers"),
|
|
146
146
|
protected: !1,
|
|
147
147
|
isPrivate: !1,
|
|
148
|
-
value:
|
|
149
|
-
url:
|
|
148
|
+
value: ue,
|
|
149
|
+
url: M(ue, h, k)
|
|
150
150
|
};
|
|
151
151
|
let f = w ? [e, t] : [e];
|
|
152
152
|
if (i) {
|
|
@@ -156,29 +156,29 @@ function _r({
|
|
|
156
156
|
label: p("common.setting"),
|
|
157
157
|
protected: !0,
|
|
158
158
|
isPrivate: !0,
|
|
159
|
-
value:
|
|
160
|
-
url:
|
|
159
|
+
value: z,
|
|
160
|
+
url: M(z, h, k)
|
|
161
161
|
},
|
|
162
162
|
{
|
|
163
163
|
label: p("storageManagement"),
|
|
164
164
|
protected: !0,
|
|
165
165
|
isPrivate: !0,
|
|
166
|
-
value:
|
|
167
|
-
url:
|
|
166
|
+
value: W,
|
|
167
|
+
url: M(W, h, k)
|
|
168
168
|
}
|
|
169
169
|
];
|
|
170
170
|
f = w ? [...u, t] : u;
|
|
171
171
|
}
|
|
172
172
|
return f;
|
|
173
173
|
}, [i, h, w]), a = c(() => {
|
|
174
|
-
const e =
|
|
175
|
-
return (
|
|
176
|
-
const
|
|
174
|
+
const e = E?.navigation?.userCenter || [];
|
|
175
|
+
return (Oe({ navigation: e, locale: h, defaultLocale: k }) || []).concat(_).map((u) => {
|
|
176
|
+
const X = u.value ?? u._rawLink ?? u.link ?? u.url;
|
|
177
177
|
return {
|
|
178
|
-
value:
|
|
178
|
+
value: X,
|
|
179
179
|
label: u.title || u.label,
|
|
180
180
|
url: u.link || u.url,
|
|
181
|
-
protected: g?.data?.[
|
|
181
|
+
protected: g?.data?.[X] ?? !1,
|
|
182
182
|
isPrivate: u.isPrivate || u.private || (u?._rawLink?.includes("/customer") ?? !1),
|
|
183
183
|
// FIXME: HACK: 隐藏 /customer 菜单, 需要一个通用的解决方案,在嵌入的时候就决定是否是私有的
|
|
184
184
|
followersOnly: u.component === "did-comments"
|
|
@@ -186,32 +186,32 @@ function _r({
|
|
|
186
186
|
// icon: x.icon,
|
|
187
187
|
};
|
|
188
188
|
}).filter((u) => i || !u.isPrivate);
|
|
189
|
-
}, [
|
|
189
|
+
}, [E, n.data, g?.data, h, _, i]), s = c(() => a.find((e) => ie(e.value) === ie(b)), [a]), O = c(() => {
|
|
190
190
|
const e = window.blocklet?.appName, f = [s?.label, p("userCenter.title")].filter(Boolean).join("-");
|
|
191
191
|
return e ? `${f} | ${e}` : f;
|
|
192
|
-
}, [s, p]),
|
|
192
|
+
}, [s, p]), xe = C((e) => e && (Y(e) ? Z(e, {
|
|
193
193
|
...e.props || {},
|
|
194
194
|
userCenterTabs: a
|
|
195
|
-
}) :
|
|
195
|
+
}) : Ce.map(e, (t) => Y(t) ? Z(t, {
|
|
196
196
|
...t.props || {},
|
|
197
197
|
userCenterTabs: a
|
|
198
|
-
}) : t))),
|
|
198
|
+
}) : t))), ge = C((e) => {
|
|
199
199
|
const t = a.find((f) => f.value === e);
|
|
200
|
-
t && (window.location.href =
|
|
200
|
+
t && (window.location.href = oe(t.url, {
|
|
201
201
|
did: i ? void 0 : x
|
|
202
202
|
}));
|
|
203
|
-
}),
|
|
204
|
-
|
|
203
|
+
}), R = c(() => /* @__PURE__ */ r(
|
|
204
|
+
$e,
|
|
205
205
|
{
|
|
206
206
|
user: n.data,
|
|
207
207
|
settings: { userCenterTabs: a },
|
|
208
208
|
onSave: async (e) => e === "privacy" ? (await g.runAsync(), g.data) : (e === "profile" && await o.refresh(), null),
|
|
209
209
|
isMobile: l,
|
|
210
|
-
onDestroySelf:
|
|
210
|
+
onDestroySelf: he
|
|
211
211
|
}
|
|
212
|
-
), [n.data, a, g.data, g.runAsync]),
|
|
213
|
-
o?.user?.sourceProvider === "passkey" ?
|
|
214
|
-
}),
|
|
212
|
+
), [n.data, a, g.data, g.runAsync]), $ = c(() => s && s?.value === z, [s]), q = c(() => s && s?.value === P(S, "/profile") || s?.value === F, [s]), be = c(() => s && s?.value === W, [s]), ve = o.useOAuth(), we = o.usePasskey(), G = C(() => {
|
|
213
|
+
o?.user?.sourceProvider === "passkey" ? we.switchPassport(o.user) : ["google", "apple", "email", "github"].includes(o?.user?.sourceProvider ?? "") ? ve.switchOAuthPassport(o.user) : o && o.switchPassport();
|
|
214
|
+
}), T = c(() => q ? /* @__PURE__ */ m(
|
|
215
215
|
d,
|
|
216
216
|
{
|
|
217
217
|
sx: {
|
|
@@ -222,7 +222,7 @@ function _r({
|
|
|
222
222
|
children: [
|
|
223
223
|
i ? /* @__PURE__ */ m(d, { sx: { border: "1px solid", borderColor: "divider", borderRadius: 1.5, p: 2 }, children: [
|
|
224
224
|
/* @__PURE__ */ r(
|
|
225
|
-
|
|
225
|
+
Pe,
|
|
226
226
|
{
|
|
227
227
|
sx: {
|
|
228
228
|
color: "text.primary",
|
|
@@ -232,12 +232,12 @@ function _r({
|
|
|
232
232
|
children: p("passport")
|
|
233
233
|
}
|
|
234
234
|
),
|
|
235
|
-
/* @__PURE__ */ r(
|
|
235
|
+
/* @__PURE__ */ r(Re, { user: n.data })
|
|
236
236
|
] }) : null,
|
|
237
|
-
/* @__PURE__ */ r(
|
|
237
|
+
/* @__PURE__ */ r(Ve, { user: n.data })
|
|
238
238
|
]
|
|
239
239
|
}
|
|
240
|
-
) :
|
|
240
|
+
) : $ && i ? R : be && i ? /* @__PURE__ */ r(Ge, { children: /* @__PURE__ */ r(Qe, {}) }) : null, [$, q, n, i, I, R]), Q = c(() => /* @__PURE__ */ r(
|
|
241
241
|
d,
|
|
242
242
|
{
|
|
243
243
|
sx: {
|
|
@@ -247,9 +247,9 @@ function _r({
|
|
|
247
247
|
},
|
|
248
248
|
py: 3
|
|
249
249
|
},
|
|
250
|
-
children: /* @__PURE__ */ r(
|
|
250
|
+
children: /* @__PURE__ */ r(te, { children: p("emptyContent") })
|
|
251
251
|
}
|
|
252
|
-
), [i, h]),
|
|
252
|
+
), [i, h]), V = c(() => !g.data || g.loading ? /* @__PURE__ */ r(
|
|
253
253
|
d,
|
|
254
254
|
{
|
|
255
255
|
sx: {
|
|
@@ -261,28 +261,28 @@ function _r({
|
|
|
261
261
|
alignItems: "center",
|
|
262
262
|
flex: 1
|
|
263
263
|
},
|
|
264
|
-
children: /* @__PURE__ */ r(
|
|
264
|
+
children: /* @__PURE__ */ r(Se, {})
|
|
265
265
|
}
|
|
266
266
|
) : /* @__PURE__ */ r(d, { sx: { flex: 1 }, children: /* @__PURE__ */ r(
|
|
267
|
-
|
|
267
|
+
Je,
|
|
268
268
|
{
|
|
269
269
|
isSupportFollow: w,
|
|
270
270
|
currentActiveTab: s,
|
|
271
271
|
isMyself: i,
|
|
272
|
-
children: v ? /* @__PURE__ */ r(d, { ...U, children:
|
|
272
|
+
children: v ? /* @__PURE__ */ r(d, { ...U, children: xe(v) }) : T
|
|
273
273
|
}
|
|
274
|
-
) }), [g, s, i, v, U,
|
|
274
|
+
) }), [g, s, i, v, U, T, h]), J = c(() => {
|
|
275
275
|
if (n.loading || o.loading)
|
|
276
276
|
return null;
|
|
277
277
|
if (n.error) {
|
|
278
278
|
if (n.error?.response?.status === 404)
|
|
279
|
-
return /* @__PURE__ */ r(d, { sx: { width: "100%" }, children: /* @__PURE__ */ r(
|
|
279
|
+
return /* @__PURE__ */ r(d, { sx: { width: "100%" }, children: /* @__PURE__ */ r(We, { status: 404, description: p("noUserFound") }) });
|
|
280
280
|
const f = {
|
|
281
281
|
message: n.error.response?.data?.error || n.error.message || "error occurred"
|
|
282
282
|
};
|
|
283
|
-
return /* @__PURE__ */ r(d, { sx: { width: "100%" }, children: /* @__PURE__ */ r(
|
|
283
|
+
return /* @__PURE__ */ r(d, { sx: { width: "100%" }, children: /* @__PURE__ */ r(Be, { error: f }) });
|
|
284
284
|
}
|
|
285
|
-
return !x && !n.data ?
|
|
285
|
+
return !x && !n.data ? L || /* @__PURE__ */ r(d, { sx: { width: "100%" }, children: /* @__PURE__ */ m(
|
|
286
286
|
d,
|
|
287
287
|
{
|
|
288
288
|
sx: {
|
|
@@ -293,11 +293,11 @@ function _r({
|
|
|
293
293
|
gap: 1
|
|
294
294
|
},
|
|
295
295
|
children: [
|
|
296
|
-
/* @__PURE__ */ r(
|
|
297
|
-
/* @__PURE__ */ r(
|
|
296
|
+
/* @__PURE__ */ r(te, { children: p("viewAfterLogin") }),
|
|
297
|
+
/* @__PURE__ */ r(ze, { size: "small", variant: "contained", onClick: () => o.login(), children: p("loginNow") })
|
|
298
298
|
]
|
|
299
299
|
}
|
|
300
|
-
) }) :
|
|
300
|
+
) }) : j ? /* @__PURE__ */ m(A, { children: [
|
|
301
301
|
a.length > 0 && b ? /* @__PURE__ */ r(
|
|
302
302
|
d,
|
|
303
303
|
{
|
|
@@ -307,22 +307,22 @@ function _r({
|
|
|
307
307
|
overflow: "auto",
|
|
308
308
|
padding: "1px"
|
|
309
309
|
},
|
|
310
|
-
children:
|
|
310
|
+
children: V
|
|
311
311
|
}
|
|
312
312
|
) : null,
|
|
313
|
-
a.length === 0 &&
|
|
314
|
-
] }) : y ? /* @__PURE__ */ r(
|
|
315
|
-
|
|
313
|
+
a.length === 0 && Q
|
|
314
|
+
] }) : y ? /* @__PURE__ */ r(A, { display: "flex", flexDirection: l ? "column" : "row", children: /* @__PURE__ */ r(
|
|
315
|
+
se,
|
|
316
316
|
{
|
|
317
317
|
isMobile: l,
|
|
318
318
|
order: l ? 1 : "unset",
|
|
319
319
|
isMyself: i,
|
|
320
|
-
switchPassport:
|
|
320
|
+
switchPassport: G,
|
|
321
321
|
switchProfile: o.switchProfile,
|
|
322
322
|
user: n.data,
|
|
323
323
|
showFullDid: !1,
|
|
324
324
|
onlyProfile: y,
|
|
325
|
-
refreshProfile:
|
|
325
|
+
refreshProfile: H,
|
|
326
326
|
isShowSocialActions: w,
|
|
327
327
|
sx: {
|
|
328
328
|
padding: l ? "16px 0 0 0" : "40px 24px 24px 40px",
|
|
@@ -330,7 +330,7 @@ function _r({
|
|
|
330
330
|
boxSizing: "content-box"
|
|
331
331
|
}
|
|
332
332
|
}
|
|
333
|
-
) }) : /* @__PURE__ */ m(
|
|
333
|
+
) }) : /* @__PURE__ */ m(A, { display: "flex", flexDirection: l ? "column" : "row", children: [
|
|
334
334
|
/* @__PURE__ */ m(
|
|
335
335
|
d,
|
|
336
336
|
{
|
|
@@ -353,13 +353,13 @@ function _r({
|
|
|
353
353
|
},
|
|
354
354
|
children: [
|
|
355
355
|
/* @__PURE__ */ r(
|
|
356
|
-
|
|
356
|
+
Fe,
|
|
357
357
|
{
|
|
358
358
|
orientation: "horizontal",
|
|
359
359
|
variant: "line",
|
|
360
360
|
tabs: a,
|
|
361
361
|
current: s?.value ?? b,
|
|
362
|
-
onChange:
|
|
362
|
+
onChange: ge,
|
|
363
363
|
enableTabClick: !0,
|
|
364
364
|
sx: {
|
|
365
365
|
mb: (e) => `${e.spacing(3)} !important`,
|
|
@@ -396,25 +396,25 @@ function _r({
|
|
|
396
396
|
}
|
|
397
397
|
}
|
|
398
398
|
),
|
|
399
|
-
|
|
399
|
+
V
|
|
400
400
|
]
|
|
401
401
|
}
|
|
402
402
|
) : null,
|
|
403
|
-
a.length === 0 &&
|
|
403
|
+
a.length === 0 && Q
|
|
404
404
|
]
|
|
405
405
|
}
|
|
406
406
|
),
|
|
407
|
-
!l && /* @__PURE__ */ r(
|
|
407
|
+
!l && /* @__PURE__ */ r(Me, { orientation: "vertical", sx: { ml: 5 } }),
|
|
408
408
|
/* @__PURE__ */ r(
|
|
409
|
-
|
|
409
|
+
se,
|
|
410
410
|
{
|
|
411
411
|
isMobile: l,
|
|
412
412
|
order: l ? 1 : "unset",
|
|
413
413
|
isMyself: i,
|
|
414
|
-
switchPassport:
|
|
414
|
+
switchPassport: G,
|
|
415
415
|
switchProfile: o.switchProfile,
|
|
416
416
|
user: n.data,
|
|
417
|
-
refreshProfile:
|
|
417
|
+
refreshProfile: H,
|
|
418
418
|
showFullDid: !1,
|
|
419
419
|
isShowSocialActions: w,
|
|
420
420
|
sx: {
|
|
@@ -432,23 +432,23 @@ function _r({
|
|
|
432
432
|
s,
|
|
433
433
|
g,
|
|
434
434
|
b,
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
]),
|
|
438
|
-
if (c(() => y ? !1 : !
|
|
435
|
+
I,
|
|
436
|
+
T
|
|
437
|
+
]), K = c(() => i ? !1 : s?.isPrivate, [i, s]);
|
|
438
|
+
if (c(() => y ? !1 : !B && !b && a?.length > 0 || !s || K, [B, b, a, s, K, y])) {
|
|
439
439
|
const e = a[0]?.url, t = a.find((f) => f.value === e);
|
|
440
440
|
return e && !t?.isPrivate && window.location.replace(
|
|
441
|
-
|
|
441
|
+
oe(e, {
|
|
442
442
|
did: i ? void 0 : x
|
|
443
443
|
})
|
|
444
444
|
), null;
|
|
445
445
|
}
|
|
446
|
-
return
|
|
447
|
-
/* @__PURE__ */ r(
|
|
448
|
-
/* @__PURE__ */ r(
|
|
449
|
-
/* @__PURE__ */ m(
|
|
450
|
-
/* @__PURE__ */ r(
|
|
451
|
-
|
|
446
|
+
return j || y ? /* @__PURE__ */ m(d, { children: [
|
|
447
|
+
/* @__PURE__ */ r(re, { children: /* @__PURE__ */ r("title", { children: O }) }),
|
|
448
|
+
/* @__PURE__ */ r(ne, { style: { display: "none" } }),
|
|
449
|
+
/* @__PURE__ */ m(ce, { children: [
|
|
450
|
+
/* @__PURE__ */ r(ae, { isMySelf: i, userDid: n.data?.did ?? "", children: J }),
|
|
451
|
+
N
|
|
452
452
|
] })
|
|
453
453
|
] }) : /* @__PURE__ */ m(
|
|
454
454
|
d,
|
|
@@ -459,17 +459,17 @@ function _r({
|
|
|
459
459
|
flexDirection: "column"
|
|
460
460
|
},
|
|
461
461
|
children: [
|
|
462
|
-
/* @__PURE__ */ r(
|
|
463
|
-
/* @__PURE__ */ r(
|
|
464
|
-
/* @__PURE__ */ m(
|
|
465
|
-
/* @__PURE__ */ r(
|
|
466
|
-
|
|
462
|
+
/* @__PURE__ */ r(re, { children: /* @__PURE__ */ r("title", { children: O }) }),
|
|
463
|
+
/* @__PURE__ */ r(ne, { bordered: !0, ...pe, maxWidth: "100%" }),
|
|
464
|
+
/* @__PURE__ */ m(ce, { children: [
|
|
465
|
+
/* @__PURE__ */ r(ae, { isMySelf: i, userDid: n.data?.did ?? "", children: J }),
|
|
466
|
+
N
|
|
467
467
|
] }),
|
|
468
|
-
|
|
469
|
-
|
|
468
|
+
fe ? null : /* @__PURE__ */ r(
|
|
469
|
+
Ne,
|
|
470
470
|
{
|
|
471
471
|
bordered: !0,
|
|
472
|
-
...
|
|
472
|
+
...me,
|
|
473
473
|
sx: {
|
|
474
474
|
".MuiContainer-root": {
|
|
475
475
|
maxWidth: 1600
|
|
@@ -482,5 +482,5 @@ function _r({
|
|
|
482
482
|
);
|
|
483
483
|
}
|
|
484
484
|
export {
|
|
485
|
-
|
|
485
|
+
Or as default
|
|
486
486
|
};
|
package/lib/blocklets.d.ts
CHANGED
|
@@ -1,7 +1,18 @@
|
|
|
1
1
|
export const publicPath: any;
|
|
2
2
|
export function formatTheme(theme: any): any;
|
|
3
|
-
export function getLink(link: any, locale?: string): any;
|
|
4
|
-
export function getLocalizedNavigation(navigation
|
|
3
|
+
export function getLink(link: any, locale?: string, defaultLocale?: string): any;
|
|
4
|
+
export function getLocalizedNavigation({ navigation, locale, defaultLocale, section }: {
|
|
5
|
+
navigation: Array<{
|
|
6
|
+
title?: string | Record<string, string>;
|
|
7
|
+
description?: string | Record<string, string>;
|
|
8
|
+
link?: string | Record<string, string>;
|
|
9
|
+
items?: any[];
|
|
10
|
+
[key: string]: any;
|
|
11
|
+
}>;
|
|
12
|
+
locale: string;
|
|
13
|
+
defaultLocale: string;
|
|
14
|
+
section?: "footer" | "header" | undefined;
|
|
15
|
+
}): any[];
|
|
5
16
|
export function formatNavigation(navigation: any): any;
|
|
6
17
|
export function parseNavigation(navigation: any): {
|
|
7
18
|
header: never[];
|
package/lib/blocklets.js
CHANGED
|
@@ -1,51 +1,51 @@
|
|
|
1
|
-
import { getUTMUrl as
|
|
2
|
-
import { mapRecursive as
|
|
3
|
-
const
|
|
1
|
+
import { getUTMUrl as c } from "@arcblock/ux/lib/withTracker/libs/utm";
|
|
2
|
+
import { mapRecursive as a, filterRecursive as i, isUrl as u, isMailProtocol as l } from "./utils.js";
|
|
3
|
+
const v = window?.blocklet?.groupPrefix || window?.blocklet?.prefix || "/", d = (e) => {
|
|
4
4
|
const r = { ...e }, t = e?.background;
|
|
5
5
|
return typeof t == "string" ? r.background = { header: t, footer: t, default: t } : t && typeof t == "object" && (r.background = {
|
|
6
6
|
header: t.header || t.default,
|
|
7
7
|
footer: t.footer || t.default,
|
|
8
8
|
default: t.default
|
|
9
9
|
}), r;
|
|
10
|
-
},
|
|
10
|
+
}, h = (e, r = "en", t = "en") => {
|
|
11
11
|
if (typeof e == "string") {
|
|
12
|
-
if (
|
|
13
|
-
const
|
|
14
|
-
return
|
|
12
|
+
if (u(e)) {
|
|
13
|
+
const s = new URL(e);
|
|
14
|
+
return s.searchParams.set("locale", r), s.href;
|
|
15
15
|
}
|
|
16
|
-
if (
|
|
16
|
+
if (l(e))
|
|
17
17
|
return e;
|
|
18
|
-
const
|
|
19
|
-
return
|
|
18
|
+
const o = new URL(e, window.location.origin);
|
|
19
|
+
return o.searchParams.set("locale", r), o.pathname + o.search;
|
|
20
20
|
}
|
|
21
|
-
return typeof e == "object" ? e[r] || e
|
|
22
|
-
},
|
|
21
|
+
return typeof e == "object" ? e[r] || e[t] || e.en : e;
|
|
22
|
+
}, N = ({ navigation: e, locale: r, defaultLocale: t, section: o = "header" }) => {
|
|
23
23
|
if (!e?.length)
|
|
24
24
|
return e;
|
|
25
|
-
const
|
|
26
|
-
return
|
|
25
|
+
const s = (n, f) => n && typeof n == "object" ? n[f] || n[t] || n.en : n;
|
|
26
|
+
return a(
|
|
27
27
|
e,
|
|
28
|
-
(
|
|
29
|
-
...
|
|
30
|
-
title: n
|
|
31
|
-
description: n
|
|
28
|
+
(n) => ({
|
|
29
|
+
...n,
|
|
30
|
+
title: s(n.title, r),
|
|
31
|
+
description: s(n.description, r),
|
|
32
32
|
// 仅对叶结点进行处理
|
|
33
|
-
link:
|
|
34
|
-
_rawLink:
|
|
33
|
+
link: c(n.items?.length ? n.link : h(n.link, r, t), o),
|
|
34
|
+
_rawLink: n.link
|
|
35
35
|
}),
|
|
36
36
|
"items"
|
|
37
37
|
);
|
|
38
|
-
},
|
|
38
|
+
}, g = (e) => a(
|
|
39
39
|
e,
|
|
40
40
|
(r) => r.role ? {
|
|
41
41
|
...r,
|
|
42
42
|
role: Array.isArray(r.role) ? r.role : [r.role]
|
|
43
43
|
} : r,
|
|
44
44
|
"items"
|
|
45
|
-
),
|
|
45
|
+
), p = (e) => {
|
|
46
46
|
if (!e?.length)
|
|
47
47
|
return null;
|
|
48
|
-
const r =
|
|
48
|
+
const r = g(e), t = {
|
|
49
49
|
header: [],
|
|
50
50
|
footer: [],
|
|
51
51
|
// 对应 footer social media
|
|
@@ -58,32 +58,32 @@ const w = window?.blocklet?.groupPrefix || window?.blocklet?.prefix || "/", l =
|
|
|
58
58
|
sessionManager: [],
|
|
59
59
|
userCenter: []
|
|
60
60
|
};
|
|
61
|
-
return r.forEach((
|
|
62
|
-
|
|
63
|
-
t[
|
|
64
|
-
}) : typeof
|
|
61
|
+
return r.forEach((o) => {
|
|
62
|
+
o.section ? Array.isArray(o.section) ? o.section.forEach((s) => {
|
|
63
|
+
t[s]?.push(o);
|
|
64
|
+
}) : typeof o.section == "string" && t[o.section]?.push(o) : t.header.push(o);
|
|
65
65
|
}), t;
|
|
66
66
|
}, L = (e) => {
|
|
67
67
|
if (!e)
|
|
68
68
|
return null;
|
|
69
69
|
const r = { ...e };
|
|
70
|
-
return r.theme =
|
|
71
|
-
},
|
|
70
|
+
return r.theme = d(r.theme), r.navigation = p(b(r.navigation)), r;
|
|
71
|
+
}, b = (e = []) => i(e, (r, t) => !!r.link || t.filteredChildren?.length, "items"), P = (e, r) => i(
|
|
72
72
|
e,
|
|
73
|
-
(t,
|
|
74
|
-
const
|
|
75
|
-
return
|
|
73
|
+
(t, o) => {
|
|
74
|
+
const s = !t.role || r && (t.role.includes(r) || t.role.includes("guest"));
|
|
75
|
+
return o.isLeaf ? s : s && o.filteredChildren?.length;
|
|
76
76
|
},
|
|
77
77
|
"items"
|
|
78
78
|
);
|
|
79
79
|
export {
|
|
80
|
-
|
|
81
|
-
|
|
80
|
+
P as filterNavByRole,
|
|
81
|
+
b as filterValidNavItems,
|
|
82
82
|
L as formatBlockletInfo,
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
83
|
+
g as formatNavigation,
|
|
84
|
+
d as formatTheme,
|
|
85
|
+
h as getLink,
|
|
86
|
+
N as getLocalizedNavigation,
|
|
87
|
+
p as parseNavigation,
|
|
88
|
+
v as publicPath
|
|
89
89
|
};
|