@blocklet/ui-react 3.0.9 → 3.0.10
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/BlockletStudio/index.js +70 -71
- package/lib/ComponentInstaller/index.js +85 -88
- package/lib/ComponentInstaller/installer-item.js +47 -53
- package/lib/ComponentInstaller/use-component-installed.js +32 -38
- package/lib/ComponentManager/components/add-component.js +47 -50
- package/lib/ComponentManager/components/publish-component.js +30 -31
- package/lib/ComponentManager/components/resource-dialog.js +28 -30
- package/lib/Dashboard/index.d.ts +1 -1
- package/lib/Dashboard/index.js +59 -61
- package/lib/Footer/index.js +51 -52
- package/lib/Footer/internal-footer.js +43 -47
- package/lib/Footer/layout/standard.js +11 -12
- package/lib/Footer/links.js +25 -28
- package/lib/Footer/social-media.js +17 -17
- package/lib/Header/index.js +81 -83
- package/lib/Notifications/Snackbar.js +76 -77
- package/lib/Notifications/hooks/use-title.js +34 -34
- package/lib/Notifications/utils.js +56 -60
- package/lib/UserCenter/components/config-inviter.js +17 -18
- package/lib/UserCenter/components/danger-zone.js +49 -52
- package/lib/UserCenter/components/nft.js +44 -45
- package/lib/UserCenter/components/notification.js +92 -99
- package/lib/UserCenter/components/passport.js +22 -22
- package/lib/UserCenter/components/privacy.js +6 -6
- package/lib/UserCenter/components/settings.js +40 -43
- package/lib/UserCenter/components/status-dialog/date-picker.js +7 -8
- package/lib/UserCenter/components/status-dialog/index.js +112 -114
- package/lib/UserCenter/components/status-selector/duration-menu.js +35 -36
- package/lib/UserCenter/components/status-selector/index.js +13 -13
- package/lib/UserCenter/components/storage/action.js +21 -22
- package/lib/UserCenter/components/storage/delete.js +24 -24
- package/lib/UserCenter/components/third-party-login/index.js +53 -53
- package/lib/UserCenter/components/third-party-login/third-party-item.js +87 -89
- package/lib/UserCenter/components/user-center.js +198 -207
- package/lib/UserCenter/components/user-info/metadata.js +343 -353
- package/lib/UserCenter/components/user-info/switch-role.js +17 -20
- package/lib/UserCenter/components/user-info/user-basic-info.js +79 -82
- package/lib/UserCenter/components/user-info/user-info.js +40 -40
- package/lib/UserCenter/components/user-info/user-status.js +97 -99
- package/lib/UserCenter/components/user-info/utils.js +34 -35
- package/lib/UserSessions/components/user-session-info.js +25 -28
- package/lib/UserSessions/components/user-sessions.js +169 -181
- package/lib/blocklets.js +62 -72
- package/lib/common/domain-warning.js +31 -31
- package/lib/common/header-addons.d.ts +1 -1
- package/lib/common/header-addons.js +49 -53
- package/lib/common/notification-addon.js +29 -32
- package/lib/common/ws.js +17 -18
- package/lib/contexts/config-user-space.js +16 -19
- package/lib/utils.js +44 -48
- package/package.json +6 -6
package/lib/blocklets.js
CHANGED
|
@@ -1,52 +1,48 @@
|
|
|
1
|
-
import { mapRecursive as
|
|
2
|
-
|
|
3
|
-
const
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
return e.searchParams.set("locale", o), e.href;
|
|
1
|
+
import { mapRecursive as s, filterRecursive as a, isUrl as f } from "./utils.js";
|
|
2
|
+
const g = window?.blocklet?.groupPrefix || window?.blocklet?.prefix || "/", i = (o) => {
|
|
3
|
+
const r = { ...o }, e = o?.background;
|
|
4
|
+
return typeof e == "string" ? r.background = { header: e, footer: e, default: e } : e && typeof e == "object" && (r.background = {
|
|
5
|
+
header: e.header || e.default,
|
|
6
|
+
footer: e.footer || e.default,
|
|
7
|
+
default: e.default
|
|
8
|
+
}), r;
|
|
9
|
+
}, c = (o, r = "en") => {
|
|
10
|
+
if (typeof o == "string") {
|
|
11
|
+
if (f(o)) {
|
|
12
|
+
const t = new URL(o);
|
|
13
|
+
return t.searchParams.set("locale", r), t.href;
|
|
15
14
|
}
|
|
16
|
-
const
|
|
17
|
-
return
|
|
15
|
+
const e = new URL(o, window.location.origin);
|
|
16
|
+
return e.searchParams.set("locale", r), e.pathname + e.search;
|
|
18
17
|
}
|
|
19
|
-
return typeof
|
|
20
|
-
},
|
|
21
|
-
if (!
|
|
22
|
-
return
|
|
23
|
-
const
|
|
24
|
-
return
|
|
25
|
-
|
|
26
|
-
(
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
_rawLink: e.link
|
|
35
|
-
};
|
|
36
|
-
},
|
|
18
|
+
return typeof o == "object" ? o[r] || o?.en || o?.zh : o;
|
|
19
|
+
}, p = (o, r = "en") => {
|
|
20
|
+
if (!o?.length)
|
|
21
|
+
return o;
|
|
22
|
+
const e = (t, n) => t && typeof t == "object" ? t[n] || t?.en || t?.zh : t;
|
|
23
|
+
return s(
|
|
24
|
+
o,
|
|
25
|
+
(t) => ({
|
|
26
|
+
...t,
|
|
27
|
+
title: e(t.title, r),
|
|
28
|
+
description: e(t.description, r),
|
|
29
|
+
// 仅对叶结点进行处理
|
|
30
|
+
link: t.items?.length ? t.link : c(t.link, r),
|
|
31
|
+
_rawLink: t.link
|
|
32
|
+
}),
|
|
37
33
|
"items"
|
|
38
34
|
);
|
|
39
|
-
},
|
|
40
|
-
|
|
41
|
-
(
|
|
42
|
-
...
|
|
43
|
-
role: Array.isArray(
|
|
44
|
-
} :
|
|
35
|
+
}, u = (o) => s(
|
|
36
|
+
o,
|
|
37
|
+
(r) => r.role ? {
|
|
38
|
+
...r,
|
|
39
|
+
role: Array.isArray(r.role) ? r.role : [r.role]
|
|
40
|
+
} : r,
|
|
45
41
|
"items"
|
|
46
|
-
),
|
|
47
|
-
if (!
|
|
42
|
+
), l = (o) => {
|
|
43
|
+
if (!o?.length)
|
|
48
44
|
return null;
|
|
49
|
-
const
|
|
45
|
+
const r = u(o), e = {
|
|
50
46
|
header: [],
|
|
51
47
|
footer: [],
|
|
52
48
|
// 对应 footer social media
|
|
@@ -59,38 +55,32 @@ const w = ((c = window == null ? void 0 : window.blocklet) == null ? void 0 : c.
|
|
|
59
55
|
sessionManager: [],
|
|
60
56
|
userCenter: []
|
|
61
57
|
};
|
|
62
|
-
return
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
}, N = (r) => {
|
|
70
|
-
if (!r)
|
|
58
|
+
return r.forEach((t) => {
|
|
59
|
+
t.section ? Array.isArray(t.section) ? t.section.forEach((n) => {
|
|
60
|
+
e[n]?.push(t);
|
|
61
|
+
}) : typeof t.section == "string" && e[t.section]?.push(t) : e.header.push(t);
|
|
62
|
+
}), e;
|
|
63
|
+
}, b = (o) => {
|
|
64
|
+
if (!o)
|
|
71
65
|
return null;
|
|
72
|
-
const
|
|
73
|
-
return
|
|
74
|
-
},
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
(s, e) => {
|
|
80
|
-
var n;
|
|
81
|
-
const t = !s.role || o && (s.role.includes(o) || s.role.includes("guest"));
|
|
82
|
-
return e.isLeaf ? t : t && ((n = e.filteredChildren) == null ? void 0 : n.length);
|
|
66
|
+
const r = { ...o };
|
|
67
|
+
return r.theme = i(r.theme), r.navigation = l(d(r.navigation)), r;
|
|
68
|
+
}, d = (o = []) => a(o, (r, e) => !!r.link || e.filteredChildren?.length, "items"), y = (o, r) => a(
|
|
69
|
+
o,
|
|
70
|
+
(e, t) => {
|
|
71
|
+
const n = !e.role || r && (e.role.includes(r) || e.role.includes("guest"));
|
|
72
|
+
return t.isLeaf ? n : n && t.filteredChildren?.length;
|
|
83
73
|
},
|
|
84
74
|
"items"
|
|
85
75
|
);
|
|
86
76
|
export {
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
77
|
+
y as filterNavByRole,
|
|
78
|
+
d as filterValidNavItems,
|
|
79
|
+
b as formatBlockletInfo,
|
|
80
|
+
u as formatNavigation,
|
|
81
|
+
i as formatTheme,
|
|
82
|
+
c as getLink,
|
|
83
|
+
p as getLocalizedNavigation,
|
|
84
|
+
l as parseNavigation,
|
|
85
|
+
g as publicPath
|
|
96
86
|
};
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { useState as S, useMemo as
|
|
3
|
-
import
|
|
4
|
-
import { Dialog as T, DialogContent as A, Typography as
|
|
1
|
+
import { jsxs as a, jsx as i } from "react/jsx-runtime";
|
|
2
|
+
import { useState as S, useMemo as d, useCallback as u } from "react";
|
|
3
|
+
import p from "prop-types";
|
|
4
|
+
import { Dialog as T, DialogContent as A, Typography as c, Box as C, DialogActions as W, Button as f } from "@mui/material";
|
|
5
5
|
import { useMemoizedFn as v } from "ahooks";
|
|
6
6
|
import { translate as M } from "@arcblock/ux/lib/Locale/util";
|
|
7
7
|
import { joinURL as O } from "ufo";
|
|
8
8
|
import j from "../hooks/use-mobile.js";
|
|
9
|
-
const z = ["admin", "owner"], I = (
|
|
9
|
+
const z = ["admin", "owner"], I = (t) => t.endsWith(".ip.abtnet.io"), E = (t) => t.endsWith(".did.abtnet.io"), H = {
|
|
10
10
|
en: {
|
|
11
11
|
guest: {
|
|
12
12
|
title: "Notice: You are using a temporary domain",
|
|
@@ -41,21 +41,21 @@ const z = ["admin", "owner"], I = (i) => i.endsWith(".ip.abtnet.io"), E = (i) =>
|
|
|
41
41
|
skip: "稍后提醒",
|
|
42
42
|
bindDomain: "配置域名"
|
|
43
43
|
}
|
|
44
|
-
}, N = 1e3 * 60 * 60 * 24 * 30,
|
|
45
|
-
function P({ locale:
|
|
46
|
-
const
|
|
44
|
+
}, N = 1e3 * 60 * 60 * 24 * 30, w = ".well-known/service/admin/domains";
|
|
45
|
+
function P({ locale: t = "en", session: h = {} }) {
|
|
46
|
+
const l = h?.user, b = j(), [g, s] = S(() => {
|
|
47
47
|
const e = window.localStorage.getItem("domain-warning-skip");
|
|
48
48
|
if (!e) return !0;
|
|
49
|
-
const
|
|
50
|
-
return
|
|
51
|
-
}), n = v((e,
|
|
49
|
+
const r = +/* @__PURE__ */ new Date(), y = +new Date(e);
|
|
50
|
+
return r - y > N;
|
|
51
|
+
}), n = v((e, r = {}) => M(H, e, t, "en", r)), m = d(() => {
|
|
52
52
|
try {
|
|
53
53
|
const { hostname: e } = new URL(window.location.href);
|
|
54
54
|
return e;
|
|
55
55
|
} catch {
|
|
56
56
|
return "";
|
|
57
57
|
}
|
|
58
|
-
}, []), x =
|
|
58
|
+
}, []), x = d(
|
|
59
59
|
() => [
|
|
60
60
|
n("owner.benefits1"),
|
|
61
61
|
n("owner.benefits2"),
|
|
@@ -65,36 +65,36 @@ function P({ locale: i = "en", session: s = {} }) {
|
|
|
65
65
|
],
|
|
66
66
|
[n]
|
|
67
67
|
), D = u(() => {
|
|
68
|
-
window.localStorage.setItem("domain-warning-skip", (/* @__PURE__ */ new Date()).toISOString()),
|
|
68
|
+
window.localStorage.setItem("domain-warning-skip", (/* @__PURE__ */ new Date()).toISOString()), s(!1);
|
|
69
69
|
}, []), k = u(() => {
|
|
70
|
-
const e = O(window.location.origin,
|
|
71
|
-
e.startsWith("http") && window.open(e, "_blank"),
|
|
72
|
-
}, []),
|
|
73
|
-
return window.location.href.includes(
|
|
74
|
-
/* @__PURE__ */
|
|
75
|
-
/* @__PURE__ */
|
|
76
|
-
|
|
70
|
+
const e = O(window.location.origin, w);
|
|
71
|
+
e.startsWith("http") && window.open(e, "_blank"), s(!1);
|
|
72
|
+
}, []), o = l?.role && z.includes(l.role);
|
|
73
|
+
return window.location.href.includes(w) || b || !I(m) && !E(m) ? null : /* @__PURE__ */ a(T, { open: g, disableEscapeKeyDown: !0, fullWidth: !0, maxWidth: "sm", onClose: () => s(!1), children: [
|
|
74
|
+
/* @__PURE__ */ a(A, { sx: { padding: "20px !important" }, children: [
|
|
75
|
+
/* @__PURE__ */ i(
|
|
76
|
+
c,
|
|
77
77
|
{
|
|
78
78
|
sx: {
|
|
79
79
|
fontSize: "20px",
|
|
80
80
|
fontWeight: "500"
|
|
81
81
|
},
|
|
82
|
-
children: n(
|
|
82
|
+
children: n(o ? "owner.title" : "guest.title")
|
|
83
83
|
}
|
|
84
84
|
),
|
|
85
|
-
/* @__PURE__ */
|
|
86
|
-
|
|
85
|
+
/* @__PURE__ */ i(
|
|
86
|
+
c,
|
|
87
87
|
{
|
|
88
88
|
sx: {
|
|
89
89
|
marginTop: "20px",
|
|
90
90
|
fontSize: "14px",
|
|
91
91
|
color: "#9397A1"
|
|
92
92
|
},
|
|
93
|
-
children: n(
|
|
93
|
+
children: n(o ? "owner.description" : "guest.description")
|
|
94
94
|
}
|
|
95
95
|
),
|
|
96
|
-
|
|
97
|
-
|
|
96
|
+
o && /* @__PURE__ */ i(C, { component: "ul", children: x.map((e) => /* @__PURE__ */ i(
|
|
97
|
+
c,
|
|
98
98
|
{
|
|
99
99
|
component: "li",
|
|
100
100
|
sx: {
|
|
@@ -106,15 +106,15 @@ function P({ locale: i = "en", session: s = {} }) {
|
|
|
106
106
|
e
|
|
107
107
|
)) })
|
|
108
108
|
] }),
|
|
109
|
-
/* @__PURE__ */
|
|
110
|
-
/* @__PURE__ */
|
|
111
|
-
|
|
109
|
+
/* @__PURE__ */ a(W, { sx: { px: "12px !important" }, children: [
|
|
110
|
+
/* @__PURE__ */ i(f, { onClick: D, children: n("skip") }),
|
|
111
|
+
o && /* @__PURE__ */ i(f, { variant: "contained", onClick: k, children: n("bindDomain") })
|
|
112
112
|
] })
|
|
113
113
|
] });
|
|
114
114
|
}
|
|
115
115
|
P.propTypes = {
|
|
116
|
-
locale:
|
|
117
|
-
session:
|
|
116
|
+
locale: p.string,
|
|
117
|
+
session: p.object
|
|
118
118
|
};
|
|
119
119
|
export {
|
|
120
120
|
P as default
|
|
@@ -11,7 +11,7 @@ declare function HeaderAddons({ formattedBlocklet, addons, showDomainWarningDial
|
|
|
11
11
|
declare namespace HeaderAddons {
|
|
12
12
|
namespace propTypes {
|
|
13
13
|
export let formattedBlocklet: PropTypes.Validator<object>;
|
|
14
|
-
export let addons: PropTypes.Requireable<NonNullable<
|
|
14
|
+
export let addons: PropTypes.Requireable<NonNullable<((...args: any[]) => any) | PropTypes.ReactNodeLike>>;
|
|
15
15
|
export { SessionManagerProps as sessionManagerProps };
|
|
16
16
|
export let showDomainWarningDialog: PropTypes.Requireable<boolean>;
|
|
17
17
|
}
|
|
@@ -1,75 +1,71 @@
|
|
|
1
|
-
import { jsx as
|
|
1
|
+
import { jsx as s, Fragment as v } from "react/jsx-runtime";
|
|
2
2
|
import "iconify-icon";
|
|
3
|
-
import { use as
|
|
4
|
-
import
|
|
5
|
-
import { SessionContext as
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import { useLocaleContext as
|
|
10
|
-
import
|
|
11
|
-
import { SessionManagerProps as
|
|
12
|
-
import { getLocalizedNavigation as
|
|
13
|
-
import
|
|
14
|
-
import
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
addons: e = null,
|
|
22
|
-
showDomainWarningDialog: c = !0,
|
|
23
|
-
sessionManagerProps: d = { showRole: !0 }
|
|
3
|
+
import { use as b, createElement as k } from "react";
|
|
4
|
+
import r from "prop-types";
|
|
5
|
+
import { SessionContext as w } from "@arcblock/did-connect/lib/Session";
|
|
6
|
+
import L from "@arcblock/ux/lib/SessionUser";
|
|
7
|
+
import N from "@arcblock/ux/lib/SessionBlocklet";
|
|
8
|
+
import T from "@arcblock/ux/lib/Locale/selector";
|
|
9
|
+
import { useLocaleContext as C } from "@arcblock/ux/lib/Locale/context";
|
|
10
|
+
import R from "@arcblock/ux/lib/Config/theme-mode-toggle";
|
|
11
|
+
import { SessionManagerProps as S } from "../types.js";
|
|
12
|
+
import { getLocalizedNavigation as M, filterNavByRole as B } from "../blocklets.js";
|
|
13
|
+
import D from "./notification-addon.js";
|
|
14
|
+
import P from "./domain-warning.js";
|
|
15
|
+
const j = () => !!(window?.blocklet?.navigation ?? []).find((o) => o.id === "/userCenter/notification");
|
|
16
|
+
function x({
|
|
17
|
+
formattedBlocklet: l,
|
|
18
|
+
addons: o = null,
|
|
19
|
+
showDomainWarningDialog: m = !0,
|
|
20
|
+
sessionManagerProps: u = { showRole: !0 }
|
|
24
21
|
}) {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
h.push({
|
|
22
|
+
const n = b(w), { locale: i, languages: p } = C() || {}, { enableConnect: g = !0, enableLocale: d = !0 } = l, h = !!n?.session?.user;
|
|
23
|
+
let a = M(l?.navigation?.sessionManager, i) || [];
|
|
24
|
+
a = B(a, n?.session?.user?.role);
|
|
25
|
+
const c = (() => {
|
|
26
|
+
if (o && typeof o != "function")
|
|
27
|
+
return Array.isArray(o) ? o : [o];
|
|
28
|
+
let e = [];
|
|
29
|
+
if (j() && e.push(/* @__PURE__ */ s(D, { session: n.session }, "notification-addon")), d && i && p.length > 1 && e.push(/* @__PURE__ */ s(T, { showText: !1 }, "locale-selector")), e.push(/* @__PURE__ */ s(R, {}, "theme-mode-toggle")), g && n) {
|
|
30
|
+
const f = [];
|
|
31
|
+
h && (a ? a.slice(0, 5) : []).forEach((t) => {
|
|
32
|
+
f.push({
|
|
37
33
|
label: t.title,
|
|
38
|
-
icon: t.icon ? /* @__PURE__ */
|
|
34
|
+
icon: t.icon ? /* @__PURE__ */ s("iconify-icon", { icon: t.icon, height: 24, style: { marginRight: 8 } }) : null,
|
|
39
35
|
component: "a",
|
|
40
36
|
href: t.link,
|
|
41
37
|
key: t.link
|
|
42
38
|
});
|
|
43
|
-
}),
|
|
44
|
-
/* @__PURE__ */
|
|
45
|
-
|
|
39
|
+
}), e.push(/* @__PURE__ */ s(N, { session: n.session, locale: i }, "session-blocklet")), e.push(
|
|
40
|
+
/* @__PURE__ */ s(
|
|
41
|
+
L,
|
|
46
42
|
{
|
|
47
|
-
session:
|
|
48
|
-
locale:
|
|
49
|
-
menu:
|
|
43
|
+
session: n.session,
|
|
44
|
+
locale: i,
|
|
45
|
+
menu: f,
|
|
50
46
|
showRole: !0,
|
|
51
|
-
...
|
|
47
|
+
...u
|
|
52
48
|
},
|
|
53
49
|
"session-user"
|
|
54
50
|
)
|
|
55
51
|
);
|
|
56
52
|
}
|
|
57
|
-
return typeof
|
|
58
|
-
})(),
|
|
59
|
-
|
|
60
|
-
...
|
|
53
|
+
return typeof o == "function" && (e = o(e) || []), e;
|
|
54
|
+
})(), y = Array.isArray(c) ? c : [c], A = [
|
|
55
|
+
m ? /* @__PURE__ */ s(P, { session: n?.session, locale: i }) : null,
|
|
56
|
+
...y
|
|
61
57
|
].filter(Boolean);
|
|
62
|
-
return
|
|
58
|
+
return k(v, null, ...A);
|
|
63
59
|
}
|
|
64
|
-
|
|
65
|
-
formattedBlocklet:
|
|
60
|
+
x.propTypes = {
|
|
61
|
+
formattedBlocklet: r.object.isRequired,
|
|
66
62
|
// 需要考虑 定制的 addons 与内置的 连接钱包/选择语言 addons 共存的情况
|
|
67
63
|
// - PropTypes.func: 可以把自定义 addons 插在 session-manager 或 locale-selector (如果存在的话) 前/中/后
|
|
68
64
|
// - PropTypes.node: 将 addons 原样传给 UX Header 组件
|
|
69
|
-
addons:
|
|
70
|
-
sessionManagerProps:
|
|
71
|
-
showDomainWarningDialog:
|
|
65
|
+
addons: r.oneOfType([r.func, r.node]),
|
|
66
|
+
sessionManagerProps: S,
|
|
67
|
+
showDomainWarningDialog: r.bool
|
|
72
68
|
};
|
|
73
69
|
export {
|
|
74
|
-
|
|
70
|
+
x as default
|
|
75
71
|
};
|
|
@@ -1,70 +1,67 @@
|
|
|
1
|
-
import { jsx as
|
|
1
|
+
import { jsx as i } from "react/jsx-runtime";
|
|
2
2
|
import R from "prop-types";
|
|
3
3
|
import { useMemo as O, useCallback as h, useEffect as _ } from "react";
|
|
4
4
|
import { IconButton as $, Badge as g } from "@mui/material";
|
|
5
5
|
import { useSnackbar as B } from "notistack";
|
|
6
6
|
import D from "@arcblock/icons/lib/Notification";
|
|
7
|
-
import { useCreation as
|
|
7
|
+
import { useCreation as s } from "ahooks";
|
|
8
8
|
import { WELLKNOWN_SERVICE_PATH_PREFIX as S, EVENTS as y } from "@abtnode/constant";
|
|
9
9
|
import V from "@arcblock/react-hooks/lib/useBrowser";
|
|
10
10
|
import { joinURL as x, withQuery as U } from "ufo";
|
|
11
11
|
import { useListenWsClient as j } from "./ws.js";
|
|
12
12
|
import F from "../Notifications/Snackbar.js";
|
|
13
13
|
import { compareVersions as H } from "../utils.js";
|
|
14
|
-
const
|
|
14
|
+
const v = x(S, "user", "notifications"), K = (r) => U(v, {
|
|
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:
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
() => `${window.blocklet.did}/${
|
|
25
|
-
[
|
|
26
|
-
),
|
|
27
|
-
() =>
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
const C = H(N, "1.16.42-beta-20250407");
|
|
35
|
-
if (!k && e.source === "component" && C) {
|
|
36
|
-
const v = K(e), { severity: T, description: I } = e || {}, L = ["error", "warning"].includes(T) || e.sticky;
|
|
20
|
+
const { unReadCount: b, user: w, setUnReadCount: n } = r, e = s(() => w?.did, [w]), { enqueueSnackbar: E } = B(), c = V(), k = O(() => c.arcSphere || c.wallet, [c]), N = s(() => window.blocklet?.serverVersion, []), t = j("user"), l = s(
|
|
21
|
+
() => `${window.blocklet.did}/${e}/${y.NOTIFICATION_BLOCKLET_CREATE}`,
|
|
22
|
+
[e]
|
|
23
|
+
), u = s(
|
|
24
|
+
() => `${window.blocklet.did}/${e}/${y.NOTIFICATION_BLOCKLET_READ}`,
|
|
25
|
+
[e]
|
|
26
|
+
), d = h(
|
|
27
|
+
(o) => {
|
|
28
|
+
const { receivers: m } = o ?? {}, { receiver: f } = m[0] ?? {};
|
|
29
|
+
if (f === e) {
|
|
30
|
+
n((C) => C + 1);
|
|
31
|
+
const p = H(N, "1.16.42-beta-20250407");
|
|
32
|
+
if (!k && o.source === "component" && p) {
|
|
33
|
+
const C = K(o), { severity: T, description: I } = o || {}, L = ["error", "warning"].includes(T) || o.sticky;
|
|
37
34
|
E(I, {
|
|
38
35
|
variant: T,
|
|
39
36
|
autoHideDuration: L ? null : 5e3,
|
|
40
37
|
// eslint-disable-next-line react/no-unstable-nested-components
|
|
41
|
-
content: (A) => /* @__PURE__ */
|
|
38
|
+
content: (A) => /* @__PURE__ */ i(F, { viewAllUrl: C, keyId: A, notification: o })
|
|
42
39
|
});
|
|
43
40
|
}
|
|
44
41
|
}
|
|
45
42
|
},
|
|
46
|
-
[
|
|
47
|
-
),
|
|
48
|
-
(
|
|
49
|
-
const { receiver:
|
|
50
|
-
|
|
43
|
+
[e, n, E, N, k]
|
|
44
|
+
), a = h(
|
|
45
|
+
(o) => {
|
|
46
|
+
const { receiver: m, readCount: f } = o ?? {};
|
|
47
|
+
m === e && n((p) => Math.max(p - f, 0));
|
|
51
48
|
},
|
|
52
|
-
[
|
|
49
|
+
[e, n]
|
|
53
50
|
);
|
|
54
|
-
return _(() => (t && (t.on(
|
|
55
|
-
t && (t.off(
|
|
56
|
-
}), [t, n,
|
|
51
|
+
return _(() => (t && (t.on(l, d), t.on(u, a)), () => {
|
|
52
|
+
t && (t.off(l, d), t.off(u, a));
|
|
53
|
+
}), [t, n, d, l, a, u]), !r.user || !v ? null : /* @__PURE__ */ i(
|
|
57
54
|
$,
|
|
58
55
|
{
|
|
59
56
|
size: "medium",
|
|
60
57
|
variant: "outlined",
|
|
61
|
-
href:
|
|
58
|
+
href: v,
|
|
62
59
|
sx: {
|
|
63
60
|
"&:hover": {
|
|
64
61
|
borderRadius: "50%"
|
|
65
62
|
}
|
|
66
63
|
},
|
|
67
|
-
children: /* @__PURE__ */
|
|
64
|
+
children: /* @__PURE__ */ i(g, { badgeContent: b, color: "error", invisible: b === 0, children: /* @__PURE__ */ i(D, { style: { width: "auto", height: 24 } }) })
|
|
68
65
|
}
|
|
69
66
|
);
|
|
70
67
|
}
|
package/lib/common/ws.js
CHANGED
|
@@ -1,27 +1,26 @@
|
|
|
1
|
-
import { use as
|
|
2
|
-
import { WsClient as
|
|
3
|
-
import { SessionContext as
|
|
4
|
-
import { joinURL as
|
|
5
|
-
import { BLOCKLET_SERVICE_PATH_PREFIX as
|
|
1
|
+
import { use as s } from "react";
|
|
2
|
+
import { WsClient as o } from "@arcblock/ws";
|
|
3
|
+
import { SessionContext as n } from "@arcblock/did-connect/lib/Session";
|
|
4
|
+
import { joinURL as f } from "ufo";
|
|
5
|
+
import { BLOCKLET_SERVICE_PATH_PREFIX as m } from "@arcblock/ux/lib/Util/constant";
|
|
6
6
|
const e = {};
|
|
7
|
-
function
|
|
8
|
-
var s;
|
|
7
|
+
function a(t = "admin") {
|
|
9
8
|
let r = "/";
|
|
10
|
-
!
|
|
11
|
-
const i =
|
|
12
|
-
return new
|
|
9
|
+
!window?.blocklet && window?.env?.apiPrefix && (r = window.env.apiPrefix);
|
|
10
|
+
const i = f(r, m, t);
|
|
11
|
+
return new o(i, {
|
|
13
12
|
heartbeatIntervalMs: 100 * 1e3
|
|
14
13
|
});
|
|
15
14
|
}
|
|
16
|
-
function
|
|
17
|
-
return e[t] || (e[t] =
|
|
15
|
+
function c(t = "admin") {
|
|
16
|
+
return e[t] || (e[t] = a(t)), e[t];
|
|
18
17
|
}
|
|
19
|
-
const
|
|
20
|
-
const r =
|
|
21
|
-
return !e[t] && i.user && (e[t] =
|
|
18
|
+
const P = (t = "admin") => {
|
|
19
|
+
const r = s(n), { session: i } = r ?? {};
|
|
20
|
+
return !e[t] && i.user && (e[t] = c(t), e[t].connect()), e[t];
|
|
22
21
|
};
|
|
23
22
|
export {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
23
|
+
a as create,
|
|
24
|
+
c as default,
|
|
25
|
+
P as useListenWsClient
|
|
27
26
|
};
|
|
@@ -1,32 +1,29 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { createContext as
|
|
1
|
+
import { jsx as f } from "react/jsx-runtime";
|
|
2
|
+
import { createContext as g, useState as i, use as p, useMemo as C, useEffect as m } from "react";
|
|
3
3
|
import { SessionContext as y } from "@arcblock/did-connect/lib/Session";
|
|
4
|
-
const d =
|
|
4
|
+
const d = g({}), { Provider: w, Consumer: U } = d;
|
|
5
5
|
function h({ children: n }) {
|
|
6
|
-
const [S] =
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
}, [e
|
|
10
|
-
u(
|
|
11
|
-
|
|
12
|
-
},
|
|
13
|
-
const f = async () => {
|
|
14
|
-
o(void 0);
|
|
15
|
-
}, i = (t) => {
|
|
6
|
+
const [S] = i(!1), { session: a } = p(y), { user: e } = a, [s, t] = i(), c = C(() => e?.didSpace?.endpoint, [e?.didSpace]);
|
|
7
|
+
m(() => {
|
|
8
|
+
t(e?.didSpace);
|
|
9
|
+
}, [e?.didSpace]);
|
|
10
|
+
const u = async () => {
|
|
11
|
+
t(void 0);
|
|
12
|
+
}, r = (o) => {
|
|
16
13
|
};
|
|
17
|
-
return /* @__PURE__ */
|
|
14
|
+
return /* @__PURE__ */ f(
|
|
18
15
|
w,
|
|
19
16
|
{
|
|
20
17
|
value: {
|
|
21
18
|
loading: S,
|
|
22
19
|
spaceGateway: s,
|
|
23
20
|
session: a,
|
|
24
|
-
deleteSpaceGateway:
|
|
25
|
-
updateSpaceGateway: async (
|
|
26
|
-
o
|
|
21
|
+
deleteSpaceGateway: u,
|
|
22
|
+
updateSpaceGateway: async (o) => {
|
|
23
|
+
t(o), await r(o.endpoint);
|
|
27
24
|
},
|
|
28
25
|
storageEndpoint: c,
|
|
29
|
-
settingStorageEndpoint:
|
|
26
|
+
settingStorageEndpoint: r,
|
|
30
27
|
hasStorageEndpoint: !!(c && s)
|
|
31
28
|
},
|
|
32
29
|
children: n
|
|
@@ -34,7 +31,7 @@ function h({ children: n }) {
|
|
|
34
31
|
);
|
|
35
32
|
}
|
|
36
33
|
function P() {
|
|
37
|
-
return
|
|
34
|
+
return p(d);
|
|
38
35
|
}
|
|
39
36
|
export {
|
|
40
37
|
U as ConfigUserSpaceConsumer,
|