@blocklet/ui-react 3.0.35 → 3.0.37

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 f, Fragment as S } from "react/jsx-runtime";
2
- import { use as xe, isValidElement as X, cloneElement as Y, Children as ge } from "react";
3
- import { Box as l, Typography as be, CircularProgress as ve, Divider as we } from "@mui/material";
4
- import { useMemoizedFn as y, useCreation as u, useRequest as Z } from "ahooks";
5
- import ye from "p-wait-for";
6
- import { SessionContext as Ce } from "@arcblock/did-connect/lib/Session";
7
- import ke from "@arcblock/ux/lib/Tabs";
8
- import D from "@arcblock/ux/lib/Empty";
9
- import Pe from "@arcblock/ux/lib/Button";
10
- import Me from "@arcblock/ux/lib/Result";
11
- import { useConfirm as Se } from "@arcblock/ux/lib/Dialog";
12
- import { translate as De } from "@arcblock/ux/lib/Locale/util";
13
- import { useLocaleContext as ze } from "@arcblock/ux/lib/Locale/context";
14
- import { ErrorFallback as Te } from "@arcblock/ux/lib/ErrorBoundary";
15
- import { styled as se } from "@arcblock/ux/lib/Theme";
16
- import We from "lodash/cloneDeep";
17
- import { joinURL as C, getQuery as Ae, withoutTrailingSlash as ee, withQuery as re } from "ufo";
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 Ue from "../../Footer/index.js";
20
- import te from "../../Header/index.js";
21
- import { translations as Le } from "../libs/locales.js";
22
- import ie from "./user-info/user-basic-info.js";
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 Be, getLink as z, getLocalizedNavigation as Fe } from "../../blocklets.js";
34
- import Ie from "./passport.js";
35
- import je from "./settings.js";
36
- import { client as ne } from "../../libs/client.js";
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 He } from "../../contexts/config-user-space.js";
39
- import Ne from "./storage/index.js";
40
- import _e from "./nft.js";
41
- const T = C(k, "/nfts"), W = C(k, "/settings"), A = C(k, "/did-spaces"), oe = se(l)(({ theme: b }) => ({
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
- [b.breakpoints.up("md")]: {
53
+ [v.breakpoints.up("md")]: {
53
54
  flexDirection: "row"
54
55
  }
55
- })), U = se(l)(({ theme: b }) => ({
56
+ })), A = le(a)(({ theme: v }) => ({
56
57
  overflow: "hidden",
57
58
  flex: "revert",
58
- [b.breakpoints.up("md")]: {
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 Wr({
68
- children: b,
69
- notLoginContent: L = null,
70
- currentTab: h,
68
+ function Br({
69
+ children: v,
70
+ notLoginContent: U = null,
71
+ currentTab: g,
71
72
  contentProps: B = {},
72
- disableAutoRedirect: F = !1,
73
- hideFooter: ae = !1,
74
- headerProps: le = {},
75
- footerProps: de = {},
73
+ disableAutoRedirect: L = !1,
74
+ hideFooter: ce = !1,
75
+ headerProps: de = {},
76
+ footerProps: ue = {},
76
77
  userDid: P = void 0,
77
- stickySidebar: I = !1,
78
- embed: j = !1,
78
+ stickySidebar: F = !1,
79
+ embed: I = !1,
79
80
  onlyProfile: w = !1,
80
81
  // 只显示 profile 页面,用于 ArcSphere 只需要显示 Profile 的内容
81
- onDestroySelf: ue = void 0
82
+ onDestroySelf: fe = void 0
82
83
  }) {
83
- const { locale: x } = ze(), d = Ee({ key: "md" }), g = y((e, t = {}) => De(Le, e, x, "en", t)), i = xe(Ce)?.session, p = u(() => {
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 = Ae(e);
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 = u(() => i?.user ? p === i?.user?.did : !1, [p, i?.user?.did]), o = Z(
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 ye(() => i?.initialized), n)
92
+ if (await ke(() => i?.initialized), n)
92
93
  return i.user;
93
- if (p)
94
- return ne.user.getUserPublicInfo({ did: p });
94
+ if (m)
95
+ return se.user.getUserPublicInfo({ did: m });
95
96
  },
96
97
  {
97
- refreshDeps: [p, n, i?.initialized, i?.user]
98
+ refreshDeps: [m, n, i?.initialized, i?.user]
98
99
  }
99
- ), E = y(() => n ? i.refresh() : o.refresh()), m = Z(
100
- async () => o.data && h ? await ne.user.getUserPrivacyConfig({ did: p }) : null,
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: [p, o.data, h],
103
+ refreshDeps: [m, s.data, g],
103
104
  loadingDelay: 300
104
105
  }
105
- ), { confirmHolder: H } = Se({
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 = u(() => {
126
- const e = We(window.blocklet);
126
+ }), N = c(() => {
127
+ const e = Ue(window.blocklet);
127
128
  try {
128
- return Be(e);
129
+ return Ie(e);
129
130
  } catch (t) {
130
131
  return console.error("Failed to format blocklet info", t, e), e;
131
132
  }
132
- }, []), _ = u(() => {
133
+ }, []), E = c(() => {
133
134
  const e = {
134
- label: g("common.nft"),
135
+ label: f("common.nft"),
135
136
  protected: !1,
136
137
  isPrivate: !1,
137
138
  // true: 隐私数据,仅自己可见
138
139
  value: T,
139
- url: z(T, x)
140
+ url: D(T, b)
140
141
  };
141
142
  let t = [e];
142
143
  return n && (t = [
143
144
  e,
144
145
  {
145
- label: g("common.setting"),
146
+ label: f("common.setting"),
146
147
  protected: !0,
147
148
  isPrivate: !0,
148
- value: W,
149
- url: z(W, x)
149
+ value: z,
150
+ url: D(z, b)
150
151
  },
151
152
  {
152
- label: g("storageManagement"),
153
+ label: f("storageManagement"),
153
154
  protected: !0,
154
155
  isPrivate: !0,
155
- value: A,
156
- url: z(A, x)
156
+ value: W,
157
+ url: D(W, b)
157
158
  }
158
159
  ]), t;
159
- }, [n, x]), a = u(() => {
160
+ }, [n, b]), l = c(() => {
160
161
  const e = N?.navigation?.userCenter || [];
161
- return (Fe(e, x) || []).concat(_).map((c) => {
162
- const K = c.value ?? c._rawLink ?? c.link ?? c.url;
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: c.title || c.label,
166
- url: c.link || c.url,
167
- protected: m?.data?.[K] ?? !1,
168
- isPrivate: c.isPrivate || c.private || (c?._rawLink?.includes("/customer") ?? !1)
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((c) => n || !c.isPrivate);
173
- }, [N, o.data, m?.data, x, _, n]), s = u(() => a.find((e) => ee(e.value) === ee(h)), [a]), ce = y((e) => e && (X(e) ? Y(e, {
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: a
176
- }) : ge.map(e, (t) => X(t) ? Y(t, {
179
+ userCenterTabs: l
180
+ }) : ve.map(e, (t) => Y(t) ? Z(t, {
177
181
  ...t.props || {},
178
- userCenterTabs: a
179
- }) : t))), fe = y((e) => {
180
- const t = a.find((v) => v.value === e);
181
- t && (window.location.href = re(t.url, {
182
- did: n ? void 0 : p
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 = u(() => /* @__PURE__ */ r(
185
- je,
188
+ }), R = c(() => /* @__PURE__ */ r(
189
+ Ne,
186
190
  {
187
- user: o.data,
188
- settings: { userCenterTabs: a },
189
- onSave: async (e) => e === "privacy" ? (await m.runAsync(), m.data) : (e === "profile" && await i.refresh(), null),
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: ue
195
+ onDestroySelf: fe
192
196
  }
193
- ), [o.data, a, m.data, m.runAsync]), O = u(() => s && s?.value === W, [s]), q = u(() => s && s?.value === C(k, "/profile") || s?.value === T, [s]), pe = u(() => s && s?.value === A, [s]), me = i.useOAuth(), he = i.usePasskey(), Q = y(() => {
194
- i?.user?.sourceProvider === "passkey" ? he.switchPassport(i.user) : ["google", "apple", "email", "github"].includes(i?.user?.sourceProvider ?? "") ? me.switchOAuthPassport(i.user) : i && i.switchPassport();
195
- }), M = u(() => q ? /* @__PURE__ */ f(
196
- l,
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__ */ f(l, { sx: { border: "1px solid", borderColor: "divider", borderRadius: 1.5, p: 2 }, children: [
208
+ n ? /* @__PURE__ */ p(a, { sx: { border: "1px solid", borderColor: "divider", borderRadius: 1.5, p: 2 }, children: [
205
209
  /* @__PURE__ */ r(
206
- be,
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: g("passport")
217
+ children: f("passport")
214
218
  }
215
219
  ),
216
- /* @__PURE__ */ r(Ie, { user: o.data })
220
+ /* @__PURE__ */ r(He, { user: s.data })
217
221
  ] }) : null,
218
- /* @__PURE__ */ r(_e, { user: o.data })
222
+ /* @__PURE__ */ r(Oe, { user: s.data })
219
223
  ]
220
224
  }
221
- ) : O && n ? R : pe && n ? /* @__PURE__ */ r(He, { children: /* @__PURE__ */ r(Ne, {}) }) : null, [O, q, o, n, I, R]), V = u(() => /* @__PURE__ */ r(
222
- l,
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(D, { children: g("emptyContent") })
235
+ children: /* @__PURE__ */ r(S, { children: f("emptyContent") })
232
236
  }
233
- ), [n, x]), $ = u(() => !m.data || m.loading ? /* @__PURE__ */ r(
234
- l,
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(ve, {})
249
+ children: /* @__PURE__ */ r(ye, {})
246
250
  }
247
251
  ) : (
248
252
  // eslint-disable-next-line react/jsx-no-useless-fragment
249
- /* @__PURE__ */ r(l, { sx: { flex: 1 }, children: s?.protected && !n ? /* @__PURE__ */ r(l, { children: /* @__PURE__ */ r(D, { children: g("underProtected") }) }) : (
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(S, { children: b ? /* @__PURE__ */ r(l, { ...B, children: ce(b) }) : /* @__PURE__ */ r(S, { children: M }) })
255
+ /* @__PURE__ */ r(X, { children: v ? /* @__PURE__ */ r(a, { ...B, children: pe(v) }) : /* @__PURE__ */ r(X, { children: M }) })
252
256
  ) })
253
- ), [m, s, n, b, B, M, x]), G = u(() => {
254
- if (o.loading || i.loading)
257
+ ), [h, o, n, v, B, M, b]), V = c(() => {
258
+ if (s.loading || i.loading)
255
259
  return null;
256
- if (o.error) {
257
- if (o.error?.response?.status === 404)
258
- return /* @__PURE__ */ r(l, { sx: { width: "100%" }, children: /* @__PURE__ */ r(Me, { status: 404, description: g("noUserFound") }) });
259
- const v = {
260
- message: o.error.response?.data?.error || o.error.message || "error occurred"
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(l, { sx: { width: "100%" }, children: /* @__PURE__ */ r(Te, { error: v }) });
266
+ return /* @__PURE__ */ r(a, { sx: { width: "100%" }, children: /* @__PURE__ */ r(Ae, { error: x }) });
263
267
  }
264
- return !p && !o.data ? L || /* @__PURE__ */ r(l, { sx: { width: "100%" }, children: /* @__PURE__ */ f(
265
- l,
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(D, { children: g("viewAfterLogin") }),
276
- /* @__PURE__ */ r(Pe, { size: "small", variant: "contained", onClick: () => i.login(), children: g("loginNow") })
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
- ) }) : j ? /* @__PURE__ */ f(U, { children: [
280
- a.length > 0 && h ? /* @__PURE__ */ r(
281
- l,
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
- a.length === 0 && V
293
- ] }) : w ? /* @__PURE__ */ r(U, { display: "flex", flexDirection: d ? "column" : "row", children: /* @__PURE__ */ r(
294
- ie,
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: Q,
303
+ switchPassport: q,
300
304
  switchProfile: i.switchProfile,
301
- user: o.data,
305
+ user: s.data,
302
306
  showFullDid: !1,
303
307
  onlyProfile: w,
304
- refreshProfile: E,
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__ */ f(U, { display: "flex", flexDirection: d ? "column" : "row", children: [
312
- /* @__PURE__ */ f(
313
- l,
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
- a.length > 0 && h ? /* @__PURE__ */ f(
322
- l,
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
- ke,
337
+ Me,
334
338
  {
335
339
  orientation: "horizontal",
336
340
  variant: "line",
337
- tabs: a,
338
- current: s?.value ?? h,
339
- onChange: fe,
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
- a.length === 0 && V
384
+ l.length === 0 && G
381
385
  ]
382
386
  }
383
387
  ),
384
- !d && /* @__PURE__ */ r(we, { orientation: "vertical", sx: { ml: 5 } }),
388
+ !d && /* @__PURE__ */ r(Ce, { orientation: "vertical", sx: { ml: 5 } }),
385
389
  /* @__PURE__ */ r(
386
- ie,
390
+ oe,
387
391
  {
388
392
  isMobile: d,
389
393
  order: d ? 1 : "unset",
390
394
  isMyself: n,
391
- switchPassport: Q,
395
+ switchPassport: q,
392
396
  switchProfile: i.switchProfile,
393
- user: o.data,
394
- refreshProfile: E,
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
- m,
410
+ l,
411
+ n,
412
+ o,
410
413
  h,
411
- I,
414
+ g,
415
+ F,
412
416
  M
413
- ]), J = u(() => n ? !1 : s?.isPrivate, [n, s]);
414
- if (u(() => w ? !1 : !F && !h && a?.length > 0 || !s || J, [F, h, a, s, J, w])) {
415
- const e = a[0]?.url, t = a.find((v) => v.value === 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
- re(e, {
418
- did: n ? void 0 : p
421
+ ie(e, {
422
+ did: n ? void 0 : m
419
423
  })
420
424
  ), null;
421
425
  }
422
- return j || w ? /* @__PURE__ */ f(S, { children: [
423
- /* @__PURE__ */ r(te, { style: { display: "none" } }),
424
- /* @__PURE__ */ f(oe, { children: [
425
- G,
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__ */ f(
429
- l,
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(te, { bordered: !0, ...le, maxWidth: "100%" }),
438
- /* @__PURE__ */ f(oe, { children: [
439
- G,
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
- ae ? null : /* @__PURE__ */ r(
443
- Ue,
448
+ ce ? null : /* @__PURE__ */ r(
449
+ Le,
444
450
  {
445
451
  bordered: !0,
446
- ...de,
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
- Wr as default
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.35",
3
+ "version": "3.0.37",
4
4
  "description": "Some useful front-end web components that can be used in Blocklets.",
5
5
  "keywords": [
6
6
  "react",
@@ -35,12 +35,12 @@
35
35
  "dependencies": {
36
36
  "@abtnode/constant": "^1.16.46",
37
37
  "@abtnode/util": "^1.16.46",
38
- "@arcblock/bridge": "3.0.35",
39
- "@arcblock/icons": "3.0.35",
40
- "@arcblock/react-hooks": "3.0.35",
38
+ "@arcblock/bridge": "3.0.37",
39
+ "@arcblock/icons": "3.0.37",
40
+ "@arcblock/react-hooks": "3.0.37",
41
41
  "@arcblock/ws": "^1.21.0",
42
42
  "@blocklet/constant": "^1.16.46",
43
- "@blocklet/did-space-react": "^1.1.10",
43
+ "@blocklet/did-space-react": "^1.1.11",
44
44
  "@iconify-icons/logos": "^1.2.36",
45
45
  "@iconify-icons/material-symbols": "^1.2.58",
46
46
  "@iconify-icons/tabler": "^1.2.95",
@@ -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": "96e21256a13c640548c59ccd807a61e6faae35f8"
94
+ "gitHead": "7b09f31c3bd00c1472469dc926f7ee9e74133085"
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
  };