@blocklet/ui-react 3.0.35 → 3.0.36
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.
|
@@ -1,25 +1,26 @@
|
|
|
1
|
-
import { jsx as r, jsxs as
|
|
2
|
-
import { use as
|
|
3
|
-
import { Box as
|
|
4
|
-
import { useMemoizedFn as y, useCreation as
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
import
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import
|
|
17
|
-
import
|
|
1
|
+
import { jsx as r, jsxs as p, Fragment as X } from "react/jsx-runtime";
|
|
2
|
+
import { use as be, isValidElement as Y, cloneElement as Z, Children as ve } from "react";
|
|
3
|
+
import { Box as a, Typography as we, CircularProgress as ye, Divider as Ce } from "@mui/material";
|
|
4
|
+
import { useMemoizedFn as y, useCreation as c, useRequest as ee } from "ahooks";
|
|
5
|
+
import ke from "p-wait-for";
|
|
6
|
+
import re from "react-helmet";
|
|
7
|
+
import { SessionContext as Pe } from "@arcblock/did-connect/lib/Session";
|
|
8
|
+
import Me from "@arcblock/ux/lib/Tabs";
|
|
9
|
+
import S from "@arcblock/ux/lib/Empty";
|
|
10
|
+
import Se from "@arcblock/ux/lib/Button";
|
|
11
|
+
import De from "@arcblock/ux/lib/Result";
|
|
12
|
+
import { useConfirm as Te } from "@arcblock/ux/lib/Dialog";
|
|
13
|
+
import { translate as ze } from "@arcblock/ux/lib/Locale/util";
|
|
14
|
+
import { useLocaleContext as We } from "@arcblock/ux/lib/Locale/context";
|
|
15
|
+
import { ErrorFallback as Ae } from "@arcblock/ux/lib/ErrorBoundary";
|
|
16
|
+
import { styled as le } from "@arcblock/ux/lib/Theme";
|
|
17
|
+
import Ue from "lodash/cloneDeep";
|
|
18
|
+
import { joinURL as C, getQuery as Be, withoutTrailingSlash as te, withQuery as ie } from "ufo";
|
|
18
19
|
import { PROFILE_URL as k } from "@arcblock/ux/lib/Util/constant";
|
|
19
|
-
import
|
|
20
|
-
import
|
|
21
|
-
import { translations as
|
|
22
|
-
import
|
|
20
|
+
import Le from "../../Footer/index.js";
|
|
21
|
+
import ne from "../../Header/index.js";
|
|
22
|
+
import { translations as Fe } from "../libs/locales.js";
|
|
23
|
+
import oe from "./user-info/user-basic-info.js";
|
|
23
24
|
import "@mui/icons-material";
|
|
24
25
|
import "@iconify/react";
|
|
25
26
|
import "@arcblock/ux/lib/DID";
|
|
@@ -30,15 +31,15 @@ import "@iconify-icons/material-symbols/settings-input-antenna-rounded";
|
|
|
30
31
|
import "@arcblock/ux/lib/RelativeTime";
|
|
31
32
|
import "@arcblock/ux/lib/UserCard/Content/shorten-label";
|
|
32
33
|
import "./user-info/switch-role.js";
|
|
33
|
-
import { formatBlockletInfo as
|
|
34
|
-
import
|
|
35
|
-
import
|
|
36
|
-
import { client as
|
|
34
|
+
import { formatBlockletInfo as Ie, getLink as D, getLocalizedNavigation as je } from "../../blocklets.js";
|
|
35
|
+
import He from "./passport.js";
|
|
36
|
+
import Ne from "./settings.js";
|
|
37
|
+
import { client as se } from "../../libs/client.js";
|
|
37
38
|
import Ee from "../../hooks/use-mobile.js";
|
|
38
|
-
import { ConfigUserSpaceProvider as
|
|
39
|
-
import
|
|
40
|
-
import
|
|
41
|
-
const T = C(k, "/nfts"),
|
|
39
|
+
import { ConfigUserSpaceProvider as _e } from "../../contexts/config-user-space.js";
|
|
40
|
+
import Re from "./storage/index.js";
|
|
41
|
+
import Oe from "./nft.js";
|
|
42
|
+
const T = C(k, "/nfts"), z = C(k, "/settings"), W = C(k, "/did-spaces"), ae = le(a)(({ theme: v }) => ({
|
|
42
43
|
flex: 1,
|
|
43
44
|
boxSizing: "border-box",
|
|
44
45
|
padding: "0 16px",
|
|
@@ -49,13 +50,13 @@ const T = C(k, "/nfts"), W = C(k, "/settings"), A = C(k, "/did-spaces"), oe = se
|
|
|
49
50
|
alignItems: "stretch",
|
|
50
51
|
gap: 2.5,
|
|
51
52
|
flexDirection: "column",
|
|
52
|
-
[
|
|
53
|
+
[v.breakpoints.up("md")]: {
|
|
53
54
|
flexDirection: "row"
|
|
54
55
|
}
|
|
55
|
-
})),
|
|
56
|
+
})), A = le(a)(({ theme: v }) => ({
|
|
56
57
|
overflow: "hidden",
|
|
57
58
|
flex: "revert",
|
|
58
|
-
[
|
|
59
|
+
[v.breakpoints.up("md")]: {
|
|
59
60
|
flex: 1
|
|
60
61
|
},
|
|
61
62
|
"@media (min-width: 850px) and (max-width: 1050px)": {
|
|
@@ -64,45 +65,45 @@ const T = C(k, "/nfts"), W = C(k, "/settings"), A = C(k, "/did-spaces"), oe = se
|
|
|
64
65
|
}
|
|
65
66
|
}
|
|
66
67
|
}));
|
|
67
|
-
function
|
|
68
|
-
children:
|
|
69
|
-
notLoginContent:
|
|
70
|
-
currentTab:
|
|
68
|
+
function Br({
|
|
69
|
+
children: v,
|
|
70
|
+
notLoginContent: U = null,
|
|
71
|
+
currentTab: g,
|
|
71
72
|
contentProps: B = {},
|
|
72
|
-
disableAutoRedirect:
|
|
73
|
-
hideFooter:
|
|
74
|
-
headerProps:
|
|
75
|
-
footerProps:
|
|
73
|
+
disableAutoRedirect: L = !1,
|
|
74
|
+
hideFooter: ce = !1,
|
|
75
|
+
headerProps: de = {},
|
|
76
|
+
footerProps: ue = {},
|
|
76
77
|
userDid: P = void 0,
|
|
77
|
-
stickySidebar:
|
|
78
|
-
embed:
|
|
78
|
+
stickySidebar: F = !1,
|
|
79
|
+
embed: I = !1,
|
|
79
80
|
onlyProfile: w = !1,
|
|
80
81
|
// 只显示 profile 页面,用于 ArcSphere 只需要显示 Profile 的内容
|
|
81
|
-
onDestroySelf:
|
|
82
|
+
onDestroySelf: fe = void 0
|
|
82
83
|
}) {
|
|
83
|
-
const { locale:
|
|
84
|
+
const { locale: b } = We(), d = Ee({ key: "md" }), f = y((e, t = {}) => ze(Fe, e, b, "en", t)), i = be(Pe)?.session, m = c(() => {
|
|
84
85
|
if (P)
|
|
85
86
|
return P;
|
|
86
|
-
const e = window.location.href, t =
|
|
87
|
+
const e = window.location.href, t = Be(e);
|
|
87
88
|
return t?.did ? Array.isArray(t.did) ? t.did[0] : t.did : i?.user?.did;
|
|
88
|
-
}, [i?.user?.did, P]), n =
|
|
89
|
+
}, [i?.user?.did, P]), n = c(() => i?.user ? m === i?.user?.did : !1, [m, i?.user?.did]), s = ee(
|
|
89
90
|
// eslint-disable-next-line consistent-return
|
|
90
91
|
async () => {
|
|
91
|
-
if (await
|
|
92
|
+
if (await ke(() => i?.initialized), n)
|
|
92
93
|
return i.user;
|
|
93
|
-
if (
|
|
94
|
-
return
|
|
94
|
+
if (m)
|
|
95
|
+
return se.user.getUserPublicInfo({ did: m });
|
|
95
96
|
},
|
|
96
97
|
{
|
|
97
|
-
refreshDeps: [
|
|
98
|
+
refreshDeps: [m, n, i?.initialized, i?.user]
|
|
98
99
|
}
|
|
99
|
-
),
|
|
100
|
-
async () =>
|
|
100
|
+
), j = y(() => n ? i.refresh() : s.refresh()), h = ee(
|
|
101
|
+
async () => s.data && g ? await se.user.getUserPrivacyConfig({ did: m }) : null,
|
|
101
102
|
{
|
|
102
|
-
refreshDeps: [
|
|
103
|
+
refreshDeps: [m, s.data, g],
|
|
103
104
|
loadingDelay: 300
|
|
104
105
|
}
|
|
105
|
-
), { confirmHolder: H } =
|
|
106
|
+
), { confirmHolder: H } = Te({
|
|
106
107
|
fullScreen: d,
|
|
107
108
|
sx: {
|
|
108
109
|
".MuiDialog-paper": {
|
|
@@ -122,78 +123,81 @@ function Wr({
|
|
|
122
123
|
}
|
|
123
124
|
}
|
|
124
125
|
}
|
|
125
|
-
}), N =
|
|
126
|
-
const e =
|
|
126
|
+
}), N = c(() => {
|
|
127
|
+
const e = Ue(window.blocklet);
|
|
127
128
|
try {
|
|
128
|
-
return
|
|
129
|
+
return Ie(e);
|
|
129
130
|
} catch (t) {
|
|
130
131
|
return console.error("Failed to format blocklet info", t, e), e;
|
|
131
132
|
}
|
|
132
|
-
}, []),
|
|
133
|
+
}, []), E = c(() => {
|
|
133
134
|
const e = {
|
|
134
|
-
label:
|
|
135
|
+
label: f("common.nft"),
|
|
135
136
|
protected: !1,
|
|
136
137
|
isPrivate: !1,
|
|
137
138
|
// true: 隐私数据,仅自己可见
|
|
138
139
|
value: T,
|
|
139
|
-
url:
|
|
140
|
+
url: D(T, b)
|
|
140
141
|
};
|
|
141
142
|
let t = [e];
|
|
142
143
|
return n && (t = [
|
|
143
144
|
e,
|
|
144
145
|
{
|
|
145
|
-
label:
|
|
146
|
+
label: f("common.setting"),
|
|
146
147
|
protected: !0,
|
|
147
148
|
isPrivate: !0,
|
|
148
|
-
value:
|
|
149
|
-
url: z
|
|
149
|
+
value: z,
|
|
150
|
+
url: D(z, b)
|
|
150
151
|
},
|
|
151
152
|
{
|
|
152
|
-
label:
|
|
153
|
+
label: f("storageManagement"),
|
|
153
154
|
protected: !0,
|
|
154
155
|
isPrivate: !0,
|
|
155
|
-
value:
|
|
156
|
-
url:
|
|
156
|
+
value: W,
|
|
157
|
+
url: D(W, b)
|
|
157
158
|
}
|
|
158
159
|
]), t;
|
|
159
|
-
}, [n,
|
|
160
|
+
}, [n, b]), l = c(() => {
|
|
160
161
|
const e = N?.navigation?.userCenter || [];
|
|
161
|
-
return (
|
|
162
|
-
const K =
|
|
162
|
+
return (je(e, b) || []).concat(E).map((u) => {
|
|
163
|
+
const K = u.value ?? u._rawLink ?? u.link ?? u.url;
|
|
163
164
|
return {
|
|
164
165
|
value: K,
|
|
165
|
-
label:
|
|
166
|
-
url:
|
|
167
|
-
protected:
|
|
168
|
-
isPrivate:
|
|
166
|
+
label: u.title || u.label,
|
|
167
|
+
url: u.link || u.url,
|
|
168
|
+
protected: h?.data?.[K] ?? !1,
|
|
169
|
+
isPrivate: u.isPrivate || u.private || (u?._rawLink?.includes("/customer") ?? !1)
|
|
169
170
|
// FIXME: HACK: 隐藏 /customer 菜单, 需要一个通用的解决方案,在嵌入的时候就决定是否是私有的
|
|
170
171
|
// icon: x.icon,
|
|
171
172
|
};
|
|
172
|
-
}).filter((
|
|
173
|
-
}, [N,
|
|
173
|
+
}).filter((u) => n || !u.isPrivate);
|
|
174
|
+
}, [N, s.data, h?.data, b, E, n]), o = c(() => l.find((e) => te(e.value) === te(g)), [l]), _ = c(() => {
|
|
175
|
+
const e = window.blocklet?.appName, x = [o?.label, f("userCenter.title")].filter(Boolean).join("-");
|
|
176
|
+
return e ? `${x} | ${e}` : x;
|
|
177
|
+
}, [o, f]), pe = y((e) => e && (Y(e) ? Z(e, {
|
|
174
178
|
...e.props || {},
|
|
175
|
-
userCenterTabs:
|
|
176
|
-
}) :
|
|
179
|
+
userCenterTabs: l
|
|
180
|
+
}) : ve.map(e, (t) => Y(t) ? Z(t, {
|
|
177
181
|
...t.props || {},
|
|
178
|
-
userCenterTabs:
|
|
179
|
-
}) : t))),
|
|
180
|
-
const t =
|
|
181
|
-
t && (window.location.href =
|
|
182
|
-
did: n ? void 0 :
|
|
182
|
+
userCenterTabs: l
|
|
183
|
+
}) : t))), me = y((e) => {
|
|
184
|
+
const t = l.find((x) => x.value === e);
|
|
185
|
+
t && (window.location.href = ie(t.url, {
|
|
186
|
+
did: n ? void 0 : m
|
|
183
187
|
}));
|
|
184
|
-
}), R =
|
|
185
|
-
|
|
188
|
+
}), R = c(() => /* @__PURE__ */ r(
|
|
189
|
+
Ne,
|
|
186
190
|
{
|
|
187
|
-
user:
|
|
188
|
-
settings: { userCenterTabs:
|
|
189
|
-
onSave: async (e) => e === "privacy" ? (await
|
|
191
|
+
user: s.data,
|
|
192
|
+
settings: { userCenterTabs: l },
|
|
193
|
+
onSave: async (e) => e === "privacy" ? (await h.runAsync(), h.data) : (e === "profile" && await i.refresh(), null),
|
|
190
194
|
isMobile: d,
|
|
191
|
-
onDestroySelf:
|
|
195
|
+
onDestroySelf: fe
|
|
192
196
|
}
|
|
193
|
-
), [
|
|
194
|
-
i?.user?.sourceProvider === "passkey" ?
|
|
195
|
-
}), M =
|
|
196
|
-
|
|
197
|
+
), [s.data, l, h.data, h.runAsync]), O = c(() => o && o?.value === z, [o]), $ = c(() => o && o?.value === C(k, "/profile") || o?.value === T, [o]), he = c(() => o && o?.value === W, [o]), xe = i.useOAuth(), ge = i.usePasskey(), q = y(() => {
|
|
198
|
+
i?.user?.sourceProvider === "passkey" ? ge.switchPassport(i.user) : ["google", "apple", "email", "github"].includes(i?.user?.sourceProvider ?? "") ? xe.switchOAuthPassport(i.user) : i && i.switchPassport();
|
|
199
|
+
}), M = c(() => $ ? /* @__PURE__ */ p(
|
|
200
|
+
a,
|
|
197
201
|
{
|
|
198
202
|
sx: {
|
|
199
203
|
display: "flex",
|
|
@@ -201,25 +205,25 @@ function Wr({
|
|
|
201
205
|
gap: 2.5
|
|
202
206
|
},
|
|
203
207
|
children: [
|
|
204
|
-
n ? /* @__PURE__ */
|
|
208
|
+
n ? /* @__PURE__ */ p(a, { sx: { border: "1px solid", borderColor: "divider", borderRadius: 1.5, p: 2 }, children: [
|
|
205
209
|
/* @__PURE__ */ r(
|
|
206
|
-
|
|
210
|
+
we,
|
|
207
211
|
{
|
|
208
212
|
sx: {
|
|
209
213
|
color: "text.primary",
|
|
210
214
|
fontWeight: 600,
|
|
211
215
|
mb: 2.5
|
|
212
216
|
},
|
|
213
|
-
children:
|
|
217
|
+
children: f("passport")
|
|
214
218
|
}
|
|
215
219
|
),
|
|
216
|
-
/* @__PURE__ */ r(
|
|
220
|
+
/* @__PURE__ */ r(He, { user: s.data })
|
|
217
221
|
] }) : null,
|
|
218
|
-
/* @__PURE__ */ r(
|
|
222
|
+
/* @__PURE__ */ r(Oe, { user: s.data })
|
|
219
223
|
]
|
|
220
224
|
}
|
|
221
|
-
) : O && n ? R :
|
|
222
|
-
|
|
225
|
+
) : O && n ? R : he && n ? /* @__PURE__ */ r(_e, { children: /* @__PURE__ */ r(Re, {}) }) : null, [O, $, s, n, F, R]), G = c(() => /* @__PURE__ */ r(
|
|
226
|
+
a,
|
|
223
227
|
{
|
|
224
228
|
sx: {
|
|
225
229
|
display: {
|
|
@@ -228,10 +232,10 @@ function Wr({
|
|
|
228
232
|
},
|
|
229
233
|
py: 3
|
|
230
234
|
},
|
|
231
|
-
children: /* @__PURE__ */ r(
|
|
235
|
+
children: /* @__PURE__ */ r(S, { children: f("emptyContent") })
|
|
232
236
|
}
|
|
233
|
-
), [n,
|
|
234
|
-
|
|
237
|
+
), [n, b]), Q = c(() => !h.data || h.loading ? /* @__PURE__ */ r(
|
|
238
|
+
a,
|
|
235
239
|
{
|
|
236
240
|
sx: {
|
|
237
241
|
height: "100%",
|
|
@@ -242,27 +246,27 @@ function Wr({
|
|
|
242
246
|
alignItems: "center",
|
|
243
247
|
flex: 1
|
|
244
248
|
},
|
|
245
|
-
children: /* @__PURE__ */ r(
|
|
249
|
+
children: /* @__PURE__ */ r(ye, {})
|
|
246
250
|
}
|
|
247
251
|
) : (
|
|
248
252
|
// eslint-disable-next-line react/jsx-no-useless-fragment
|
|
249
|
-
/* @__PURE__ */ r(
|
|
253
|
+
/* @__PURE__ */ r(a, { sx: { flex: 1 }, children: o?.protected && !n ? /* @__PURE__ */ r(a, { children: /* @__PURE__ */ r(S, { children: f("underProtected") }) }) : (
|
|
250
254
|
// eslint-disable-next-line react/jsx-no-useless-fragment
|
|
251
|
-
/* @__PURE__ */ r(
|
|
255
|
+
/* @__PURE__ */ r(X, { children: v ? /* @__PURE__ */ r(a, { ...B, children: pe(v) }) : /* @__PURE__ */ r(X, { children: M }) })
|
|
252
256
|
) })
|
|
253
|
-
), [
|
|
254
|
-
if (
|
|
257
|
+
), [h, o, n, v, B, M, b]), V = c(() => {
|
|
258
|
+
if (s.loading || i.loading)
|
|
255
259
|
return null;
|
|
256
|
-
if (
|
|
257
|
-
if (
|
|
258
|
-
return /* @__PURE__ */ r(
|
|
259
|
-
const
|
|
260
|
-
message:
|
|
260
|
+
if (s.error) {
|
|
261
|
+
if (s.error?.response?.status === 404)
|
|
262
|
+
return /* @__PURE__ */ r(a, { sx: { width: "100%" }, children: /* @__PURE__ */ r(De, { status: 404, description: f("noUserFound") }) });
|
|
263
|
+
const x = {
|
|
264
|
+
message: s.error.response?.data?.error || s.error.message || "error occurred"
|
|
261
265
|
};
|
|
262
|
-
return /* @__PURE__ */ r(
|
|
266
|
+
return /* @__PURE__ */ r(a, { sx: { width: "100%" }, children: /* @__PURE__ */ r(Ae, { error: x }) });
|
|
263
267
|
}
|
|
264
|
-
return !
|
|
265
|
-
|
|
268
|
+
return !m && !s.data ? U || /* @__PURE__ */ r(a, { sx: { width: "100%" }, children: /* @__PURE__ */ p(
|
|
269
|
+
a,
|
|
266
270
|
{
|
|
267
271
|
sx: {
|
|
268
272
|
display: "flex",
|
|
@@ -272,13 +276,13 @@ function Wr({
|
|
|
272
276
|
gap: 1
|
|
273
277
|
},
|
|
274
278
|
children: [
|
|
275
|
-
/* @__PURE__ */ r(
|
|
276
|
-
/* @__PURE__ */ r(
|
|
279
|
+
/* @__PURE__ */ r(S, { children: f("viewAfterLogin") }),
|
|
280
|
+
/* @__PURE__ */ r(Se, { size: "small", variant: "contained", onClick: () => i.login(), children: f("loginNow") })
|
|
277
281
|
]
|
|
278
282
|
}
|
|
279
|
-
) }) :
|
|
280
|
-
|
|
281
|
-
|
|
283
|
+
) }) : I ? /* @__PURE__ */ p(A, { children: [
|
|
284
|
+
l.length > 0 && g ? /* @__PURE__ */ r(
|
|
285
|
+
a,
|
|
282
286
|
{
|
|
283
287
|
sx: {
|
|
284
288
|
display: d ? "block" : "flex",
|
|
@@ -286,31 +290,31 @@ function Wr({
|
|
|
286
290
|
overflow: "auto",
|
|
287
291
|
padding: "1px"
|
|
288
292
|
},
|
|
289
|
-
children:
|
|
293
|
+
children: Q
|
|
290
294
|
}
|
|
291
295
|
) : null,
|
|
292
|
-
|
|
293
|
-
] }) : w ? /* @__PURE__ */ r(
|
|
294
|
-
|
|
296
|
+
l.length === 0 && G
|
|
297
|
+
] }) : w ? /* @__PURE__ */ r(A, { display: "flex", flexDirection: d ? "column" : "row", children: /* @__PURE__ */ r(
|
|
298
|
+
oe,
|
|
295
299
|
{
|
|
296
300
|
isMobile: d,
|
|
297
301
|
order: d ? 1 : "unset",
|
|
298
302
|
isMyself: n,
|
|
299
|
-
switchPassport:
|
|
303
|
+
switchPassport: q,
|
|
300
304
|
switchProfile: i.switchProfile,
|
|
301
|
-
user:
|
|
305
|
+
user: s.data,
|
|
302
306
|
showFullDid: !1,
|
|
303
307
|
onlyProfile: w,
|
|
304
|
-
refreshProfile:
|
|
308
|
+
refreshProfile: j,
|
|
305
309
|
sx: {
|
|
306
310
|
padding: d ? "16px 0 0 0" : "40px 24px 24px 40px",
|
|
307
311
|
...d ? {} : { width: 320, maxWidth: 320, flexShrink: 0 },
|
|
308
312
|
boxSizing: "content-box"
|
|
309
313
|
}
|
|
310
314
|
}
|
|
311
|
-
) }) : /* @__PURE__ */
|
|
312
|
-
/* @__PURE__ */
|
|
313
|
-
|
|
315
|
+
) }) : /* @__PURE__ */ p(A, { display: "flex", flexDirection: d ? "column" : "row", children: [
|
|
316
|
+
/* @__PURE__ */ p(
|
|
317
|
+
a,
|
|
314
318
|
{
|
|
315
319
|
className: "user-center-tabs",
|
|
316
320
|
sx: {
|
|
@@ -318,8 +322,8 @@ function Wr({
|
|
|
318
322
|
order: d ? 2 : "unset"
|
|
319
323
|
},
|
|
320
324
|
children: [
|
|
321
|
-
|
|
322
|
-
|
|
325
|
+
l.length > 0 && g ? /* @__PURE__ */ p(
|
|
326
|
+
a,
|
|
323
327
|
{
|
|
324
328
|
sx: {
|
|
325
329
|
display: "flex",
|
|
@@ -330,13 +334,13 @@ function Wr({
|
|
|
330
334
|
},
|
|
331
335
|
children: [
|
|
332
336
|
/* @__PURE__ */ r(
|
|
333
|
-
|
|
337
|
+
Me,
|
|
334
338
|
{
|
|
335
339
|
orientation: "horizontal",
|
|
336
340
|
variant: "line",
|
|
337
|
-
tabs:
|
|
338
|
-
current:
|
|
339
|
-
onChange:
|
|
341
|
+
tabs: l,
|
|
342
|
+
current: o?.value ?? g,
|
|
343
|
+
onChange: me,
|
|
340
344
|
enableTabClick: !0,
|
|
341
345
|
sx: {
|
|
342
346
|
mb: (e) => `${e.spacing(3)} !important`,
|
|
@@ -373,25 +377,25 @@ function Wr({
|
|
|
373
377
|
}
|
|
374
378
|
}
|
|
375
379
|
),
|
|
376
|
-
|
|
380
|
+
Q
|
|
377
381
|
]
|
|
378
382
|
}
|
|
379
383
|
) : null,
|
|
380
|
-
|
|
384
|
+
l.length === 0 && G
|
|
381
385
|
]
|
|
382
386
|
}
|
|
383
387
|
),
|
|
384
|
-
!d && /* @__PURE__ */ r(
|
|
388
|
+
!d && /* @__PURE__ */ r(Ce, { orientation: "vertical", sx: { ml: 5 } }),
|
|
385
389
|
/* @__PURE__ */ r(
|
|
386
|
-
|
|
390
|
+
oe,
|
|
387
391
|
{
|
|
388
392
|
isMobile: d,
|
|
389
393
|
order: d ? 1 : "unset",
|
|
390
394
|
isMyself: n,
|
|
391
|
-
switchPassport:
|
|
395
|
+
switchPassport: q,
|
|
392
396
|
switchProfile: i.switchProfile,
|
|
393
|
-
user:
|
|
394
|
-
refreshProfile:
|
|
397
|
+
user: s.data,
|
|
398
|
+
refreshProfile: j,
|
|
395
399
|
showFullDid: !1,
|
|
396
400
|
sx: {
|
|
397
401
|
padding: d ? "16px 0 0 0" : "40px 24px 24px 40px",
|
|
@@ -402,31 +406,32 @@ function Wr({
|
|
|
402
406
|
)
|
|
403
407
|
] });
|
|
404
408
|
}, [
|
|
405
|
-
o,
|
|
406
|
-
a,
|
|
407
|
-
n,
|
|
408
409
|
s,
|
|
409
|
-
|
|
410
|
+
l,
|
|
411
|
+
n,
|
|
412
|
+
o,
|
|
410
413
|
h,
|
|
411
|
-
|
|
414
|
+
g,
|
|
415
|
+
F,
|
|
412
416
|
M
|
|
413
|
-
]), J =
|
|
414
|
-
if (
|
|
415
|
-
const e =
|
|
417
|
+
]), J = c(() => n ? !1 : o?.isPrivate, [n, o]);
|
|
418
|
+
if (c(() => w ? !1 : !L && !g && l?.length > 0 || !o || J, [L, g, l, o, J, w])) {
|
|
419
|
+
const e = l[0]?.url, t = l.find((x) => x.value === e);
|
|
416
420
|
return e && !t?.isPrivate && window.location.replace(
|
|
417
|
-
|
|
418
|
-
did: n ? void 0 :
|
|
421
|
+
ie(e, {
|
|
422
|
+
did: n ? void 0 : m
|
|
419
423
|
})
|
|
420
424
|
), null;
|
|
421
425
|
}
|
|
422
|
-
return
|
|
423
|
-
/* @__PURE__ */ r(
|
|
424
|
-
/* @__PURE__ */
|
|
425
|
-
|
|
426
|
+
return I || w ? /* @__PURE__ */ p(a, { children: [
|
|
427
|
+
/* @__PURE__ */ r(re, { children: /* @__PURE__ */ r("title", { children: _ }) }),
|
|
428
|
+
/* @__PURE__ */ r(ne, { style: { display: "none" } }),
|
|
429
|
+
/* @__PURE__ */ p(ae, { children: [
|
|
430
|
+
V,
|
|
426
431
|
H
|
|
427
432
|
] })
|
|
428
|
-
] }) : /* @__PURE__ */
|
|
429
|
-
|
|
433
|
+
] }) : /* @__PURE__ */ p(
|
|
434
|
+
a,
|
|
430
435
|
{
|
|
431
436
|
sx: {
|
|
432
437
|
minHeight: "100vh",
|
|
@@ -434,16 +439,17 @@ function Wr({
|
|
|
434
439
|
flexDirection: "column"
|
|
435
440
|
},
|
|
436
441
|
children: [
|
|
437
|
-
/* @__PURE__ */ r(
|
|
438
|
-
/* @__PURE__ */
|
|
439
|
-
|
|
442
|
+
/* @__PURE__ */ r(re, { children: /* @__PURE__ */ r("title", { children: _ }) }),
|
|
443
|
+
/* @__PURE__ */ r(ne, { bordered: !0, ...de, maxWidth: "100%" }),
|
|
444
|
+
/* @__PURE__ */ p(ae, { children: [
|
|
445
|
+
V,
|
|
440
446
|
H
|
|
441
447
|
] }),
|
|
442
|
-
|
|
443
|
-
|
|
448
|
+
ce ? null : /* @__PURE__ */ r(
|
|
449
|
+
Le,
|
|
444
450
|
{
|
|
445
451
|
bordered: !0,
|
|
446
|
-
...
|
|
452
|
+
...ue,
|
|
447
453
|
sx: {
|
|
448
454
|
".MuiContainer-root": {
|
|
449
455
|
maxWidth: 1600
|
|
@@ -456,5 +462,5 @@ function Wr({
|
|
|
456
462
|
);
|
|
457
463
|
}
|
|
458
464
|
export {
|
|
459
|
-
|
|
465
|
+
Br as default
|
|
460
466
|
};
|
|
@@ -170,6 +170,9 @@ export declare const translations: {
|
|
|
170
170
|
error: string;
|
|
171
171
|
};
|
|
172
172
|
notImplemented: string;
|
|
173
|
+
userCenter: {
|
|
174
|
+
title: string;
|
|
175
|
+
};
|
|
173
176
|
};
|
|
174
177
|
en: {
|
|
175
178
|
settings: string;
|
|
@@ -343,5 +346,8 @@ export declare const translations: {
|
|
|
343
346
|
error: string;
|
|
344
347
|
};
|
|
345
348
|
notImplemented: string;
|
|
349
|
+
userCenter: {
|
|
350
|
+
title: string;
|
|
351
|
+
};
|
|
346
352
|
};
|
|
347
353
|
};
|
|
@@ -169,7 +169,10 @@ const e = {
|
|
|
169
169
|
abort: "取消删除账户",
|
|
170
170
|
error: "删除账户失败"
|
|
171
171
|
},
|
|
172
|
-
notImplemented: "操作未实现"
|
|
172
|
+
notImplemented: "操作未实现",
|
|
173
|
+
userCenter: {
|
|
174
|
+
title: "用户中心"
|
|
175
|
+
}
|
|
173
176
|
},
|
|
174
177
|
en: {
|
|
175
178
|
settings: "Settings",
|
|
@@ -342,7 +345,10 @@ const e = {
|
|
|
342
345
|
abort: "Delete account aborted",
|
|
343
346
|
error: "Delete account failed"
|
|
344
347
|
},
|
|
345
|
-
notImplemented: "This action is not implemented"
|
|
348
|
+
notImplemented: "This action is not implemented",
|
|
349
|
+
userCenter: {
|
|
350
|
+
title: "User Center"
|
|
351
|
+
}
|
|
346
352
|
}
|
|
347
353
|
};
|
|
348
354
|
export {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blocklet/ui-react",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.36",
|
|
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.36",
|
|
39
|
+
"@arcblock/icons": "3.0.36",
|
|
40
|
+
"@arcblock/react-hooks": "3.0.36",
|
|
41
41
|
"@arcblock/ws": "^1.21.0",
|
|
42
42
|
"@blocklet/constant": "^1.16.46",
|
|
43
43
|
"@blocklet/did-space-react": "^1.1.10",
|
|
@@ -61,6 +61,7 @@
|
|
|
61
61
|
"p-wait-for": "^5.0.2",
|
|
62
62
|
"prop-types": "^15.8.1",
|
|
63
63
|
"react-error-boundary": "^3.1.4",
|
|
64
|
+
"react-helmet": "^6.1.0",
|
|
64
65
|
"react-placeholder": "^4.1.0",
|
|
65
66
|
"semver": "^7.7.2",
|
|
66
67
|
"type-fest": "^4.41.0",
|
|
@@ -90,5 +91,5 @@
|
|
|
90
91
|
"jest": "^29.7.0",
|
|
91
92
|
"unbuild": "^2.0.0"
|
|
92
93
|
},
|
|
93
|
-
"gitHead": "
|
|
94
|
+
"gitHead": "8d2ee041615e72c57199253d5425b50872642e6e"
|
|
94
95
|
}
|
|
@@ -3,6 +3,7 @@ import { Box, CircularProgress, Divider, Typography } from '@mui/material';
|
|
|
3
3
|
import type { BoxProps, Theme } from '@mui/material';
|
|
4
4
|
import { useCreation, useMemoizedFn, useRequest } from 'ahooks';
|
|
5
5
|
import pWaitFor from 'p-wait-for';
|
|
6
|
+
import Helmet from 'react-helmet';
|
|
6
7
|
|
|
7
8
|
import { SessionContext } from '@arcblock/did-connect/lib/Session';
|
|
8
9
|
import Tabs from '@arcblock/ux/lib/Tabs';
|
|
@@ -263,6 +264,16 @@ export default function UserCenter({
|
|
|
263
264
|
return userCenterTabs.find((x) => withoutTrailingSlash(x.value) === withoutTrailingSlash(currentTab));
|
|
264
265
|
}, [userCenterTabs]);
|
|
265
266
|
|
|
267
|
+
const htmlTitle = useCreation(() => {
|
|
268
|
+
const blockletName = window.blocklet?.appName;
|
|
269
|
+
const titleGroup = [currentActiveTab?.label, t('userCenter.title')].filter(Boolean);
|
|
270
|
+
const title = titleGroup.join('-');
|
|
271
|
+
if (blockletName) {
|
|
272
|
+
return `${title} | ${blockletName}`;
|
|
273
|
+
}
|
|
274
|
+
return title;
|
|
275
|
+
}, [currentActiveTab, t]);
|
|
276
|
+
|
|
266
277
|
// 辅助函数:给 children 注入 userCenterTabs 属性
|
|
267
278
|
const renderChildrenWithProps = useMemoizedFn((childrenToRender: any) => {
|
|
268
279
|
if (!childrenToRender) return childrenToRender;
|
|
@@ -663,14 +674,17 @@ export default function UserCenter({
|
|
|
663
674
|
// 嵌入其它页面内时,只展示 content
|
|
664
675
|
if (embed || onlyProfile) {
|
|
665
676
|
return (
|
|
666
|
-
|
|
677
|
+
<Box>
|
|
667
678
|
{/* 在 Arcsphere 中,需要渲染 header 用于注入某些 bridge 方法,设置为隐藏状态 */}
|
|
679
|
+
<Helmet>
|
|
680
|
+
<title>{htmlTitle}</title>
|
|
681
|
+
</Helmet>
|
|
668
682
|
<Header style={{ display: 'none' }} />
|
|
669
683
|
<Main>
|
|
670
684
|
{content}
|
|
671
685
|
{confirmHolder}
|
|
672
686
|
</Main>
|
|
673
|
-
|
|
687
|
+
</Box>
|
|
674
688
|
);
|
|
675
689
|
}
|
|
676
690
|
|
|
@@ -681,6 +695,9 @@ export default function UserCenter({
|
|
|
681
695
|
display: 'flex',
|
|
682
696
|
flexDirection: 'column',
|
|
683
697
|
}}>
|
|
698
|
+
<Helmet>
|
|
699
|
+
<title>{htmlTitle}</title>
|
|
700
|
+
</Helmet>
|
|
684
701
|
<Header bordered {...headerProps} maxWidth="100%" />
|
|
685
702
|
<Main>
|
|
686
703
|
{content}
|
|
@@ -172,6 +172,9 @@ export const translations = {
|
|
|
172
172
|
error: '删除账户失败',
|
|
173
173
|
},
|
|
174
174
|
notImplemented: '操作未实现',
|
|
175
|
+
userCenter: {
|
|
176
|
+
title: '用户中心',
|
|
177
|
+
},
|
|
175
178
|
},
|
|
176
179
|
en: {
|
|
177
180
|
settings: 'Settings',
|
|
@@ -348,5 +351,8 @@ export const translations = {
|
|
|
348
351
|
error: 'Delete account failed',
|
|
349
352
|
},
|
|
350
353
|
notImplemented: 'This action is not implemented',
|
|
354
|
+
userCenter: {
|
|
355
|
+
title: 'User Center',
|
|
356
|
+
},
|
|
351
357
|
},
|
|
352
358
|
};
|