@blocklet/ui-react 3.4.13 → 3.4.15
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,26 +1,26 @@
|
|
|
1
|
-
import { jsx as r, jsxs as
|
|
2
|
-
import { use as
|
|
3
|
-
import { Box as a, Typography as B, CircularProgress as
|
|
4
|
-
import { useMemoizedFn as
|
|
5
|
-
import
|
|
1
|
+
import { jsx as r, jsxs as h } from "react/jsx-runtime";
|
|
2
|
+
import { use as Pe, useMemo as Se, isValidElement as ie, cloneElement as oe, Children as Me } from "react";
|
|
3
|
+
import { Box as a, Typography as B, CircularProgress as De, Divider as Fe } from "@mui/material";
|
|
4
|
+
import { useMemoizedFn as S, useCreation as c, useRequest as ne } from "ahooks";
|
|
5
|
+
import Te from "p-wait-for";
|
|
6
6
|
import se from "react-helmet";
|
|
7
|
-
import { SessionContext as
|
|
8
|
-
import
|
|
7
|
+
import { SessionContext as ze } from "@arcblock/did-connect-react/lib/Session";
|
|
8
|
+
import We from "@arcblock/ux/lib/Tabs";
|
|
9
9
|
import I from "@arcblock/ux/lib/Empty";
|
|
10
|
-
import
|
|
11
|
-
import
|
|
12
|
-
import { useConfirm as
|
|
13
|
-
import { translate as
|
|
14
|
-
import { useLocaleContext as
|
|
15
|
-
import { ErrorFallback as
|
|
16
|
-
import { styled as
|
|
17
|
-
import
|
|
18
|
-
import { joinURL as
|
|
19
|
-
import { getBlockletSDK as
|
|
20
|
-
import { isSupportFollow as
|
|
21
|
-
import { PROFILE_URL as
|
|
10
|
+
import Ae from "@arcblock/ux/lib/Button";
|
|
11
|
+
import Le from "@arcblock/ux/lib/Result";
|
|
12
|
+
import { useConfirm as Ue } from "@arcblock/ux/lib/Dialog";
|
|
13
|
+
import { translate as Be } from "@arcblock/ux/lib/Locale/util";
|
|
14
|
+
import { useLocaleContext as Ie } from "@arcblock/ux/lib/Locale/context";
|
|
15
|
+
import { ErrorFallback as Ne } from "@arcblock/ux/lib/ErrorBoundary";
|
|
16
|
+
import { styled as me } from "@arcblock/ux/lib/Theme";
|
|
17
|
+
import je from "lodash/cloneDeep";
|
|
18
|
+
import { joinURL as M, getQuery as He, parseURL as le, withoutTrailingSlash as ae, withQuery as ue } from "ufo";
|
|
19
|
+
import { getBlockletSDK as Ee } from "@blocklet/js-sdk";
|
|
20
|
+
import { isSupportFollow as Re } from "@arcblock/ux/lib/Util";
|
|
21
|
+
import { PROFILE_URL as D } from "@arcblock/ux/lib/Util/constant";
|
|
22
22
|
import _e from "../../Footer/index.js";
|
|
23
|
-
import
|
|
23
|
+
import ce from "../../Header/index.js";
|
|
24
24
|
import { translations as Oe } from "../libs/locales.js";
|
|
25
25
|
import de from "./user-info/user-basic-info.js";
|
|
26
26
|
import "@mui/icons-material";
|
|
@@ -33,20 +33,20 @@ import "@iconify-icons/material-symbols/settings-input-antenna-rounded";
|
|
|
33
33
|
import "@arcblock/ux/lib/RelativeTime";
|
|
34
34
|
import "@arcblock/ux/lib/UserCard/Content/shorten-label";
|
|
35
35
|
import "./user-info/switch-role.js";
|
|
36
|
-
import { formatBlockletInfo as
|
|
37
|
-
import
|
|
38
|
-
import
|
|
39
|
-
import
|
|
40
|
-
import { ConfigUserSpaceProvider as
|
|
41
|
-
import
|
|
42
|
-
import
|
|
43
|
-
import { UserFollowersProvider as
|
|
44
|
-
import
|
|
45
|
-
const T =
|
|
46
|
-
(
|
|
47
|
-
|
|
48
|
-
) || [T, z, W, j].includes(
|
|
49
|
-
),
|
|
36
|
+
import { formatBlockletInfo as $e, getLink as C, getLocalizedNavigation as qe } from "../../blocklets.js";
|
|
37
|
+
import Ge from "./passport.js";
|
|
38
|
+
import Qe from "./settings.js";
|
|
39
|
+
import Ke from "../../hooks/use-mobile.js";
|
|
40
|
+
import { ConfigUserSpaceProvider as Ve } from "../../contexts/config-user-space.js";
|
|
41
|
+
import Je from "./storage/index.js";
|
|
42
|
+
import Xe from "./nft.js";
|
|
43
|
+
import { UserFollowersProvider as fe } from "../../contexts/user-followers.js";
|
|
44
|
+
import Ye from "./fallback.js";
|
|
45
|
+
const T = M(D, "/nfts"), z = M(D, "/settings"), W = M(D, "/did-spaces"), j = M(D, "/user-followers"), Ze = (b) => b.some(
|
|
46
|
+
(k) => ["/userCenter/nfts", "/userCenter/user-followers", "/userCenter/settings", "/userCenter/did-spaces"].includes(
|
|
47
|
+
k.id
|
|
48
|
+
) || [T, z, W, j].includes(k.link)
|
|
49
|
+
), pe = me(a)(({ theme: b }) => ({
|
|
50
50
|
flex: 1,
|
|
51
51
|
boxSizing: "border-box",
|
|
52
52
|
padding: "0 16px",
|
|
@@ -60,7 +60,7 @@ const T = S(M, "/nfts"), z = S(M, "/settings"), W = S(M, "/did-spaces"), j = S(M
|
|
|
60
60
|
[b.breakpoints.up("md")]: {
|
|
61
61
|
flexDirection: "row"
|
|
62
62
|
}
|
|
63
|
-
})), N =
|
|
63
|
+
})), N = me(a)(({ theme: b }) => ({
|
|
64
64
|
overflow: "hidden",
|
|
65
65
|
flex: "revert",
|
|
66
66
|
[b.breakpoints.up("md")]: {
|
|
@@ -72,45 +72,45 @@ const T = S(M, "/nfts"), z = S(M, "/settings"), W = S(M, "/did-spaces"), j = S(M
|
|
|
72
72
|
}
|
|
73
73
|
}
|
|
74
74
|
}));
|
|
75
|
-
function
|
|
75
|
+
function Gr({
|
|
76
76
|
children: b,
|
|
77
|
-
notLoginContent:
|
|
77
|
+
notLoginContent: k = null,
|
|
78
78
|
currentTab: v,
|
|
79
79
|
contentProps: H = {},
|
|
80
80
|
disableAutoRedirect: E = !1,
|
|
81
|
-
hideFooter:
|
|
82
|
-
headerProps:
|
|
83
|
-
footerProps:
|
|
81
|
+
hideFooter: he = !1,
|
|
82
|
+
headerProps: xe = {},
|
|
83
|
+
footerProps: ge = {},
|
|
84
84
|
userDid: A = void 0,
|
|
85
|
-
stickySidebar:
|
|
86
|
-
embed:
|
|
87
|
-
onlyProfile:
|
|
85
|
+
stickySidebar: R = !1,
|
|
86
|
+
embed: F = !1,
|
|
87
|
+
onlyProfile: P = !1,
|
|
88
88
|
// 只显示 profile 页面,用于 ArcSphere 只需要显示 Profile 的内容
|
|
89
|
-
onDestroySelf:
|
|
89
|
+
onDestroySelf: be = void 0
|
|
90
90
|
}) {
|
|
91
|
-
const
|
|
91
|
+
const _ = Ee(), { locale: m, defaultLocale: w } = Ie(), u = Ke({ key: "md" }), f = S((e, i = {}) => Be(Oe, e, m, "en", i)), t = Pe(ze)?.session, x = c(() => {
|
|
92
92
|
if (A)
|
|
93
93
|
return A;
|
|
94
|
-
const e = window.location.href, i =
|
|
94
|
+
const e = window.location.href, i = He(e);
|
|
95
95
|
return i?.did ? Array.isArray(i.did) ? i.did[0] : i.did : t?.user?.did;
|
|
96
|
-
}, [t?.user?.did, A]), o =
|
|
96
|
+
}, [t?.user?.did, A]), o = c(() => t?.user ? x === t?.user?.did : !1, [x, t?.user?.did]), y = Se(() => !!t?.user && Re(), [t?.user]), n = ne(
|
|
97
97
|
// eslint-disable-next-line consistent-return
|
|
98
98
|
async () => {
|
|
99
|
-
if (await
|
|
99
|
+
if (await Te(() => t?.initialized), o)
|
|
100
100
|
return t.user;
|
|
101
|
-
if (
|
|
102
|
-
return
|
|
101
|
+
if (x)
|
|
102
|
+
return _.user.getUserPublicInfo({ did: x });
|
|
103
103
|
},
|
|
104
104
|
{
|
|
105
|
-
refreshDeps: [
|
|
105
|
+
refreshDeps: [x, o, t?.initialized, t?.user]
|
|
106
106
|
}
|
|
107
|
-
),
|
|
108
|
-
async () => n.data && v ? await
|
|
107
|
+
), O = S(() => o ? t.refresh() : n.refresh()), g = ne(
|
|
108
|
+
async () => n.data && v ? await _.user.getUserPrivacyConfig({ did: x }) : null,
|
|
109
109
|
{
|
|
110
|
-
refreshDeps: [
|
|
110
|
+
refreshDeps: [x, n.data, v],
|
|
111
111
|
loadingDelay: 300
|
|
112
112
|
}
|
|
113
|
-
), { confirmHolder: $ } =
|
|
113
|
+
), { confirmHolder: $ } = Ue({
|
|
114
114
|
fullScreen: u,
|
|
115
115
|
sx: {
|
|
116
116
|
".MuiDialog-paper": {
|
|
@@ -130,29 +130,29 @@ function qr({
|
|
|
130
130
|
}
|
|
131
131
|
}
|
|
132
132
|
}
|
|
133
|
-
}), q =
|
|
134
|
-
const e =
|
|
133
|
+
}), q = c(() => {
|
|
134
|
+
const e = je(window.blocklet);
|
|
135
135
|
try {
|
|
136
|
-
return
|
|
136
|
+
return $e(e);
|
|
137
137
|
} catch (i) {
|
|
138
138
|
return console.error("Failed to format blocklet info", i, e), e;
|
|
139
139
|
}
|
|
140
|
-
}, []), G =
|
|
140
|
+
}, []), G = c(() => {
|
|
141
141
|
const e = {
|
|
142
142
|
label: f("common.nft"),
|
|
143
143
|
protected: !1,
|
|
144
144
|
isPrivate: !1,
|
|
145
145
|
// true: 隐私数据,仅自己可见
|
|
146
146
|
value: T,
|
|
147
|
-
url:
|
|
147
|
+
url: C(T, m, w)
|
|
148
148
|
}, i = {
|
|
149
149
|
label: f("userFollowers"),
|
|
150
150
|
protected: !1,
|
|
151
151
|
isPrivate: !1,
|
|
152
152
|
value: j,
|
|
153
|
-
url:
|
|
153
|
+
url: C(j, m, w)
|
|
154
154
|
};
|
|
155
|
-
let p =
|
|
155
|
+
let p = y ? [e, i] : [e];
|
|
156
156
|
if (o) {
|
|
157
157
|
const U = [
|
|
158
158
|
e,
|
|
@@ -161,61 +161,67 @@ function qr({
|
|
|
161
161
|
protected: !0,
|
|
162
162
|
isPrivate: !0,
|
|
163
163
|
value: z,
|
|
164
|
-
url:
|
|
164
|
+
url: C(z, m, w)
|
|
165
165
|
},
|
|
166
166
|
{
|
|
167
167
|
label: f("storageManagement"),
|
|
168
168
|
protected: !0,
|
|
169
169
|
isPrivate: !0,
|
|
170
170
|
value: W,
|
|
171
|
-
url:
|
|
171
|
+
url: C(W, m, w)
|
|
172
172
|
}
|
|
173
173
|
];
|
|
174
|
-
p =
|
|
174
|
+
p = y ? [...U, i] : U;
|
|
175
175
|
}
|
|
176
176
|
return p;
|
|
177
|
-
}, [o,
|
|
178
|
-
const e = q?.navigation?.userCenter || [], i =
|
|
179
|
-
return (
|
|
180
|
-
const te =
|
|
177
|
+
}, [o, m, y]), l = c(() => {
|
|
178
|
+
const e = q?.navigation?.userCenter || [], i = Ze(e);
|
|
179
|
+
return (qe({ navigation: e, locale: m, defaultLocale: w }) || []).concat(i ? [] : G).map((d) => {
|
|
180
|
+
const te = d.value ?? d._rawLink ?? d.link ?? d.url;
|
|
181
181
|
return {
|
|
182
182
|
value: te,
|
|
183
|
-
label:
|
|
184
|
-
url:
|
|
183
|
+
label: d.title || d.label,
|
|
184
|
+
url: d.link || d.url,
|
|
185
185
|
protected: g?.data?.[te] ?? !1,
|
|
186
|
-
isPrivate:
|
|
186
|
+
isPrivate: d.isPrivate || d.private || (C(d._rawLink, m, w)?.includes?.("/customer") ?? !1),
|
|
187
187
|
// FIXME: HACK: 隐藏 /customer 菜单, 需要一个通用的解决方案,在嵌入的时候就决定是否是私有的
|
|
188
|
-
followersOnly:
|
|
188
|
+
followersOnly: d.component === "did-comments"
|
|
189
189
|
// 是否开启仅粉丝可查看的功能,目前只对 discuss kit 开启
|
|
190
190
|
// icon: x.icon,
|
|
191
191
|
};
|
|
192
|
-
}).filter((
|
|
193
|
-
}, [q, n.data, g?.data,
|
|
192
|
+
}).filter((d) => o || !d.isPrivate);
|
|
193
|
+
}, [q, n.data, g?.data, m, G, o]), s = c(() => l.find((e) => {
|
|
194
|
+
try {
|
|
195
|
+
return le(ae(C(e.value, m, w))).pathname === le(ae(v)).pathname;
|
|
196
|
+
} catch {
|
|
197
|
+
return !1;
|
|
198
|
+
}
|
|
199
|
+
}), [l]), Q = c(() => {
|
|
194
200
|
const e = window.blocklet?.appName, p = [s?.label, f("userCenter.title")].filter(Boolean).join("-");
|
|
195
201
|
return e ? `${p} | ${e}` : p;
|
|
196
|
-
}, [s, f]),
|
|
202
|
+
}, [s, f]), ve = S((e) => e && (ie(e) ? oe(e, {
|
|
197
203
|
...e.props || {},
|
|
198
204
|
userCenterTabs: l
|
|
199
|
-
}) :
|
|
205
|
+
}) : Me.map(e, (i) => ie(i) ? oe(i, {
|
|
200
206
|
...i.props || {},
|
|
201
207
|
userCenterTabs: l
|
|
202
|
-
}) : i))),
|
|
208
|
+
}) : i))), we = S((e) => {
|
|
203
209
|
const i = l.find((p) => p.value === e);
|
|
204
|
-
i && (window.location.href =
|
|
205
|
-
did: o ? void 0 :
|
|
210
|
+
i && (window.location.href = ue(i.url, {
|
|
211
|
+
did: o ? void 0 : x
|
|
206
212
|
}));
|
|
207
|
-
}), K =
|
|
208
|
-
|
|
213
|
+
}), K = c(() => /* @__PURE__ */ r(
|
|
214
|
+
Qe,
|
|
209
215
|
{
|
|
210
216
|
user: n.data,
|
|
211
217
|
settings: { userCenterTabs: l },
|
|
212
218
|
onSave: async (e) => e === "privacy" ? (await g.runAsync(), g.data) : (e === "profile" && await t.refresh(), null),
|
|
213
219
|
isMobile: u,
|
|
214
|
-
onDestroySelf:
|
|
220
|
+
onDestroySelf: be
|
|
215
221
|
}
|
|
216
|
-
), [n.data, l, g.data, g.runAsync]), V =
|
|
217
|
-
t?.user?.sourceProvider === "passkey" ?
|
|
218
|
-
}), L =
|
|
222
|
+
), [n.data, l, g.data, g.runAsync]), V = c(() => s && s?.value === z, [s]), J = c(() => s && s?.value === M(D, "/profile") || s?.value === T, [s]), ye = c(() => s && s?.value === W, [s]), Ce = t.useOAuth(), ke = t.usePasskey(), X = S(() => {
|
|
223
|
+
t?.user?.sourceProvider === "passkey" ? ke.switchPassport(t.user) : ["google", "apple", "email", "github"].includes(t?.user?.sourceProvider ?? "") ? Ce.switchOAuthPassport(t.user) : t && t.switchPassport();
|
|
224
|
+
}), L = c(() => J ? /* @__PURE__ */ h(
|
|
219
225
|
a,
|
|
220
226
|
{
|
|
221
227
|
sx: {
|
|
@@ -224,7 +230,7 @@ function qr({
|
|
|
224
230
|
gap: 2.5
|
|
225
231
|
},
|
|
226
232
|
children: [
|
|
227
|
-
o ? /* @__PURE__ */
|
|
233
|
+
o ? /* @__PURE__ */ h(a, { sx: { border: "1px solid", borderColor: "divider", borderRadius: 1.5, p: 2 }, children: [
|
|
228
234
|
/* @__PURE__ */ r(
|
|
229
235
|
B,
|
|
230
236
|
{
|
|
@@ -236,12 +242,12 @@ function qr({
|
|
|
236
242
|
children: f("passport")
|
|
237
243
|
}
|
|
238
244
|
),
|
|
239
|
-
/* @__PURE__ */ r(
|
|
245
|
+
/* @__PURE__ */ r(Ge, { user: n.data })
|
|
240
246
|
] }) : null,
|
|
241
|
-
/* @__PURE__ */ r(
|
|
247
|
+
/* @__PURE__ */ r(Xe, { user: n.data })
|
|
242
248
|
]
|
|
243
249
|
}
|
|
244
|
-
) : V && o ? K :
|
|
250
|
+
) : V && o ? K : ye && o ? /* @__PURE__ */ r(Ve, { children: /* @__PURE__ */ r(Je, {}) }) : null, [V, J, n, o, R, K]), Y = c(() => /* @__PURE__ */ r(
|
|
245
251
|
a,
|
|
246
252
|
{
|
|
247
253
|
sx: {
|
|
@@ -253,7 +259,7 @@ function qr({
|
|
|
253
259
|
},
|
|
254
260
|
children: /* @__PURE__ */ r(I, { children: f("emptyContent") })
|
|
255
261
|
}
|
|
256
|
-
), [o,
|
|
262
|
+
), [o, m]), Z = c(() => !g.data || g.loading ? /* @__PURE__ */ r(
|
|
257
263
|
a,
|
|
258
264
|
{
|
|
259
265
|
sx: {
|
|
@@ -265,28 +271,28 @@ function qr({
|
|
|
265
271
|
alignItems: "center",
|
|
266
272
|
flex: 1
|
|
267
273
|
},
|
|
268
|
-
children: /* @__PURE__ */ r(
|
|
274
|
+
children: /* @__PURE__ */ r(De, {})
|
|
269
275
|
}
|
|
270
276
|
) : /* @__PURE__ */ r(a, { sx: { flex: 1 }, children: /* @__PURE__ */ r(
|
|
271
|
-
|
|
277
|
+
Ye,
|
|
272
278
|
{
|
|
273
|
-
isSupportFollow:
|
|
279
|
+
isSupportFollow: y,
|
|
274
280
|
currentActiveTab: s,
|
|
275
281
|
isMyself: o,
|
|
276
|
-
children: b ? /* @__PURE__ */ r(a, { ...H, children:
|
|
282
|
+
children: b ? /* @__PURE__ */ r(a, { ...H, children: ve(b) }) : L
|
|
277
283
|
}
|
|
278
|
-
) }), [g, s, o, b, H, L,
|
|
284
|
+
) }), [g, s, o, b, H, L, m]), ee = c(() => {
|
|
279
285
|
if (n.loading || t.loading)
|
|
280
286
|
return null;
|
|
281
287
|
if (n.error) {
|
|
282
288
|
if (n.error?.response?.status === 404)
|
|
283
|
-
return /* @__PURE__ */ r(a, { sx: { width: "100%" }, children: /* @__PURE__ */ r(
|
|
289
|
+
return /* @__PURE__ */ r(a, { sx: { width: "100%" }, children: /* @__PURE__ */ r(Le, { status: 404, description: f("noUserFound") }) });
|
|
284
290
|
const p = {
|
|
285
291
|
message: n.error.response?.data?.error || n.error.message || "error occurred"
|
|
286
292
|
};
|
|
287
|
-
return /* @__PURE__ */ r(a, { sx: { width: "100%" }, children: /* @__PURE__ */ r(
|
|
293
|
+
return /* @__PURE__ */ r(a, { sx: { width: "100%" }, children: /* @__PURE__ */ r(Ne, { error: p }) });
|
|
288
294
|
}
|
|
289
|
-
return !
|
|
295
|
+
return !x && !n.data ? k || /* @__PURE__ */ r(a, { sx: { width: "100%" }, children: /* @__PURE__ */ h(
|
|
290
296
|
a,
|
|
291
297
|
{
|
|
292
298
|
sx: {
|
|
@@ -298,13 +304,13 @@ function qr({
|
|
|
298
304
|
},
|
|
299
305
|
children: [
|
|
300
306
|
/* @__PURE__ */ r(I, { children: f("viewAfterLogin") }),
|
|
301
|
-
/* @__PURE__ */ r(
|
|
307
|
+
/* @__PURE__ */ r(Ae, { size: "small", variant: "contained", onClick: () => t.login(), children: f("loginNow") })
|
|
302
308
|
]
|
|
303
309
|
}
|
|
304
|
-
) }) :
|
|
310
|
+
) }) : x && !n.data && !n.loading ? /* @__PURE__ */ r(I, { style: { width: "100%", paddingTop: 16 }, children: /* @__PURE__ */ h(a, { sx: { textAlign: "center", width: "100%" }, children: [
|
|
305
311
|
/* @__PURE__ */ r(B, { variant: "body1", sx: { fontSize: 18, fontWeight: 500 }, children: f("userNotFound") }),
|
|
306
312
|
/* @__PURE__ */ r(B, { variant: "body1", color: "text.secondary", children: f("userNotFoundDescription") })
|
|
307
|
-
] }) }) :
|
|
313
|
+
] }) }) : F ? /* @__PURE__ */ h(N, { children: [
|
|
308
314
|
l.length > 0 && v ? /* @__PURE__ */ r(
|
|
309
315
|
a,
|
|
310
316
|
{
|
|
@@ -318,7 +324,7 @@ function qr({
|
|
|
318
324
|
}
|
|
319
325
|
) : null,
|
|
320
326
|
l.length === 0 && Y
|
|
321
|
-
] }) :
|
|
327
|
+
] }) : P ? /* @__PURE__ */ r(N, { display: "flex", flexDirection: u ? "column" : "row", children: /* @__PURE__ */ r(
|
|
322
328
|
de,
|
|
323
329
|
{
|
|
324
330
|
isMobile: u,
|
|
@@ -328,17 +334,17 @@ function qr({
|
|
|
328
334
|
switchProfile: t.switchProfile,
|
|
329
335
|
user: n.data,
|
|
330
336
|
showFullDid: !1,
|
|
331
|
-
onlyProfile:
|
|
332
|
-
refreshProfile:
|
|
333
|
-
isShowSocialActions:
|
|
337
|
+
onlyProfile: P,
|
|
338
|
+
refreshProfile: O,
|
|
339
|
+
isShowSocialActions: y,
|
|
334
340
|
sx: {
|
|
335
341
|
padding: u ? "16px 0 0 0" : "40px 24px 24px 40px",
|
|
336
342
|
...u ? {} : { width: 320, maxWidth: 320, flexShrink: 0 },
|
|
337
343
|
boxSizing: "content-box"
|
|
338
344
|
}
|
|
339
345
|
}
|
|
340
|
-
) }) : /* @__PURE__ */
|
|
341
|
-
/* @__PURE__ */
|
|
346
|
+
) }) : /* @__PURE__ */ h(N, { display: "flex", flexDirection: u ? "column" : "row", children: [
|
|
347
|
+
/* @__PURE__ */ h(
|
|
342
348
|
a,
|
|
343
349
|
{
|
|
344
350
|
className: "user-center-tabs",
|
|
@@ -348,7 +354,7 @@ function qr({
|
|
|
348
354
|
width: u ? "unset" : "calc(100% - 424px)"
|
|
349
355
|
},
|
|
350
356
|
children: [
|
|
351
|
-
l.length > 0 && v ? /* @__PURE__ */
|
|
357
|
+
l.length > 0 && v ? /* @__PURE__ */ h(
|
|
352
358
|
a,
|
|
353
359
|
{
|
|
354
360
|
sx: {
|
|
@@ -360,13 +366,13 @@ function qr({
|
|
|
360
366
|
},
|
|
361
367
|
children: [
|
|
362
368
|
/* @__PURE__ */ r(
|
|
363
|
-
|
|
369
|
+
We,
|
|
364
370
|
{
|
|
365
371
|
orientation: "horizontal",
|
|
366
372
|
variant: "line",
|
|
367
373
|
tabs: l,
|
|
368
374
|
current: s?.value ?? v,
|
|
369
|
-
onChange:
|
|
375
|
+
onChange: we,
|
|
370
376
|
enableTabClick: !0,
|
|
371
377
|
sx: {
|
|
372
378
|
mb: (e) => `${e.spacing(3)} !important`,
|
|
@@ -411,7 +417,7 @@ function qr({
|
|
|
411
417
|
]
|
|
412
418
|
}
|
|
413
419
|
),
|
|
414
|
-
!u && /* @__PURE__ */ r(
|
|
420
|
+
!u && /* @__PURE__ */ r(Fe, { orientation: "vertical", sx: { ml: 5 } }),
|
|
415
421
|
/* @__PURE__ */ r(
|
|
416
422
|
de,
|
|
417
423
|
{
|
|
@@ -421,9 +427,9 @@ function qr({
|
|
|
421
427
|
switchPassport: X,
|
|
422
428
|
switchProfile: t.switchProfile,
|
|
423
429
|
user: n.data,
|
|
424
|
-
refreshProfile:
|
|
430
|
+
refreshProfile: O,
|
|
425
431
|
showFullDid: !1,
|
|
426
|
-
isShowSocialActions:
|
|
432
|
+
isShowSocialActions: y,
|
|
427
433
|
sx: {
|
|
428
434
|
padding: u ? "16px 0 0 0" : "40px 24px 24px 40px",
|
|
429
435
|
...u ? {} : { width: 320, maxWidth: 320, flexShrink: 0 },
|
|
@@ -439,34 +445,34 @@ function qr({
|
|
|
439
445
|
s,
|
|
440
446
|
g,
|
|
441
447
|
v,
|
|
442
|
-
|
|
448
|
+
R,
|
|
443
449
|
L
|
|
444
|
-
]), re =
|
|
445
|
-
if (
|
|
450
|
+
]), re = c(() => o ? !1 : s?.isPrivate, [o, s]);
|
|
451
|
+
if (c(() => P || F || !l.length || !t.user ? !1 : !E && !v && l?.length > 0 || !s || re, [
|
|
446
452
|
E,
|
|
447
453
|
v,
|
|
448
454
|
l,
|
|
449
455
|
s,
|
|
450
456
|
re,
|
|
451
|
-
|
|
457
|
+
P,
|
|
452
458
|
t.user,
|
|
453
|
-
|
|
459
|
+
F
|
|
454
460
|
])) {
|
|
455
461
|
const e = l[0]?.url, i = l.find((p) => p.value === e);
|
|
456
462
|
return e && !i?.isPrivate && window.location.replace(
|
|
457
|
-
|
|
458
|
-
did: o ? void 0 :
|
|
463
|
+
ue(e, {
|
|
464
|
+
did: o ? void 0 : x
|
|
459
465
|
})
|
|
460
466
|
), null;
|
|
461
467
|
}
|
|
462
|
-
return
|
|
468
|
+
return F || P ? /* @__PURE__ */ h(a, { children: [
|
|
463
469
|
/* @__PURE__ */ r(se, { children: /* @__PURE__ */ r("title", { children: Q }) }),
|
|
464
|
-
/* @__PURE__ */ r(
|
|
465
|
-
/* @__PURE__ */
|
|
466
|
-
/* @__PURE__ */ r(
|
|
470
|
+
/* @__PURE__ */ r(ce, { style: { display: "none" } }),
|
|
471
|
+
/* @__PURE__ */ h(pe, { children: [
|
|
472
|
+
/* @__PURE__ */ r(fe, { isMySelf: o, userDid: n.data?.did ?? "", children: ee }),
|
|
467
473
|
$
|
|
468
474
|
] })
|
|
469
|
-
] }) : /* @__PURE__ */
|
|
475
|
+
] }) : /* @__PURE__ */ h(
|
|
470
476
|
a,
|
|
471
477
|
{
|
|
472
478
|
sx: {
|
|
@@ -476,16 +482,16 @@ function qr({
|
|
|
476
482
|
},
|
|
477
483
|
children: [
|
|
478
484
|
/* @__PURE__ */ r(se, { children: /* @__PURE__ */ r("title", { children: Q }) }),
|
|
479
|
-
/* @__PURE__ */ r(
|
|
480
|
-
/* @__PURE__ */
|
|
481
|
-
/* @__PURE__ */ r(
|
|
485
|
+
/* @__PURE__ */ r(ce, { bordered: !0, ...xe, maxWidth: "100%" }),
|
|
486
|
+
/* @__PURE__ */ h(pe, { children: [
|
|
487
|
+
/* @__PURE__ */ r(fe, { isMySelf: o, userDid: n.data?.did ?? "", children: ee }),
|
|
482
488
|
$
|
|
483
489
|
] }),
|
|
484
|
-
|
|
490
|
+
he ? null : /* @__PURE__ */ r(
|
|
485
491
|
_e,
|
|
486
492
|
{
|
|
487
493
|
bordered: !0,
|
|
488
|
-
...
|
|
494
|
+
...ge,
|
|
489
495
|
sx: {
|
|
490
496
|
".MuiContainer-root": {
|
|
491
497
|
maxWidth: 1600
|
|
@@ -498,5 +504,5 @@ function qr({
|
|
|
498
504
|
);
|
|
499
505
|
}
|
|
500
506
|
export {
|
|
501
|
-
|
|
507
|
+
Gr as default
|
|
502
508
|
};
|
package/lib/common/ws.d.ts
CHANGED
|
@@ -1,3 +1,24 @@
|
|
|
1
|
-
export function create(endpoint?: string):
|
|
1
|
+
export function create(endpoint?: string): {
|
|
2
|
+
_logger: ReturnType<(subModule: string, silent?: boolean) => import('@arcblock/ws/esm/logger.mjs').Logger>;
|
|
3
|
+
emitter: import('@arcblock/ws/esm/client/base.mjs').EventEmitterInstance;
|
|
4
|
+
on(event: string, handler: (data: unknown) => void, params?: object): void;
|
|
5
|
+
off(event: string, handler?: (data: unknown) => void): void;
|
|
6
|
+
disconnect(callback?: () => void, code?: number, reason?: string): void;
|
|
7
|
+
ensureJoinChannel(topic: string, params?: object): void;
|
|
8
|
+
ensureLeaveChannel(topic: string): void;
|
|
9
|
+
subscribe(topic: string, params?: object): import('@arcblock/ws/esm/client/base.mjs').Channel;
|
|
10
|
+
unsubscribe(topic: string): void;
|
|
11
|
+
channels: import('@arcblock/ws/esm/client/base.mjs').Channel[];
|
|
12
|
+
connect(): void;
|
|
13
|
+
isConnected(): boolean;
|
|
14
|
+
onOpen(cb: () => void): void;
|
|
15
|
+
onClose(cb: () => void): void;
|
|
16
|
+
onError(cb: (err: {
|
|
17
|
+
error: Error;
|
|
18
|
+
}) => void): void;
|
|
19
|
+
onMessage(cb: (message: unknown) => void): void;
|
|
20
|
+
channel(topic: string, params?: object | (() => object)): import('@arcblock/ws/esm/client/base.mjs').Channel;
|
|
21
|
+
remove(channel: import('@arcblock/ws/esm/client/base.mjs').Channel): void;
|
|
22
|
+
};
|
|
2
23
|
export default function getWsClient(endpoint?: string): any;
|
|
3
24
|
export function useListenWsClient(endpoint?: string): any;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blocklet/ui-react",
|
|
3
|
-
"version": "3.4.
|
|
3
|
+
"version": "3.4.15",
|
|
4
4
|
"description": "Some useful front-end web components that can be used in Blocklets.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -36,10 +36,10 @@
|
|
|
36
36
|
"dependencies": {
|
|
37
37
|
"@abtnode/constant": "^1.17.7",
|
|
38
38
|
"@abtnode/util": "^1.17.7",
|
|
39
|
-
"@arcblock/bridge": "3.4.
|
|
40
|
-
"@arcblock/icons": "3.4.
|
|
41
|
-
"@arcblock/react-hooks": "3.4.
|
|
42
|
-
"@arcblock/ws": "^1.
|
|
39
|
+
"@arcblock/bridge": "3.4.15",
|
|
40
|
+
"@arcblock/icons": "3.4.15",
|
|
41
|
+
"@arcblock/react-hooks": "3.4.15",
|
|
42
|
+
"@arcblock/ws": "^1.29.4",
|
|
43
43
|
"@blocklet/did-space-react": "^1.2.15",
|
|
44
44
|
"@blocklet/uploader": "^0.3.19",
|
|
45
45
|
"@iconify-icons/logos": "^1.2.36",
|
|
@@ -84,7 +84,7 @@
|
|
|
84
84
|
"access": "public"
|
|
85
85
|
},
|
|
86
86
|
"devDependencies": {
|
|
87
|
-
"@arcblock/did-connect-react": "3.4.
|
|
87
|
+
"@arcblock/did-connect-react": "3.4.15",
|
|
88
88
|
"@babel/preset-env": "^7.28.0",
|
|
89
89
|
"@babel/preset-react": "^7.27.1",
|
|
90
90
|
"@babel/preset-typescript": "^7.27.1",
|
|
@@ -98,5 +98,5 @@
|
|
|
98
98
|
"typescript": "~5.5.4",
|
|
99
99
|
"unbuild": "^2.0.0"
|
|
100
100
|
},
|
|
101
|
-
"gitHead": "
|
|
101
|
+
"gitHead": "73039d82d507d9ec5408d8cfc67d9efeffae3e74"
|
|
102
102
|
}
|
|
@@ -16,7 +16,7 @@ import { useLocaleContext } from '@arcblock/ux/lib/Locale/context';
|
|
|
16
16
|
import { ErrorFallback } from '@arcblock/ux/lib/ErrorBoundary';
|
|
17
17
|
import { styled } from '@arcblock/ux/lib/Theme';
|
|
18
18
|
import cloneDeep from 'lodash/cloneDeep';
|
|
19
|
-
import { getQuery, withQuery, joinURL, withoutTrailingSlash } from 'ufo';
|
|
19
|
+
import { getQuery, withQuery, joinURL, withoutTrailingSlash, parseURL } from 'ufo';
|
|
20
20
|
import type { AxiosError } from 'axios';
|
|
21
21
|
import { getBlockletSDK, type UserPublicInfo } from '@blocklet/js-sdk';
|
|
22
22
|
import { isSupportFollow } from '@arcblock/ux/lib/Util';
|
|
@@ -279,7 +279,8 @@ export default function UserCenter({
|
|
|
279
279
|
label: x.title || x.label,
|
|
280
280
|
url: x.link || x.url,
|
|
281
281
|
protected: privacyState?.data?.[value] ?? false,
|
|
282
|
-
isPrivate:
|
|
282
|
+
isPrivate:
|
|
283
|
+
x.isPrivate || x.private || (getLink(x._rawLink, locale, defaultLocale)?.includes?.('/customer') ?? false), // FIXME: HACK: 隐藏 /customer 菜单, 需要一个通用的解决方案,在嵌入的时候就决定是否是私有的
|
|
283
284
|
followersOnly: x.component === 'did-comments', // 是否开启仅粉丝可查看的功能,目前只对 discuss kit 开启
|
|
284
285
|
// icon: x.icon,
|
|
285
286
|
};
|
|
@@ -288,7 +289,16 @@ export default function UserCenter({
|
|
|
288
289
|
}, [formattedBlocklet, userState.data, privacyState?.data, locale, defaultTabs, isMyself]);
|
|
289
290
|
|
|
290
291
|
const currentActiveTab = useCreation(() => {
|
|
291
|
-
return userCenterTabs.find((x) =>
|
|
292
|
+
return userCenterTabs.find((x) => {
|
|
293
|
+
try {
|
|
294
|
+
return (
|
|
295
|
+
parseURL(withoutTrailingSlash(getLink(x.value, locale, defaultLocale))).pathname ===
|
|
296
|
+
parseURL(withoutTrailingSlash(currentTab)).pathname
|
|
297
|
+
);
|
|
298
|
+
} catch {
|
|
299
|
+
return false;
|
|
300
|
+
}
|
|
301
|
+
});
|
|
292
302
|
}, [userCenterTabs]);
|
|
293
303
|
|
|
294
304
|
const htmlTitle = useCreation(() => {
|