@blocklet/ui-react 2.12.61 → 2.12.63
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/@types/index.d.ts +5 -0
- package/lib/@types/shims.d.ts +1 -0
- package/lib/Notifications/Snackbar.d.ts +14 -0
- package/lib/Notifications/Snackbar.js +210 -0
- package/lib/Notifications/hooks/use-title.d.ts +48 -0
- package/lib/Notifications/hooks/use-title.js +159 -0
- package/lib/Notifications/hooks/use-width.d.ts +2 -0
- package/lib/Notifications/hooks/use-width.js +11 -0
- package/lib/Notifications/utils.d.ts +70 -0
- package/lib/Notifications/utils.js +130 -0
- package/lib/UserCenter/components/danger-zone.d.ts +1 -0
- package/lib/UserCenter/components/danger-zone.js +125 -0
- package/lib/UserCenter/components/settings.js +21 -8
- package/lib/UserCenter/components/user-info/user-basic-info.js +1 -1
- package/lib/UserCenter/libs/locales.d.ts +32 -0
- package/lib/UserCenter/libs/locales.js +34 -2
- package/lib/common/notification-addon.js +31 -8
- package/lib/utils.d.ts +1 -0
- package/lib/utils.js +26 -0
- package/package.json +13 -6
- package/src/@types/index.ts +5 -0
- package/src/@types/shims.d.ts +1 -0
- package/src/Notifications/Snackbar.tsx +270 -0
- package/src/Notifications/hooks/use-title.tsx +248 -0
- package/src/Notifications/hooks/use-width.tsx +16 -0
- package/src/Notifications/utils.ts +245 -0
- package/src/UserCenter/components/danger-zone.tsx +136 -0
- package/src/UserCenter/components/settings.tsx +20 -7
- package/src/UserCenter/components/user-info/user-basic-info.tsx +1 -1
- package/src/UserCenter/libs/locales.ts +33 -0
- package/src/common/notification-addon.jsx +36 -9
- package/src/utils.js +26 -0
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useContext } from "react";
|
|
3
|
+
import { Box, Button, Typography } from "@mui/material";
|
|
4
|
+
import { useLocaleContext } from "@arcblock/ux/lib/Locale/context";
|
|
5
|
+
import { translate } from "@arcblock/ux/lib/Locale/util";
|
|
6
|
+
import { useCreation, useMemoizedFn } from "ahooks";
|
|
7
|
+
import { useConfirm } from "@arcblock/ux/lib/Dialog";
|
|
8
|
+
import { SessionContext } from "@arcblock/did-connect/lib/Session";
|
|
9
|
+
import { LOGIN_PROVIDER } from "@blocklet/constant";
|
|
10
|
+
import Toast from "@arcblock/ux/lib/Toast";
|
|
11
|
+
import { translations } from "../libs/locales.js";
|
|
12
|
+
import { client } from "../../libs/client.js";
|
|
13
|
+
export default function DangerZone() {
|
|
14
|
+
const { confirmApi, confirmHolder } = useConfirm();
|
|
15
|
+
const { locale } = useLocaleContext();
|
|
16
|
+
const { session, connectApi } = useContext(SessionContext);
|
|
17
|
+
const t = useMemoizedFn((key, data = {}) => {
|
|
18
|
+
return translate(translations, key, locale, "en", data);
|
|
19
|
+
});
|
|
20
|
+
const isNeedVerify = useCreation(() => {
|
|
21
|
+
if (["true", true].includes(window?.blocklet?.ALLOW_SKIP_DESTROY_MYSELF_VERIFY)) {
|
|
22
|
+
return false;
|
|
23
|
+
}
|
|
24
|
+
const connectedAccounts = session?.user?.connectedAccounts || [];
|
|
25
|
+
const ALLOW_VERIFY_PROVIDERS = [LOGIN_PROVIDER.WALLET];
|
|
26
|
+
if (connectedAccounts.some((x) => ALLOW_VERIFY_PROVIDERS.includes(x.provider))) {
|
|
27
|
+
return true;
|
|
28
|
+
}
|
|
29
|
+
return false;
|
|
30
|
+
}, [session?.user]);
|
|
31
|
+
const handleVerify = useMemoizedFn(() => {
|
|
32
|
+
return new Promise((resolve, reject) => {
|
|
33
|
+
const userDid = session?.user?.did;
|
|
34
|
+
connectApi.open({
|
|
35
|
+
locale,
|
|
36
|
+
action: "destroy-myself",
|
|
37
|
+
forceConnected: true,
|
|
38
|
+
saveConnect: false,
|
|
39
|
+
autoConnect: false,
|
|
40
|
+
// 暂不允许使用 passkey 进行验证
|
|
41
|
+
passkeyBehavior: "none",
|
|
42
|
+
extraParams: {
|
|
43
|
+
removeUserDid: userDid
|
|
44
|
+
},
|
|
45
|
+
messages: {
|
|
46
|
+
title: t("destroyMyself.title"),
|
|
47
|
+
scan: t("destroyMyself.scan"),
|
|
48
|
+
confirm: t("destroyMyself.confirm"),
|
|
49
|
+
success: t("destroyMyself.success")
|
|
50
|
+
},
|
|
51
|
+
onSuccess: ({ result }, decrypt = (x) => x) => {
|
|
52
|
+
const decryptResult = decrypt(result);
|
|
53
|
+
resolve(decryptResult);
|
|
54
|
+
},
|
|
55
|
+
onClose: () => {
|
|
56
|
+
connectApi.close();
|
|
57
|
+
reject(new Error(t("destroyMyself.abort")));
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
});
|
|
61
|
+
});
|
|
62
|
+
const handleDeleteAccount = useMemoizedFn(() => {
|
|
63
|
+
confirmApi.open({
|
|
64
|
+
title: t("dangerZone.deleteAccount"),
|
|
65
|
+
content: t("dangerZone.deleteAccountDescription"),
|
|
66
|
+
confirmButtonText: t("common.confirm"),
|
|
67
|
+
confirmButtonProps: {
|
|
68
|
+
color: "error"
|
|
69
|
+
},
|
|
70
|
+
cancelButtonText: t("common.cancel"),
|
|
71
|
+
async onConfirm(close) {
|
|
72
|
+
let result;
|
|
73
|
+
try {
|
|
74
|
+
if (isNeedVerify) {
|
|
75
|
+
result = await handleVerify();
|
|
76
|
+
} else if (client?.user?.destroyMyself instanceof Function) {
|
|
77
|
+
result = await client.user.destroyMyself();
|
|
78
|
+
} else {
|
|
79
|
+
Toast.error(t("notImplemented"));
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
if (result?.did === session?.user?.did) {
|
|
83
|
+
session.logout(close);
|
|
84
|
+
} else {
|
|
85
|
+
Toast.error(t("destroyMyself.error"));
|
|
86
|
+
}
|
|
87
|
+
} catch (error) {
|
|
88
|
+
const errorMessage = error?.response?.data.error || error?.message || t("destroyMyself.error");
|
|
89
|
+
Toast.error(errorMessage);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
});
|
|
94
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
95
|
+
/* @__PURE__ */ jsx(Box, { children: /* @__PURE__ */ jsxs(
|
|
96
|
+
Box,
|
|
97
|
+
{
|
|
98
|
+
sx: {
|
|
99
|
+
display: "flex",
|
|
100
|
+
alignItems: "center",
|
|
101
|
+
gap: 1,
|
|
102
|
+
justifyContent: "space-between"
|
|
103
|
+
},
|
|
104
|
+
children: [
|
|
105
|
+
/* @__PURE__ */ jsxs(Box, { children: [
|
|
106
|
+
/* @__PURE__ */ jsx(
|
|
107
|
+
Typography,
|
|
108
|
+
{
|
|
109
|
+
variant: "h6",
|
|
110
|
+
sx: {
|
|
111
|
+
fontSize: "0.875rem !important",
|
|
112
|
+
fontWeight: "bold"
|
|
113
|
+
},
|
|
114
|
+
children: t("dangerZone.deleteAccount")
|
|
115
|
+
}
|
|
116
|
+
),
|
|
117
|
+
/* @__PURE__ */ jsx(Typography, { variant: "caption", color: "text.secondary", children: t("dangerZone.deleteAccountDescription") })
|
|
118
|
+
] }),
|
|
119
|
+
/* @__PURE__ */ jsx(Button, { variant: "contained", color: "error", size: "small", onClick: handleDeleteAccount, children: t("dangerZone.delete") })
|
|
120
|
+
]
|
|
121
|
+
}
|
|
122
|
+
) }),
|
|
123
|
+
confirmHolder
|
|
124
|
+
] });
|
|
125
|
+
}
|
|
@@ -4,6 +4,7 @@ import { Box, Typography } from "@mui/material";
|
|
|
4
4
|
import { useCreation, useMemoizedFn } from "ahooks";
|
|
5
5
|
import { translate } from "@arcblock/ux/lib/Locale/util";
|
|
6
6
|
import { useLocaleContext } from "@arcblock/ux/lib/Locale/context";
|
|
7
|
+
import { mergeSx } from "@arcblock/ux/lib/Util/style";
|
|
7
8
|
import colors from "@arcblock/ux/lib/Colors/themes/temp";
|
|
8
9
|
import { translations } from "../libs/locales.js";
|
|
9
10
|
import Notification from "./notification.js";
|
|
@@ -11,6 +12,7 @@ import Privacy from "./privacy.js";
|
|
|
11
12
|
import { UserSessions } from "../../UserSessions/index.js";
|
|
12
13
|
import ThirdPartyLogin from "./third-party-login/index.js";
|
|
13
14
|
import ConfigProfile from "./config-profile.js";
|
|
15
|
+
import DangerZone from "./danger-zone.js";
|
|
14
16
|
export default function Settings({
|
|
15
17
|
user,
|
|
16
18
|
settings,
|
|
@@ -58,6 +60,14 @@ export default function Settings({
|
|
|
58
60
|
label: t("sessionManagement"),
|
|
59
61
|
value: "session",
|
|
60
62
|
content: /* @__PURE__ */ jsx(UserSessions, { user, showUser: false })
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
label: t("dangerZone.title"),
|
|
66
|
+
value: "dangerZone",
|
|
67
|
+
content: /* @__PURE__ */ jsx(DangerZone, {}),
|
|
68
|
+
sx: {
|
|
69
|
+
borderColor: "error.main"
|
|
70
|
+
}
|
|
61
71
|
}
|
|
62
72
|
].filter(Boolean);
|
|
63
73
|
}, [user, privacyConfigList]);
|
|
@@ -86,14 +96,17 @@ export default function Settings({
|
|
|
86
96
|
Box,
|
|
87
97
|
{
|
|
88
98
|
id: tab.value,
|
|
89
|
-
sx:
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
99
|
+
sx: mergeSx(
|
|
100
|
+
{
|
|
101
|
+
border: `1px solid ${colors.dividerColor}`,
|
|
102
|
+
borderRadius: 2,
|
|
103
|
+
p: 2,
|
|
104
|
+
"&:last-child": {
|
|
105
|
+
mb: 5
|
|
106
|
+
}
|
|
107
|
+
},
|
|
108
|
+
tab.sx
|
|
109
|
+
),
|
|
97
110
|
children: [
|
|
98
111
|
/* @__PURE__ */ jsx(
|
|
99
112
|
Typography,
|
|
@@ -97,6 +97,12 @@ export declare const translations: {
|
|
|
97
97
|
title: string;
|
|
98
98
|
locale: string;
|
|
99
99
|
};
|
|
100
|
+
dangerZone: {
|
|
101
|
+
title: string;
|
|
102
|
+
deleteAccount: string;
|
|
103
|
+
deleteAccountDescription: string;
|
|
104
|
+
delete: string;
|
|
105
|
+
};
|
|
100
106
|
userStatus: {
|
|
101
107
|
Online: string;
|
|
102
108
|
Meeting: string;
|
|
@@ -152,6 +158,16 @@ export declare const translations: {
|
|
|
152
158
|
invalidPostalCode: string;
|
|
153
159
|
};
|
|
154
160
|
};
|
|
161
|
+
destroyMyself: {
|
|
162
|
+
title: string;
|
|
163
|
+
scan: string;
|
|
164
|
+
confirm: string;
|
|
165
|
+
cancel: string;
|
|
166
|
+
success: string;
|
|
167
|
+
abort: string;
|
|
168
|
+
error: string;
|
|
169
|
+
};
|
|
170
|
+
notImplemented: string;
|
|
155
171
|
};
|
|
156
172
|
en: {
|
|
157
173
|
settings: string;
|
|
@@ -251,6 +267,12 @@ export declare const translations: {
|
|
|
251
267
|
title: string;
|
|
252
268
|
locale: string;
|
|
253
269
|
};
|
|
270
|
+
dangerZone: {
|
|
271
|
+
title: string;
|
|
272
|
+
deleteAccount: string;
|
|
273
|
+
deleteAccountDescription: string;
|
|
274
|
+
delete: string;
|
|
275
|
+
};
|
|
254
276
|
userStatus: {
|
|
255
277
|
Online: string;
|
|
256
278
|
Meeting: string;
|
|
@@ -307,5 +329,15 @@ export declare const translations: {
|
|
|
307
329
|
invalidPostalCode: string;
|
|
308
330
|
};
|
|
309
331
|
};
|
|
332
|
+
destroyMyself: {
|
|
333
|
+
title: string;
|
|
334
|
+
scan: string;
|
|
335
|
+
confirm: string;
|
|
336
|
+
cancel: string;
|
|
337
|
+
success: string;
|
|
338
|
+
abort: string;
|
|
339
|
+
error: string;
|
|
340
|
+
};
|
|
341
|
+
notImplemented: string;
|
|
310
342
|
};
|
|
311
343
|
};
|
|
@@ -97,6 +97,12 @@ export const translations = {
|
|
|
97
97
|
title: "\u901A\u7528\u8BBE\u7F6E",
|
|
98
98
|
locale: "\u504F\u597D\u8BED\u8A00"
|
|
99
99
|
},
|
|
100
|
+
dangerZone: {
|
|
101
|
+
title: "\u5371\u9669\u64CD\u4F5C",
|
|
102
|
+
deleteAccount: "\u5220\u9664\u8D26\u6237",
|
|
103
|
+
deleteAccountDescription: "\u5220\u9664\u8D26\u6237\u540E\uFF0C\u60A8\u5C06\u65E0\u6CD5\u4F7F\u7528\u8BE5\u8D26\u6237\u767B\u5F55\uFF0C\u60A8\u7684\u6570\u636E\u5C06\u4ECE\u5E73\u53F0\u4E2D\u5B8C\u5168\u5220\u9664\uFF0C\u4E0D\u53EF\u6062\u590D\u3002",
|
|
104
|
+
delete: "\u5220\u9664"
|
|
105
|
+
},
|
|
100
106
|
userStatus: {
|
|
101
107
|
Online: "\u5728\u7EBF",
|
|
102
108
|
Meeting: "\u5F00\u4F1A\u4E2D",
|
|
@@ -151,7 +157,17 @@ export const translations = {
|
|
|
151
157
|
postalCode: "\u90AE\u653F\u7F16\u7801",
|
|
152
158
|
invalidPostalCode: "\u90AE\u653F\u7F16\u7801\u683C\u5F0F\u4E0D\u6B63\u786E"
|
|
153
159
|
}
|
|
154
|
-
}
|
|
160
|
+
},
|
|
161
|
+
destroyMyself: {
|
|
162
|
+
title: "\u5220\u9664\u8D26\u6237",
|
|
163
|
+
scan: "\u5220\u9664\u8D26\u6237\u540E\uFF0C\u60A8\u5C06\u65E0\u6CD5\u4F7F\u7528\u8BE5\u8D26\u6237\u767B\u5F55\uFF0C\u60A8\u7684\u6570\u636E\u5C06\u4ECE\u5E73\u53F0\u4E2D\u5B8C\u5168\u5220\u9664\uFF0C\u4E0D\u53EF\u6062\u590D\u3002",
|
|
164
|
+
confirm: "\u786E\u8BA4\u5220\u9664",
|
|
165
|
+
cancel: "\u53D6\u6D88",
|
|
166
|
+
success: "\u5220\u9664\u8D26\u6237\u6210\u529F",
|
|
167
|
+
abort: "\u53D6\u6D88\u5220\u9664\u8D26\u6237",
|
|
168
|
+
error: "\u5220\u9664\u8D26\u6237\u5931\u8D25"
|
|
169
|
+
},
|
|
170
|
+
notImplemented: "\u64CD\u4F5C\u672A\u5B9E\u73B0"
|
|
155
171
|
},
|
|
156
172
|
en: {
|
|
157
173
|
settings: "Settings",
|
|
@@ -251,6 +267,12 @@ export const translations = {
|
|
|
251
267
|
title: "Common Settings",
|
|
252
268
|
locale: "Preferred language"
|
|
253
269
|
},
|
|
270
|
+
dangerZone: {
|
|
271
|
+
title: "Danger Zone",
|
|
272
|
+
deleteAccount: "Delete Account",
|
|
273
|
+
deleteAccountDescription: "Delete account will make you unable to login with this account, your data will be completely deleted from the platform and cannot be recovered.",
|
|
274
|
+
delete: "Delete"
|
|
275
|
+
},
|
|
254
276
|
userStatus: {
|
|
255
277
|
Online: "Online",
|
|
256
278
|
Meeting: "In a Meeting",
|
|
@@ -306,6 +328,16 @@ export const translations = {
|
|
|
306
328
|
postalCode: "Postal Code",
|
|
307
329
|
invalidPostalCode: "Postal code is invalid"
|
|
308
330
|
}
|
|
309
|
-
}
|
|
331
|
+
},
|
|
332
|
+
destroyMyself: {
|
|
333
|
+
title: "Delete Account",
|
|
334
|
+
scan: "Delete account will make you unable to login with this account, your data will be completely deleted from the platform and cannot be recovered.",
|
|
335
|
+
confirm: "Confirm delete",
|
|
336
|
+
cancel: "Cancel",
|
|
337
|
+
success: "Delete account successfully",
|
|
338
|
+
abort: "Delete account aborted",
|
|
339
|
+
error: "Delete account failed"
|
|
340
|
+
},
|
|
341
|
+
notImplemented: "This action is not implemented"
|
|
310
342
|
}
|
|
311
343
|
};
|
|
@@ -4,18 +4,29 @@ import PropTypes from "prop-types";
|
|
|
4
4
|
import { useCallback, useEffect } from "react";
|
|
5
5
|
import { temp as colors } from "@arcblock/ux/lib/Colors";
|
|
6
6
|
import { IconButton } from "@mui/material";
|
|
7
|
+
import { useSnackbar } from "notistack";
|
|
7
8
|
import NotificationsOutlinedIcon from "@arcblock/icons/lib/Notification";
|
|
8
9
|
import { useCreation } from "ahooks";
|
|
9
|
-
import { EVENTS } from "@abtnode/constant";
|
|
10
|
+
import { EVENTS, WELLKNOWN_SERVICE_PATH_PREFIX } from "@abtnode/constant";
|
|
11
|
+
import { joinURL, withQuery } from "ufo";
|
|
10
12
|
import { useListenWsClient } from "./ws.js";
|
|
13
|
+
import NotificationSnackbar from "../Notifications/Snackbar.js";
|
|
14
|
+
import { compareVersions } from "../utils.js";
|
|
15
|
+
const viewAllUrl = joinURL(WELLKNOWN_SERVICE_PATH_PREFIX, "user", "notifications");
|
|
16
|
+
const getNotificationLink = (notification) => {
|
|
17
|
+
return withQuery(viewAllUrl, {
|
|
18
|
+
id: notification.id,
|
|
19
|
+
severity: notification.severity || "all",
|
|
20
|
+
componentDid: notification.source === "system" ? "system" : notification.componentDid || "all"
|
|
21
|
+
});
|
|
22
|
+
};
|
|
11
23
|
export default function NotificationAddon({ session = {} }) {
|
|
12
24
|
const { unReadCount, user, setUnReadCount } = session;
|
|
13
25
|
const userDid = useCreation(() => user?.did, [user]);
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
});
|
|
26
|
+
const { enqueueSnackbar } = useSnackbar();
|
|
27
|
+
const serverVersion = useCreation(() => {
|
|
28
|
+
return window.blocklet?.serverVersion;
|
|
29
|
+
}, []);
|
|
19
30
|
const wsClient = useListenWsClient("user");
|
|
20
31
|
const listenEvent = useCreation(
|
|
21
32
|
() => `${window.blocklet.did}/${userDid}/${EVENTS.NOTIFICATION_BLOCKLET_CREATE}`,
|
|
@@ -31,15 +42,27 @@ export default function NotificationAddon({ session = {} }) {
|
|
|
31
42
|
const { receiver: notificationReceiver } = receivers[0] ?? {};
|
|
32
43
|
if (notificationReceiver === userDid) {
|
|
33
44
|
setUnReadCount((x) => x + 1);
|
|
45
|
+
const isCompatible = compareVersions(serverVersion, "1.16.42-beta-20250407");
|
|
46
|
+
if (notification.source === "component" && isCompatible) {
|
|
47
|
+
const link = getNotificationLink(notification);
|
|
48
|
+
const { severity, description } = notification || {};
|
|
49
|
+
const disableAutoHide = ["error", "warning"].includes(severity) || notification.sticky;
|
|
50
|
+
enqueueSnackbar(description, {
|
|
51
|
+
variant: severity,
|
|
52
|
+
autoHideDuration: disableAutoHide ? null : 5e3,
|
|
53
|
+
// eslint-disable-next-line react/no-unstable-nested-components
|
|
54
|
+
content: (key) => /* @__PURE__ */ jsx(NotificationSnackbar, { viewAllUrl: link, keyId: key, notification })
|
|
55
|
+
});
|
|
56
|
+
}
|
|
34
57
|
}
|
|
35
58
|
},
|
|
36
|
-
[userDid, setUnReadCount]
|
|
59
|
+
[userDid, setUnReadCount, enqueueSnackbar, serverVersion]
|
|
37
60
|
);
|
|
38
61
|
const readListenCallback = useCallback(
|
|
39
62
|
(data) => {
|
|
40
63
|
const { receiver, readCount } = data ?? {};
|
|
41
64
|
if (receiver === userDid) {
|
|
42
|
-
setUnReadCount((x) => x - readCount
|
|
65
|
+
setUnReadCount((x) => Math.max(x - readCount, 0));
|
|
43
66
|
}
|
|
44
67
|
},
|
|
45
68
|
[userDid, setUnReadCount]
|
package/lib/utils.d.ts
CHANGED
|
@@ -7,3 +7,4 @@ export function isIconifyString(str: any): boolean;
|
|
|
7
7
|
export function matchPath(path: any): any;
|
|
8
8
|
export function matchPaths(paths?: any[]): number;
|
|
9
9
|
export function splitNavColumns(items: any, options?: {}): never[][];
|
|
10
|
+
export function compareVersions(version1: any, version2: any): any;
|
package/lib/utils.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import semver from 'semver';
|
|
2
|
+
|
|
1
3
|
export const mapRecursive = (array, fn, childrenKey = 'children') => {
|
|
2
4
|
return array.map((item) => {
|
|
3
5
|
if (Array.isArray(item[childrenKey])) {
|
|
@@ -151,3 +153,27 @@ export const splitNavColumns = (items, options = {}) => {
|
|
|
151
153
|
|
|
152
154
|
return result;
|
|
153
155
|
};
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* 比较两个版本号,用于判断版本号是否兼容
|
|
159
|
+
* @param {*} version1
|
|
160
|
+
* @param {*} version2
|
|
161
|
+
* @returns 0: 版本相同, -1: version1 < version2, 1: version1 > version2
|
|
162
|
+
*/
|
|
163
|
+
export const compareVersions = (version1, version2) => {
|
|
164
|
+
const getDateVersion = (version) => {
|
|
165
|
+
const match = version.match(/^(\d+\.\d+\.\d+(?:-[^-]+?-\d{8}))/);
|
|
166
|
+
return match ? match[1] : version;
|
|
167
|
+
};
|
|
168
|
+
|
|
169
|
+
const dateVersion1 = getDateVersion(version1);
|
|
170
|
+
const dateVersion2 = getDateVersion(version2);
|
|
171
|
+
|
|
172
|
+
// 如果基础版本相同,但完整版本不同(意味着有额外部分),返回false
|
|
173
|
+
if (dateVersion1 === dateVersion2 && version1 !== version2) {
|
|
174
|
+
return false;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
// 其他情况正常比较
|
|
178
|
+
return semver.gte(dateVersion1, dateVersion2);
|
|
179
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blocklet/ui-react",
|
|
3
|
-
"version": "2.12.
|
|
3
|
+
"version": "2.12.63",
|
|
4
4
|
"description": "Some useful front-end web components that can be used in Blocklets.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -33,30 +33,36 @@
|
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
35
|
"@abtnode/constant": "^1.16.41",
|
|
36
|
-
"@
|
|
37
|
-
"@arcblock/
|
|
38
|
-
"@arcblock/
|
|
39
|
-
"@
|
|
36
|
+
"@abtnode/util": "^1.16.41",
|
|
37
|
+
"@arcblock/bridge": "^2.12.63",
|
|
38
|
+
"@arcblock/react-hooks": "^2.12.63",
|
|
39
|
+
"@arcblock/ws": "^1.19.19",
|
|
40
|
+
"@blocklet/constant": "^1.16.42-beta-20250408-072924-4b6a877a",
|
|
41
|
+
"@blocklet/did-space-react": "^1.0.43",
|
|
40
42
|
"@iconify-icons/logos": "^1.2.36",
|
|
41
43
|
"@iconify-icons/material-symbols": "^1.2.58",
|
|
44
|
+
"@iconify-icons/tabler": "^1.2.95",
|
|
42
45
|
"@iconify/react": "^5.2.0",
|
|
43
46
|
"ahooks": "^3.7.10",
|
|
44
47
|
"axios": "^1.7.5",
|
|
45
48
|
"clsx": "^2.1.0",
|
|
46
49
|
"core-js": "^3.25.5",
|
|
47
50
|
"dayjs": "^1.11.5",
|
|
51
|
+
"dompurify": "^3.2.1",
|
|
48
52
|
"iconify-icon": "^1.0.8",
|
|
49
53
|
"iconify-icons-material-symbols-400": "^0.0.1",
|
|
50
54
|
"is-url": "^1.2.4",
|
|
51
55
|
"js-cookie": "^2.2.1",
|
|
52
56
|
"lodash": "^4.17.21",
|
|
53
57
|
"moment-timezone": "^0.5.37",
|
|
58
|
+
"notistack": "^2.0.5",
|
|
54
59
|
"p-all": "^5.0.0",
|
|
55
60
|
"p-queue": "^6.6.2",
|
|
56
61
|
"p-wait-for": "^5.0.2",
|
|
57
62
|
"prop-types": "^15.8.1",
|
|
58
63
|
"react-error-boundary": "^3.1.4",
|
|
59
64
|
"react-placeholder": "^4.1.0",
|
|
65
|
+
"semver": "^7.6.3",
|
|
60
66
|
"type-fest": "^4.22.0",
|
|
61
67
|
"ua-parser-js": "^1.0.37",
|
|
62
68
|
"ufo": "^1.5.3",
|
|
@@ -81,11 +87,12 @@
|
|
|
81
87
|
"@babel/core": "^7.19.3",
|
|
82
88
|
"@babel/preset-env": "^7.19.3",
|
|
83
89
|
"@babel/preset-react": "^7.18.6",
|
|
90
|
+
"@types/dompurify": "^3.2.0",
|
|
84
91
|
"@types/ua-parser-js": "^0.7.39",
|
|
85
92
|
"eslint-plugin-react-hooks": "^4.6.0",
|
|
86
93
|
"glob": "^10.3.3",
|
|
87
94
|
"jest": "^29.7.0",
|
|
88
95
|
"unbuild": "^2.0.0"
|
|
89
96
|
},
|
|
90
|
-
"gitHead": "
|
|
97
|
+
"gitHead": "47f8ac34d544cb600e084266ceb722989476f287"
|
|
91
98
|
}
|
package/src/@types/index.ts
CHANGED
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
import type { Axios } from 'axios';
|
|
2
2
|
import type { UserPublicInfo } from '@blocklet/js-sdk';
|
|
3
3
|
import { OAUTH_PROVIDER } from '@arcblock/ux/lib/Util/constant';
|
|
4
|
+
import type { CloseConnect, OpenConnect } from '@arcblock/did-connect/lib/types';
|
|
4
5
|
|
|
5
6
|
export type SessionContext = {
|
|
6
7
|
session: Session;
|
|
7
8
|
api: Axios;
|
|
9
|
+
connectApi: {
|
|
10
|
+
open: OpenConnect;
|
|
11
|
+
close: CloseConnect;
|
|
12
|
+
};
|
|
8
13
|
};
|
|
9
14
|
|
|
10
15
|
export type OAuthAccount = {
|
package/src/@types/shims.d.ts
CHANGED
|
@@ -7,6 +7,7 @@ declare module '@arcblock/ux/lib/ErrorBoundary';
|
|
|
7
7
|
declare module '@arcblock/did-connect/*';
|
|
8
8
|
declare module '@arcblock/did-connect/lib/Session';
|
|
9
9
|
declare module '@abtnode/constant';
|
|
10
|
+
declare module '@abtnode/util/lib/notification-preview/*';
|
|
10
11
|
|
|
11
12
|
declare module 'is-url';
|
|
12
13
|
|