@blocklet/ui-react 3.1.28 → 3.1.30
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/UserCenter/components/fallback.d.ts +2 -1
- package/lib/UserCenter/components/fallback.js +17 -16
- package/lib/UserCenter/components/user-center.js +187 -173
- package/lib/UserCenter/components/user-info/social-actions/chat.js +12 -11
- package/lib/UserCenter/components/user-info/user-basic-info.d.ts +2 -1
- package/lib/UserCenter/components/user-info/user-basic-info.js +45 -44
- package/lib/common/notification-addon.js +8 -8
- package/lib/utils.d.ts +0 -1
- package/lib/utils.js +42 -50
- package/package.json +9 -10
- package/src/UserCenter/components/fallback.tsx +6 -0
- package/src/UserCenter/components/user-center.tsx +16 -6
- package/src/UserCenter/components/user-info/social-actions/chat.tsx +2 -1
- package/src/UserCenter/components/user-info/user-basic-info.tsx +3 -1
- package/src/common/notification-addon.jsx +1 -1
- package/src/utils.js +0 -26
|
@@ -1,24 +1,25 @@
|
|
|
1
|
-
import { jsxs as
|
|
1
|
+
import { jsxs as c, jsx as a } from "react/jsx-runtime";
|
|
2
2
|
import { useMemo as l } from "react";
|
|
3
3
|
import { Button as u } from "@mui/material";
|
|
4
|
-
import { useMemoizedFn as
|
|
4
|
+
import { useMemoizedFn as r } from "ahooks";
|
|
5
|
+
import { Icon as d } from "@iconify/react";
|
|
5
6
|
import { translate as f } from "@arcblock/ux/lib/Locale/util";
|
|
6
7
|
import { useLocaleContext as p } from "@arcblock/ux/lib/Locale/context";
|
|
7
|
-
import { joinURL as
|
|
8
|
-
import { translations as
|
|
9
|
-
const
|
|
8
|
+
import { joinURL as h } from "ufo";
|
|
9
|
+
import { translations as g } from "../../../libs/locales.js";
|
|
10
|
+
const M = () => {
|
|
10
11
|
const { componentMountPoints: o = [] } = window.blocklet || {};
|
|
11
12
|
return o.find((t) => t.name === "did-comments")?.mountPoint;
|
|
12
13
|
};
|
|
13
|
-
function
|
|
14
|
-
const { locale: n } = p(), t =
|
|
15
|
-
window.open(
|
|
14
|
+
function L({ user: o }) {
|
|
15
|
+
const { locale: n } = p(), t = r((m, s = {}) => f(g, m, n, "en", s)), i = l(() => M(), []), e = r(() => {
|
|
16
|
+
window.open(h(i, `/chat/dm/${o?.did}`), "_blank");
|
|
16
17
|
});
|
|
17
|
-
return i ? /* @__PURE__ */
|
|
18
|
-
/* @__PURE__ */
|
|
18
|
+
return i ? /* @__PURE__ */ c(u, { fullWidth: !0, variant: "outlined", color: "inherit", onClick: e, children: [
|
|
19
|
+
/* @__PURE__ */ a(d, { icon: "tabler:message-dots", style: { marginRight: 4 } }),
|
|
19
20
|
t("profile.chat")
|
|
20
21
|
] }) : null;
|
|
21
22
|
}
|
|
22
23
|
export {
|
|
23
|
-
|
|
24
|
+
L as default
|
|
24
25
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { BoxProps } from '@mui/material';
|
|
2
2
|
import { User } from '../../../@types';
|
|
3
|
-
export default function UserBasicInfo({ user, isMyself, showFullDid, switchPassport, switchProfile, isMobile, onlyProfile, refreshProfile, ...rest }: {
|
|
3
|
+
export default function UserBasicInfo({ user, isMyself, showFullDid, switchPassport, switchProfile, isMobile, onlyProfile, refreshProfile, isShowSocialActions, ...rest }: {
|
|
4
4
|
user: User;
|
|
5
5
|
isMyself?: boolean;
|
|
6
6
|
showFullDid?: boolean;
|
|
@@ -10,4 +10,5 @@ export default function UserBasicInfo({ user, isMyself, showFullDid, switchPassp
|
|
|
10
10
|
isMobile?: boolean;
|
|
11
11
|
onlyProfile?: boolean;
|
|
12
12
|
refreshProfile: () => void;
|
|
13
|
+
isShowSocialActions?: boolean;
|
|
13
14
|
} & BoxProps): import("react/jsx-runtime").JSX.Element | null;
|
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
import { jsxs as c, jsx as r, Fragment as
|
|
2
|
-
import { Box as l, Typography as S, Divider as
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import { useMemoizedFn as
|
|
6
|
-
import { translate as
|
|
7
|
-
import { useLocaleContext as
|
|
8
|
-
import
|
|
1
|
+
import { jsxs as c, jsx as r, Fragment as B } from "react/jsx-runtime";
|
|
2
|
+
import { Box as l, Typography as S, Divider as N, IconButton as T, Collapse as F } from "@mui/material";
|
|
3
|
+
import K from "@arcblock/ux/lib/Avatar";
|
|
4
|
+
import W from "@arcblock/ux/lib/DID";
|
|
5
|
+
import { useMemoizedFn as O } from "ahooks";
|
|
6
|
+
import { translate as Q } from "@arcblock/ux/lib/Locale/util";
|
|
7
|
+
import { useLocaleContext as V } from "@arcblock/ux/lib/Locale/context";
|
|
8
|
+
import Y from "lodash/noop";
|
|
9
9
|
import { useState as U, useEffect as y } from "react";
|
|
10
10
|
import C from "@arcblock/ux/lib/Toast";
|
|
11
|
-
import { parseURL as
|
|
12
|
-
import { KeyboardArrowUp as
|
|
13
|
-
import { translations as
|
|
11
|
+
import { parseURL as $, joinURL as q } from "ufo";
|
|
12
|
+
import { KeyboardArrowUp as G, KeyboardArrowDown as H } from "@mui/icons-material";
|
|
13
|
+
import { translations as J } from "../../libs/locales.js";
|
|
14
14
|
import { formatAxiosError as z } from "../../libs/utils.js";
|
|
15
|
-
import { currentTimezone as
|
|
16
|
-
import
|
|
17
|
-
import
|
|
18
|
-
import
|
|
19
|
-
import
|
|
15
|
+
import { currentTimezone as X, getStatusDuration as Z, isValidUrl as _ } from "./utils.js";
|
|
16
|
+
import P from "./switch-role.js";
|
|
17
|
+
import M from "./metadata.js";
|
|
18
|
+
import tt from "./user-status.js";
|
|
19
|
+
import rt from "./user-info.js";
|
|
20
20
|
import { client as j } from "../../../libs/client.js";
|
|
21
|
-
import
|
|
22
|
-
function
|
|
21
|
+
import ot from "./social-actions/index.js";
|
|
22
|
+
function zt({
|
|
23
23
|
user: t,
|
|
24
24
|
isMyself: e = !0,
|
|
25
25
|
showFullDid: f = !0,
|
|
@@ -28,19 +28,20 @@ function Ct({
|
|
|
28
28
|
isMobile: a = !1,
|
|
29
29
|
onlyProfile: s = !1,
|
|
30
30
|
refreshProfile: u,
|
|
31
|
+
isShowSocialActions: A = !1,
|
|
31
32
|
...m
|
|
32
33
|
}) {
|
|
33
|
-
const { locale: x } =
|
|
34
|
+
const { locale: x } = V(), [h, g] = U(void 0), w = O((n, o = {}) => Q(J, n, x, "en", o)), [d, v] = U(!a || s);
|
|
34
35
|
y(() => {
|
|
35
36
|
g(t?.metadata?.status);
|
|
36
37
|
}, [t]), y(() => {
|
|
37
38
|
v(!a || s);
|
|
38
39
|
}, [a, s]);
|
|
39
|
-
const
|
|
40
|
+
const b = async (n) => {
|
|
40
41
|
if (e)
|
|
41
42
|
try {
|
|
42
43
|
if (n) {
|
|
43
|
-
const o =
|
|
44
|
+
const o = Z(n);
|
|
44
45
|
n.dateRange = o.length > 0 ? o : h?.dateRange ?? [];
|
|
45
46
|
}
|
|
46
47
|
g(n), await j.user.saveProfile({
|
|
@@ -53,25 +54,25 @@ function Ct({
|
|
|
53
54
|
} catch (o) {
|
|
54
55
|
console.error(o), C.error(z(o));
|
|
55
56
|
}
|
|
56
|
-
},
|
|
57
|
+
}, D = () => {
|
|
57
58
|
v(!d);
|
|
58
59
|
};
|
|
59
60
|
if (!t)
|
|
60
61
|
return null;
|
|
61
|
-
const
|
|
62
|
+
const L = async (n) => {
|
|
62
63
|
if (!e)
|
|
63
64
|
return;
|
|
64
|
-
const { metadata: o, address:
|
|
65
|
+
const { metadata: o, address: k } = n;
|
|
65
66
|
try {
|
|
66
67
|
const p = o?.links?.map((i) => {
|
|
67
|
-
if (!i.url || !
|
|
68
|
+
if (!i.url || !_(i.url)) return null;
|
|
68
69
|
try {
|
|
69
|
-
return
|
|
70
|
+
return $(i.url).protocol || (i.url = q("https://", i.url)), i;
|
|
70
71
|
} catch {
|
|
71
72
|
return console.error("Invalid URL:", i.url), null;
|
|
72
73
|
}
|
|
73
74
|
}).filter((i) => !!i) || [];
|
|
74
|
-
o.links = p, await j.user.saveProfile({ metadata: o, address:
|
|
75
|
+
o.links = p, await j.user.saveProfile({ metadata: o, address: k }), u();
|
|
75
76
|
} catch (p) {
|
|
76
77
|
console.error(p), C.error(z(p));
|
|
77
78
|
}
|
|
@@ -107,7 +108,7 @@ function Ct({
|
|
|
107
108
|
},
|
|
108
109
|
children: [
|
|
109
110
|
/* @__PURE__ */ r(
|
|
110
|
-
|
|
111
|
+
K,
|
|
111
112
|
{
|
|
112
113
|
src: t?.avatar,
|
|
113
114
|
did: t?.did,
|
|
@@ -138,18 +139,18 @@ function Ct({
|
|
|
138
139
|
}
|
|
139
140
|
} : {}
|
|
140
141
|
},
|
|
141
|
-
onClick: e ? R :
|
|
142
|
+
onClick: e ? R : Y
|
|
142
143
|
}
|
|
143
144
|
),
|
|
144
145
|
/* @__PURE__ */ r(
|
|
145
|
-
|
|
146
|
+
tt,
|
|
146
147
|
{
|
|
147
148
|
isMobile: a,
|
|
148
149
|
size: m.size || (a ? 64 : 100),
|
|
149
150
|
isMyself: e,
|
|
150
|
-
timezone: t?.metadata?.timezone ||
|
|
151
|
+
timezone: t?.metadata?.timezone || X,
|
|
151
152
|
status: h,
|
|
152
|
-
onChange:
|
|
153
|
+
onChange: b
|
|
153
154
|
}
|
|
154
155
|
)
|
|
155
156
|
]
|
|
@@ -189,21 +190,21 @@ function Ct({
|
|
|
189
190
|
children: t?.fullName
|
|
190
191
|
}
|
|
191
192
|
),
|
|
192
|
-
e ? /* @__PURE__ */ r(
|
|
193
|
+
e ? /* @__PURE__ */ r(P, { user: t, switchPassport: I }) : null
|
|
193
194
|
]
|
|
194
195
|
}
|
|
195
196
|
),
|
|
196
|
-
/* @__PURE__ */ r(
|
|
197
|
+
/* @__PURE__ */ r(W, { did: t.did, showQrcode: !0, copyable: !0, compact: !f, responsive: !f, locale: x })
|
|
197
198
|
]
|
|
198
199
|
}
|
|
199
200
|
)
|
|
200
201
|
]
|
|
201
202
|
}
|
|
202
203
|
),
|
|
203
|
-
e
|
|
204
|
-
/* @__PURE__ */ r(
|
|
205
|
-
e ? /* @__PURE__ */ c(
|
|
206
|
-
/* @__PURE__ */ r(
|
|
204
|
+
!e && A ? /* @__PURE__ */ r(l, { sx: { mt: 2 }, children: /* @__PURE__ */ r(ot, { user: t }) }) : null,
|
|
205
|
+
/* @__PURE__ */ r(M, { isMobile: a, isMyself: e, user: t, onSave: L }),
|
|
206
|
+
e ? /* @__PURE__ */ c(B, { children: [
|
|
207
|
+
/* @__PURE__ */ r(N, { sx: { my: a ? 1 : 3 } }),
|
|
207
208
|
a && !s ? /* @__PURE__ */ r(
|
|
208
209
|
l,
|
|
209
210
|
{
|
|
@@ -213,10 +214,10 @@ function Ct({
|
|
|
213
214
|
mb: 0
|
|
214
215
|
},
|
|
215
216
|
children: /* @__PURE__ */ r(
|
|
216
|
-
|
|
217
|
+
T,
|
|
217
218
|
{
|
|
218
219
|
size: "small",
|
|
219
|
-
onClick:
|
|
220
|
+
onClick: D,
|
|
220
221
|
sx: {
|
|
221
222
|
backgroundColor: "grey.50",
|
|
222
223
|
"&:hover": {
|
|
@@ -224,12 +225,12 @@ function Ct({
|
|
|
224
225
|
opacity: 0.8
|
|
225
226
|
}
|
|
226
227
|
},
|
|
227
|
-
children: d ? /* @__PURE__ */ r(
|
|
228
|
+
children: d ? /* @__PURE__ */ r(G, {}) : /* @__PURE__ */ r(H, {})
|
|
228
229
|
}
|
|
229
230
|
)
|
|
230
231
|
}
|
|
231
232
|
) : null,
|
|
232
|
-
/* @__PURE__ */ c(
|
|
233
|
+
/* @__PURE__ */ c(F, { in: d, timeout: "auto", children: [
|
|
233
234
|
/* @__PURE__ */ r(
|
|
234
235
|
S,
|
|
235
236
|
{
|
|
@@ -242,7 +243,7 @@ function Ct({
|
|
|
242
243
|
children: w("profile.justForYou")
|
|
243
244
|
}
|
|
244
245
|
),
|
|
245
|
-
/* @__PURE__ */ r(
|
|
246
|
+
/* @__PURE__ */ r(rt, { user: t, isMySelf: e })
|
|
246
247
|
] })
|
|
247
248
|
] }) : null
|
|
248
249
|
]
|
|
@@ -250,5 +251,5 @@ function Ct({
|
|
|
250
251
|
);
|
|
251
252
|
}
|
|
252
253
|
export {
|
|
253
|
-
|
|
254
|
+
zt as default
|
|
254
255
|
};
|
|
@@ -7,17 +7,17 @@ import S from "@arcblock/icons/lib/Notification";
|
|
|
7
7
|
import { useCreation as s } from "ahooks";
|
|
8
8
|
import { WELLKNOWN_SERVICE_PATH_PREFIX as V, EVENTS as y } from "@abtnode/constant";
|
|
9
9
|
import x from "@arcblock/react-hooks/lib/useBrowser";
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import F from "
|
|
13
|
-
import
|
|
14
|
-
const b =
|
|
10
|
+
import { compareVersions as U } from "@arcblock/ux/lib/Util";
|
|
11
|
+
import { joinURL as j, withQuery as I } from "ufo";
|
|
12
|
+
import { useListenWsClient as F } from "./ws.js";
|
|
13
|
+
import H from "../Notifications/Snackbar.js";
|
|
14
|
+
const b = j(V, "user", "notifications"), K = (r) => I(b, {
|
|
15
15
|
id: r.id,
|
|
16
16
|
severity: r.severity || "all",
|
|
17
17
|
componentDid: r.source === "system" ? "system" : r.componentDid || "all"
|
|
18
18
|
});
|
|
19
19
|
function P({ session: r = {} }) {
|
|
20
|
-
const { unReadCount: c, user: w, setUnReadCount: n } = r, e = s(() => w?.did, [w]), { enqueueSnackbar: E } = D(), l = x(), k = _(() => l.arcSphere || l.wallet, [l]), N = s(() => window.blocklet?.serverVersion, []), t =
|
|
20
|
+
const { unReadCount: c, user: w, setUnReadCount: n } = r, e = s(() => w?.did, [w]), { enqueueSnackbar: E } = D(), l = x(), k = _(() => l.arcSphere || l.wallet, [l]), N = s(() => window.blocklet?.serverVersion, []), t = F("user"), d = s(
|
|
21
21
|
() => `${window.blocklet.did}/${e}/${y.NOTIFICATION_BLOCKLET_CREATE}`,
|
|
22
22
|
[e]
|
|
23
23
|
), u = s(
|
|
@@ -28,14 +28,14 @@ function P({ session: r = {} }) {
|
|
|
28
28
|
const { receivers: f } = o ?? {}, { receiver: p } = f[0] ?? {};
|
|
29
29
|
if (p === e) {
|
|
30
30
|
n((v) => v + 1);
|
|
31
|
-
const C =
|
|
31
|
+
const C = U(N, "1.16.42-beta-20250407");
|
|
32
32
|
if (!k && o.source === "component" && C) {
|
|
33
33
|
const v = K(o), { severity: T, description: L } = o || {}, A = ["error", "warning"].includes(T) || o.sticky;
|
|
34
34
|
E(L, {
|
|
35
35
|
variant: T,
|
|
36
36
|
autoHideDuration: A ? null : 5e3,
|
|
37
37
|
// eslint-disable-next-line react/no-unstable-nested-components
|
|
38
|
-
content: (R) => /* @__PURE__ */ i(
|
|
38
|
+
content: (R) => /* @__PURE__ */ i(H, { viewAllUrl: v, keyId: R, notification: o })
|
|
39
39
|
});
|
|
40
40
|
}
|
|
41
41
|
}
|
package/lib/utils.d.ts
CHANGED
|
@@ -8,4 +8,3 @@ export function isIconifyString(str: any): boolean;
|
|
|
8
8
|
export function matchPath(path: any): any;
|
|
9
9
|
export function matchPaths(paths?: any[]): number;
|
|
10
10
|
export function splitNavColumns(items: any, options?: {}): never[][];
|
|
11
|
-
export function compareVersions(version1: any, version2: any): any;
|
package/lib/utils.js
CHANGED
|
@@ -1,62 +1,54 @@
|
|
|
1
|
-
|
|
2
|
-
const d = (e, r, n = "children") => e.map((t) => Array.isArray(t[n]) ? r({
|
|
1
|
+
const p = (n, r, e = "children") => n.map((t) => Array.isArray(t[e]) ? r({
|
|
3
2
|
...t,
|
|
4
|
-
[
|
|
5
|
-
}) : r(t)),
|
|
6
|
-
const
|
|
7
|
-
return
|
|
8
|
-
},
|
|
9
|
-
let
|
|
10
|
-
return
|
|
11
|
-
},
|
|
12
|
-
const s = t[
|
|
3
|
+
[e]: p(t[e], r, e)
|
|
4
|
+
}) : r(t)), v = (n, r = "children") => {
|
|
5
|
+
const e = [];
|
|
6
|
+
return p(n, (t) => e.push(t), r), e;
|
|
7
|
+
}, A = (n, r = "children") => {
|
|
8
|
+
let e = 0;
|
|
9
|
+
return p(n, () => e++, r), e;
|
|
10
|
+
}, H = (n, r, e = "children") => n.map((t) => ({ ...t })).filter((t) => {
|
|
11
|
+
const s = t[e];
|
|
13
12
|
if (Array.isArray(s)) {
|
|
14
|
-
const
|
|
15
|
-
t[
|
|
13
|
+
const a = H(s, r, e);
|
|
14
|
+
t[e] = a?.length ? a : void 0;
|
|
16
15
|
}
|
|
17
|
-
const
|
|
18
|
-
return r(t,
|
|
19
|
-
}),
|
|
20
|
-
if (!
|
|
16
|
+
const l = { filteredChildren: t[e], isLeaf: !s?.length };
|
|
17
|
+
return r(t, l);
|
|
18
|
+
}), C = (n) => /^https?:\/\//.test(n), P = (n) => /^mailto:/i.test(n.trim()), S = (n) => /^[\w-]+:[\w-]+$/.test(n), R = (n) => {
|
|
19
|
+
if (!n || !n?.startsWith("/"))
|
|
21
20
|
return !1;
|
|
22
|
-
const r = (s) => s.endsWith("/") ? s : `${s}/`,
|
|
23
|
-
return
|
|
24
|
-
},
|
|
25
|
-
const r =
|
|
21
|
+
const r = (s) => s.endsWith("/") ? s : `${s}/`, e = r(window.location.pathname), t = r(new URL(n, window.location.origin).pathname);
|
|
22
|
+
return e.startsWith(t);
|
|
23
|
+
}, x = (n = []) => {
|
|
24
|
+
const r = n.map((t, s) => ({ path: t, index: s })).filter((t) => R(t.path));
|
|
26
25
|
return r?.length ? r.slice(1).reduce((t, s) => t.path.length >= s.path.length ? t : s, r[0]).index : -1;
|
|
27
|
-
},
|
|
28
|
-
const { columns:
|
|
29
|
-
let
|
|
30
|
-
const
|
|
31
|
-
return
|
|
32
|
-
const g = s + (
|
|
33
|
-
t && f(s) && (
|
|
34
|
-
...
|
|
26
|
+
}, W = (n, r = {}) => {
|
|
27
|
+
const { columns: e = 1, breakInside: t = !1, groupHeight: s = 48, itemHeight: l = 24, childrenKey: a = "items" } = r, m = n.reduce((c, g) => c + s + (g[a]?.length || 0) * l, 0), h = Math.ceil(m / e), u = [[]];
|
|
28
|
+
let o = 0, i = 0;
|
|
29
|
+
const d = h * 0.2, f = (c) => i > h - d && o < e - 1 && i + c > h + d;
|
|
30
|
+
return n.forEach((c) => {
|
|
31
|
+
const g = s + (c[a]?.length || 0) * l;
|
|
32
|
+
t && f(s) && (o++, i = 0, u[o] = []), !t && i > 0 && f(g) && (o++, i = 0, u[o] = []), u[o].push({
|
|
33
|
+
...c,
|
|
35
34
|
group: !0
|
|
36
|
-
}),
|
|
37
|
-
t && f(
|
|
35
|
+
}), i += s, c[a] && c[a].forEach((w) => {
|
|
36
|
+
t && f(l) && (o++, i = 0, u[o] = []), u[o].push({
|
|
38
37
|
...w,
|
|
39
38
|
group: !1
|
|
40
|
-
}),
|
|
39
|
+
}), i += l;
|
|
41
40
|
});
|
|
42
|
-
}),
|
|
43
|
-
}, E = (e, r) => {
|
|
44
|
-
const n = (c) => {
|
|
45
|
-
const o = c.match(/^(\d+\.\d+\.\d+(?:-[^-]+?-\d{8}))/);
|
|
46
|
-
return o ? o[1] : c;
|
|
47
|
-
}, t = n(e), s = n(r);
|
|
48
|
-
return t === s && e !== r ? !1 : H.gte(t, s);
|
|
41
|
+
}), u;
|
|
49
42
|
};
|
|
50
43
|
export {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
v as splitNavColumns
|
|
44
|
+
A as countRecursive,
|
|
45
|
+
H as filterRecursive,
|
|
46
|
+
v as flatRecursive,
|
|
47
|
+
S as isIconifyString,
|
|
48
|
+
P as isMailProtocol,
|
|
49
|
+
C as isUrl,
|
|
50
|
+
p as mapRecursive,
|
|
51
|
+
R as matchPath,
|
|
52
|
+
x as matchPaths,
|
|
53
|
+
W as splitNavColumns
|
|
62
54
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blocklet/ui-react",
|
|
3
|
-
"version": "3.1.
|
|
3
|
+
"version": "3.1.30",
|
|
4
4
|
"description": "Some useful front-end web components that can be used in Blocklets.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -33,13 +33,13 @@
|
|
|
33
33
|
"url": "https://github.com/ArcBlock/ux/issues"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@abtnode/constant": "^1.16.
|
|
37
|
-
"@abtnode/util": "^1.16.
|
|
38
|
-
"@arcblock/bridge": "3.1.
|
|
39
|
-
"@arcblock/icons": "3.1.
|
|
40
|
-
"@arcblock/react-hooks": "3.1.
|
|
36
|
+
"@abtnode/constant": "^1.16.49-beta-20250823-082650-626c1473",
|
|
37
|
+
"@abtnode/util": "^1.16.49-beta-20250823-082650-626c1473",
|
|
38
|
+
"@arcblock/bridge": "3.1.30",
|
|
39
|
+
"@arcblock/icons": "3.1.30",
|
|
40
|
+
"@arcblock/react-hooks": "3.1.30",
|
|
41
41
|
"@arcblock/ws": "^1.21.3",
|
|
42
|
-
"@blocklet/constant": "^1.16.
|
|
42
|
+
"@blocklet/constant": "^1.16.49-beta-20250823-082650-626c1473",
|
|
43
43
|
"@blocklet/did-space-react": "^1.1.16",
|
|
44
44
|
"@iconify-icons/logos": "^1.2.36",
|
|
45
45
|
"@iconify-icons/material-symbols": "^1.2.58",
|
|
@@ -63,7 +63,6 @@
|
|
|
63
63
|
"react-error-boundary": "^3.1.4",
|
|
64
64
|
"react-helmet": "^6.1.0",
|
|
65
65
|
"react-placeholder": "^4.1.0",
|
|
66
|
-
"semver": "^7.7.2",
|
|
67
66
|
"type-fest": "^4.41.0",
|
|
68
67
|
"ua-parser-js": "^1.0.40",
|
|
69
68
|
"ufo": "^1.6.1",
|
|
@@ -84,7 +83,7 @@
|
|
|
84
83
|
"access": "public"
|
|
85
84
|
},
|
|
86
85
|
"devDependencies": {
|
|
87
|
-
"@arcblock/did-connect-react": "3.1.
|
|
86
|
+
"@arcblock/did-connect-react": "3.1.30",
|
|
88
87
|
"@types/dompurify": "^3.2.0",
|
|
89
88
|
"@types/ua-parser-js": "^0.7.39",
|
|
90
89
|
"@types/validator": "^13.15.2",
|
|
@@ -92,5 +91,5 @@
|
|
|
92
91
|
"jest": "^29.7.0",
|
|
93
92
|
"unbuild": "^2.0.0"
|
|
94
93
|
},
|
|
95
|
-
"gitHead": "
|
|
94
|
+
"gitHead": "a51fede74e5eca679ff40a8c62d96bae09210f04"
|
|
96
95
|
}
|
|
@@ -15,10 +15,12 @@ import { useUserFollowersContext } from '../../contexts/user-followers';
|
|
|
15
15
|
function Fallback({
|
|
16
16
|
currentActiveTab,
|
|
17
17
|
isMyself,
|
|
18
|
+
isSupportFollow = false,
|
|
18
19
|
children,
|
|
19
20
|
}: {
|
|
20
21
|
currentActiveTab: UserCenterTab;
|
|
21
22
|
isMyself: boolean;
|
|
23
|
+
isSupportFollow?: boolean;
|
|
22
24
|
children: React.ReactNode;
|
|
23
25
|
}) {
|
|
24
26
|
const { locale } = useLocaleContext();
|
|
@@ -34,6 +36,10 @@ function Fallback({
|
|
|
34
36
|
|
|
35
37
|
const { protected: protection } = currentActiveTab;
|
|
36
38
|
|
|
39
|
+
// 如果还没有支持 follow 关系,但是已经设置了仅粉丝可见,则直接显示内容
|
|
40
|
+
if (!isSupportFollow && protection === 'follower-only') {
|
|
41
|
+
return children;
|
|
42
|
+
}
|
|
37
43
|
// 私密内容(仅自己可见)
|
|
38
44
|
if (protection === true || protection === 'private') {
|
|
39
45
|
return <Empty>{t('underProtected')}</Empty>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Children, cloneElement, isValidElement, use } from 'react';
|
|
1
|
+
import { Children, cloneElement, isValidElement, use, useMemo } from 'react';
|
|
2
2
|
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';
|
|
@@ -19,6 +19,7 @@ import cloneDeep from 'lodash/cloneDeep';
|
|
|
19
19
|
import { getQuery, withQuery, joinURL, withoutTrailingSlash } from 'ufo';
|
|
20
20
|
import type { AxiosError } from 'axios';
|
|
21
21
|
import type { UserPublicInfo } from '@blocklet/js-sdk';
|
|
22
|
+
import { isSupportFollow } from '@arcblock/ux/lib/Util';
|
|
22
23
|
|
|
23
24
|
import { PROFILE_URL } from '@arcblock/ux/lib/Util/constant';
|
|
24
25
|
import Footer from '../../Footer';
|
|
@@ -143,6 +144,10 @@ export default function UserCenter({
|
|
|
143
144
|
return false;
|
|
144
145
|
}, [currentDid, session?.user?.did]);
|
|
145
146
|
|
|
147
|
+
const isShowSocialActions = useMemo((): boolean => {
|
|
148
|
+
return isSupportFollow();
|
|
149
|
+
}, []);
|
|
150
|
+
|
|
146
151
|
const userState = useRequest<UserPublicInfo | User | undefined, []>(
|
|
147
152
|
// eslint-disable-next-line consistent-return
|
|
148
153
|
async () => {
|
|
@@ -227,9 +232,9 @@ export default function UserCenter({
|
|
|
227
232
|
value: userFollowersLink,
|
|
228
233
|
url: getLink(userFollowersLink, locale),
|
|
229
234
|
};
|
|
230
|
-
let tabs: NavigationTabProps[] = [nftTab, userFollowersTab];
|
|
235
|
+
let tabs: NavigationTabProps[] = isShowSocialActions ? [nftTab, userFollowersTab] : [nftTab];
|
|
231
236
|
if (isMyself) {
|
|
232
|
-
|
|
237
|
+
const restTabs = [
|
|
233
238
|
nftTab,
|
|
234
239
|
{
|
|
235
240
|
label: t('common.setting'),
|
|
@@ -245,11 +250,11 @@ export default function UserCenter({
|
|
|
245
250
|
value: didSpacesLink,
|
|
246
251
|
url: getLink(didSpacesLink, locale),
|
|
247
252
|
},
|
|
248
|
-
userFollowersTab,
|
|
249
253
|
];
|
|
254
|
+
tabs = isShowSocialActions ? [...restTabs, userFollowersTab] : restTabs;
|
|
250
255
|
}
|
|
251
256
|
return tabs;
|
|
252
|
-
}, [isMyself, locale]);
|
|
257
|
+
}, [isMyself, locale, isShowSocialActions]);
|
|
253
258
|
|
|
254
259
|
const userCenterTabs = useCreation<UserCenterTab[]>(() => {
|
|
255
260
|
const menus = formattedBlocklet?.navigation?.userCenter || [];
|
|
@@ -442,7 +447,10 @@ export default function UserCenter({
|
|
|
442
447
|
|
|
443
448
|
return (
|
|
444
449
|
<Box sx={{ flex: 1 }}>
|
|
445
|
-
<Fallback
|
|
450
|
+
<Fallback
|
|
451
|
+
isSupportFollow={isShowSocialActions}
|
|
452
|
+
currentActiveTab={currentActiveTab as UserCenterTab}
|
|
453
|
+
isMyself={isMyself}>
|
|
446
454
|
{children ? <Box {...contentProps}>{renderChildrenWithProps(children)}</Box> : renderDefaultTab}
|
|
447
455
|
</Fallback>
|
|
448
456
|
</Box>
|
|
@@ -534,6 +542,7 @@ export default function UserCenter({
|
|
|
534
542
|
showFullDid={false}
|
|
535
543
|
onlyProfile={onlyProfile}
|
|
536
544
|
refreshProfile={onRefreshUser}
|
|
545
|
+
isShowSocialActions={isShowSocialActions}
|
|
537
546
|
sx={{
|
|
538
547
|
padding: !isMobile ? '40px 24px 24px 40px' : '16px 0 0 0',
|
|
539
548
|
...(!isMobile ? { width: 320, maxWidth: 320, flexShrink: 0 } : {}),
|
|
@@ -617,6 +626,7 @@ export default function UserCenter({
|
|
|
617
626
|
user={userState.data as User}
|
|
618
627
|
refreshProfile={onRefreshUser}
|
|
619
628
|
showFullDid={false}
|
|
629
|
+
isShowSocialActions={isShowSocialActions}
|
|
620
630
|
sx={{
|
|
621
631
|
padding: !isMobile ? '40px 24px 24px 40px' : '16px 0 0 0',
|
|
622
632
|
...(!isMobile ? { width: 320, maxWidth: 320, flexShrink: 0 } : {}),
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { useMemo } from 'react';
|
|
2
2
|
import { Button } from '@mui/material';
|
|
3
3
|
import { useMemoizedFn } from 'ahooks';
|
|
4
|
+
import { Icon } from '@iconify/react';
|
|
4
5
|
import { translate } from '@arcblock/ux/lib/Locale/util';
|
|
5
6
|
import { useLocaleContext } from '@arcblock/ux/lib/Locale/context';
|
|
6
7
|
|
|
@@ -33,7 +34,7 @@ function Chat({ user }: { user: User }) {
|
|
|
33
34
|
|
|
34
35
|
return (
|
|
35
36
|
<Button fullWidth variant="outlined" color="inherit" onClick={onNavigateToChat}>
|
|
36
|
-
<
|
|
37
|
+
<Icon icon="tabler:message-dots" style={{ marginRight: 4 }} />
|
|
37
38
|
{t('profile.chat')}
|
|
38
39
|
</Button>
|
|
39
40
|
);
|
|
@@ -35,6 +35,7 @@ export default function UserBasicInfo({
|
|
|
35
35
|
isMobile = false,
|
|
36
36
|
onlyProfile = false,
|
|
37
37
|
refreshProfile,
|
|
38
|
+
isShowSocialActions = false,
|
|
38
39
|
...rest
|
|
39
40
|
}: {
|
|
40
41
|
user: User;
|
|
@@ -46,6 +47,7 @@ export default function UserBasicInfo({
|
|
|
46
47
|
isMobile?: boolean;
|
|
47
48
|
onlyProfile?: boolean;
|
|
48
49
|
refreshProfile: () => void;
|
|
50
|
+
isShowSocialActions?: boolean;
|
|
49
51
|
} & BoxProps) {
|
|
50
52
|
const { locale } = useLocaleContext();
|
|
51
53
|
const [userStatus, setUserStatus] = useState<UserMetadata['status']>(undefined);
|
|
@@ -226,7 +228,7 @@ export default function UserBasicInfo({
|
|
|
226
228
|
<DID did={user.did} showQrcode copyable compact={!showFullDid} responsive={!showFullDid} locale={locale} />
|
|
227
229
|
</Box>
|
|
228
230
|
</Box>
|
|
229
|
-
{!isMyself ? (
|
|
231
|
+
{!isMyself && isShowSocialActions ? (
|
|
230
232
|
<Box sx={{ mt: 2 }}>
|
|
231
233
|
<SocialActions user={user} />
|
|
232
234
|
</Box>
|
|
@@ -6,10 +6,10 @@ import NotificationsOutlinedIcon from '@arcblock/icons/lib/Notification';
|
|
|
6
6
|
import { useCreation } from 'ahooks';
|
|
7
7
|
import { EVENTS, WELLKNOWN_SERVICE_PATH_PREFIX } from '@abtnode/constant';
|
|
8
8
|
import useBrowser from '@arcblock/react-hooks/lib/useBrowser';
|
|
9
|
+
import { compareVersions } from '@arcblock/ux/lib/Util';
|
|
9
10
|
import { joinURL, withQuery } from 'ufo';
|
|
10
11
|
import { useListenWsClient } from './ws';
|
|
11
12
|
import NotificationSnackbar from '../Notifications/Snackbar';
|
|
12
|
-
import { compareVersions } from '../utils';
|
|
13
13
|
|
|
14
14
|
const viewAllUrl = joinURL(WELLKNOWN_SERVICE_PATH_PREFIX, 'user', 'notifications');
|
|
15
15
|
|
package/src/utils.js
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import semver from 'semver';
|
|
2
|
-
|
|
3
1
|
export const mapRecursive = (array, fn, childrenKey = 'children') => {
|
|
4
2
|
return array.map((item) => {
|
|
5
3
|
if (Array.isArray(item[childrenKey])) {
|
|
@@ -158,27 +156,3 @@ export const splitNavColumns = (items, options = {}) => {
|
|
|
158
156
|
|
|
159
157
|
return result;
|
|
160
158
|
};
|
|
161
|
-
|
|
162
|
-
/**
|
|
163
|
-
* 比较两个版本号,用于判断版本号是否兼容
|
|
164
|
-
* @param {*} version1
|
|
165
|
-
* @param {*} version2
|
|
166
|
-
* @returns 0: 版本相同, -1: version1 < version2, 1: version1 > version2
|
|
167
|
-
*/
|
|
168
|
-
export const compareVersions = (version1, version2) => {
|
|
169
|
-
const getDateVersion = (version) => {
|
|
170
|
-
const match = version.match(/^(\d+\.\d+\.\d+(?:-[^-]+?-\d{8}))/);
|
|
171
|
-
return match ? match[1] : version;
|
|
172
|
-
};
|
|
173
|
-
|
|
174
|
-
const dateVersion1 = getDateVersion(version1);
|
|
175
|
-
const dateVersion2 = getDateVersion(version2);
|
|
176
|
-
|
|
177
|
-
// 如果基础版本相同,但完整版本不同(意味着有额外部分),返回false
|
|
178
|
-
if (dateVersion1 === dateVersion2 && version1 !== version2) {
|
|
179
|
-
return false;
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
// 其他情况正常比较
|
|
183
|
-
return semver.gte(dateVersion1, dateVersion2);
|
|
184
|
-
};
|