@blocklet/ui-react 2.9.90 → 2.10.0
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/build.config.ts +1 -6
- package/lib/@types/index.d.ts +1 -0
- package/lib/@types/index.js +0 -1
- package/lib/BlockletStudio/index.js +50 -50
- package/lib/ComponentInstaller/index.js +122 -202
- package/lib/ComponentInstaller/installer-item.js +116 -138
- package/lib/ComponentInstaller/locales.js +5 -10
- package/lib/ComponentInstaller/use-component-installed.js +37 -41
- package/lib/ComponentManager/components/add-component.js +58 -67
- package/lib/ComponentManager/components/check-component.js +2 -9
- package/lib/ComponentManager/components/publish-component.js +50 -59
- package/lib/ComponentManager/components/resource-dialog.js +42 -39
- package/lib/ComponentManager/index.js +3 -27
- package/lib/ComponentManager/libs/locales.js +2 -8
- package/lib/Dashboard/index.js +74 -99
- package/lib/Footer/brand.js +21 -43
- package/lib/Footer/copyright.js +15 -24
- package/lib/Footer/index.js +47 -71
- package/lib/Footer/internal-footer.js +72 -100
- package/lib/Footer/layout/plain.js +26 -45
- package/lib/Footer/layout/row.js +12 -29
- package/lib/Footer/layout/standard.js +34 -64
- package/lib/Footer/links.js +74 -104
- package/lib/Footer/social-media.js +35 -42
- package/lib/Header/index.js +69 -117
- package/lib/Icon/index.js +18 -53
- package/{es/UserCenter/components/notification.d.ts → lib/UserCenter/components/config-profile.d.ts} +1 -1
- package/lib/UserCenter/components/config-profile.js +67 -0
- package/lib/UserCenter/components/notification.js +203 -186
- package/lib/UserCenter/components/passport.js +70 -79
- package/lib/UserCenter/components/privacy.js +86 -88
- package/lib/UserCenter/components/settings.js +74 -84
- package/lib/UserCenter/components/storage/connect-to.js +56 -75
- package/lib/UserCenter/components/storage/connected.js +16 -37
- package/lib/UserCenter/components/storage/delete.js +42 -51
- package/lib/UserCenter/components/storage/disconnect.js +15 -29
- package/lib/UserCenter/components/storage/index.js +20 -54
- package/lib/UserCenter/components/storage/item.js +94 -122
- package/lib/UserCenter/components/storage/preview-nft.js +77 -85
- package/lib/UserCenter/components/third-party-login/index.js +49 -61
- package/lib/UserCenter/components/third-party-login/third-party-item.js +159 -176
- package/lib/UserCenter/components/user-center.js +276 -287
- package/lib/UserCenter/components/user-info/index.js +3 -27
- package/lib/UserCenter/components/user-info/user-basic-info.js +134 -129
- package/lib/UserCenter/components/user-info/user-info-item.js +43 -37
- package/lib/UserCenter/components/user-info/user-info.js +41 -74
- package/lib/UserCenter/components/webhook-item.js +184 -177
- package/lib/UserCenter/index.js +1 -13
- package/lib/UserCenter/libs/api.js +4 -16
- package/lib/UserCenter/libs/locales.d.ts +10 -0
- package/lib/UserCenter/libs/locales.js +12 -8
- package/lib/UserCenter/libs/utils.js +7 -17
- package/lib/UserSessions/components/user-session-info.js +88 -85
- package/lib/UserSessions/components/user-sessions.js +177 -213
- package/lib/UserSessions/index.js +1 -13
- package/lib/UserSessions/libs/locales.js +2 -8
- package/lib/UserSessions/libs/utils.js +4 -11
- package/lib/blocklets.js +59 -63
- package/lib/common/header-addons.js +44 -60
- package/lib/common/link-blocker.js +9 -18
- package/lib/common/overridable-theme-provider.js +10 -23
- package/lib/common/wallet-hidden-topbar.js +7 -14
- package/lib/contexts/config-user-space.js +38 -46
- package/lib/hooks/use-mobile.js +5 -13
- package/lib/index.js +10 -100
- package/lib/libs/client.js +2 -8
- package/lib/libs/spaces.js +6 -13
- package/lib/types.js +39 -41
- package/lib/utils.js +25 -44
- package/package.json +8 -38
- package/src/@types/index.ts +1 -0
- package/src/Footer/brand.jsx +6 -1
- package/src/UserCenter/components/config-profile.tsx +70 -0
- package/src/UserCenter/components/notification.tsx +63 -47
- package/src/UserCenter/components/settings.tsx +6 -0
- package/src/UserCenter/libs/locales.ts +10 -0
- package/es/@types/index.d.ts +0 -101
- package/es/@types/index.js +0 -0
- package/es/@types/shims.d.ts +0 -16
- package/es/BlockletStudio/index.d.ts +0 -28
- package/es/BlockletStudio/index.js +0 -114
- package/es/ComponentInstaller/index.d.ts +0 -37
- package/es/ComponentInstaller/index.js +0 -200
- package/es/ComponentInstaller/installer-item.d.ts +0 -21
- package/es/ComponentInstaller/installer-item.js +0 -139
- package/es/ComponentInstaller/locales.d.ts +0 -28
- package/es/ComponentInstaller/locales.js +0 -22
- package/es/ComponentInstaller/use-component-installed.d.ts +0 -12
- package/es/ComponentInstaller/use-component-installed.js +0 -88
- package/es/ComponentManager/components/add-component.d.ts +0 -16
- package/es/ComponentManager/components/add-component.js +0 -114
- package/es/ComponentManager/components/check-component.d.ts +0 -2
- package/es/ComponentManager/components/check-component.js +0 -2
- package/es/ComponentManager/components/publish-component.d.ts +0 -10
- package/es/ComponentManager/components/publish-component.js +0 -76
- package/es/ComponentManager/components/resource-dialog.d.ts +0 -14
- package/es/ComponentManager/components/resource-dialog.js +0 -74
- package/es/ComponentManager/index.d.ts +0 -3
- package/es/ComponentManager/index.js +0 -3
- package/es/ComponentManager/libs/locales.d.ts +0 -14
- package/es/ComponentManager/libs/locales.js +0 -14
- package/es/Dashboard/index.d.ts +0 -40
- package/es/Dashboard/index.js +0 -118
- package/es/Footer/brand.d.ts +0 -22
- package/es/Footer/brand.js +0 -73
- package/es/Footer/copyright.d.ts +0 -18
- package/es/Footer/copyright.js +0 -25
- package/es/Footer/index.d.ts +0 -6
- package/es/Footer/index.js +0 -82
- package/es/Footer/internal-footer.d.ts +0 -29
- package/es/Footer/internal-footer.js +0 -117
- package/es/Footer/layout/plain.d.ts +0 -15
- package/es/Footer/layout/plain.js +0 -39
- package/es/Footer/layout/row.d.ts +0 -18
- package/es/Footer/layout/row.js +0 -41
- package/es/Footer/layout/standard.d.ts +0 -15
- package/es/Footer/layout/standard.js +0 -53
- package/es/Footer/links.d.ts +0 -22
- package/es/Footer/links.js +0 -207
- package/es/Footer/social-media.d.ts +0 -14
- package/es/Footer/social-media.js +0 -60
- package/es/Header/index.d.ts +0 -10
- package/es/Header/index.js +0 -155
- package/es/Icon/index.d.ts +0 -23
- package/es/Icon/index.js +0 -55
- package/es/UserCenter/assets/banner.png +0 -0
- package/es/UserCenter/components/notification.js +0 -248
- package/es/UserCenter/components/passport.d.ts +0 -6
- package/es/UserCenter/components/passport.js +0 -88
- package/es/UserCenter/components/privacy.d.ts +0 -11
- package/es/UserCenter/components/privacy.js +0 -99
- package/es/UserCenter/components/settings.d.ts +0 -9
- package/es/UserCenter/components/settings.js +0 -89
- package/es/UserCenter/components/storage/connect-to.d.ts +0 -7
- package/es/UserCenter/components/storage/connect-to.js +0 -108
- package/es/UserCenter/components/storage/connected.d.ts +0 -7
- package/es/UserCenter/components/storage/connected.js +0 -24
- package/es/UserCenter/components/storage/delete.d.ts +0 -7
- package/es/UserCenter/components/storage/delete.js +0 -62
- package/es/UserCenter/components/storage/disconnect.d.ts +0 -3
- package/es/UserCenter/components/storage/disconnect.js +0 -23
- package/es/UserCenter/components/storage/icons/empty-spaces-nft.svg +0 -58
- package/es/UserCenter/components/storage/icons/long-arrow.svg +0 -5
- package/es/UserCenter/components/storage/icons/space-connected.svg +0 -3
- package/es/UserCenter/components/storage/icons/space-disconnect.svg +0 -3
- package/es/UserCenter/components/storage/index.d.ts +0 -3
- package/es/UserCenter/components/storage/index.js +0 -27
- package/es/UserCenter/components/storage/item.d.ts +0 -9
- package/es/UserCenter/components/storage/item.js +0 -158
- package/es/UserCenter/components/storage/preview-nft.d.ts +0 -6
- package/es/UserCenter/components/storage/preview-nft.js +0 -80
- package/es/UserCenter/components/third-party-login/index.d.ts +0 -5
- package/es/UserCenter/components/third-party-login/index.js +0 -110
- package/es/UserCenter/components/third-party-login/third-party-item.d.ts +0 -13
- package/es/UserCenter/components/third-party-login/third-party-item.js +0 -224
- package/es/UserCenter/components/user-center.d.ts +0 -15
- package/es/UserCenter/components/user-center.js +0 -414
- package/es/UserCenter/components/user-info/index.d.ts +0 -3
- package/es/UserCenter/components/user-info/index.js +0 -3
- package/es/UserCenter/components/user-info/user-basic-info.d.ts +0 -11
- package/es/UserCenter/components/user-info/user-basic-info.js +0 -151
- package/es/UserCenter/components/user-info/user-info-item.d.ts +0 -11
- package/es/UserCenter/components/user-info/user-info-item.js +0 -47
- package/es/UserCenter/components/user-info/user-info.d.ts +0 -6
- package/es/UserCenter/components/user-info/user-info.js +0 -66
- package/es/UserCenter/components/webhook-item.d.ts +0 -3
- package/es/UserCenter/components/webhook-item.js +0 -243
- package/es/UserCenter/index.d.ts +0 -1
- package/es/UserCenter/index.js +0 -1
- package/es/UserCenter/libs/api.d.ts +0 -3
- package/es/UserCenter/libs/api.js +0 -4
- package/es/UserCenter/libs/locales.d.ts +0 -162
- package/es/UserCenter/libs/locales.js +0 -162
- package/es/UserCenter/libs/utils.d.ts +0 -4
- package/es/UserCenter/libs/utils.js +0 -14
- package/es/UserSessions/components/user-session-info.d.ts +0 -6
- package/es/UserSessions/components/user-session-info.js +0 -92
- package/es/UserSessions/components/user-sessions.d.ts +0 -9
- package/es/UserSessions/components/user-sessions.js +0 -265
- package/es/UserSessions/index.d.ts +0 -1
- package/es/UserSessions/index.js +0 -1
- package/es/UserSessions/libs/locales.d.ts +0 -58
- package/es/UserSessions/libs/locales.js +0 -58
- package/es/UserSessions/libs/utils.d.ts +0 -2
- package/es/UserSessions/libs/utils.js +0 -73
- package/es/blocklets.d.ts +0 -16
- package/es/blocklets.js +0 -178
- package/es/common/header-addons.d.ts +0 -21
- package/es/common/header-addons.js +0 -83
- package/es/common/link-blocker.d.ts +0 -7
- package/es/common/link-blocker.js +0 -18
- package/es/common/overridable-theme-provider.d.ts +0 -18
- package/es/common/overridable-theme-provider.js +0 -15
- package/es/common/wallet-hidden-topbar.d.ts +0 -1
- package/es/common/wallet-hidden-topbar.js +0 -14
- package/es/contexts/config-user-space.d.ts +0 -26
- package/es/contexts/config-user-space.js +0 -53
- package/es/hooks/use-mobile.d.ts +0 -4
- package/es/hooks/use-mobile.js +0 -5
- package/es/index.d.ts +0 -10
- package/es/index.js +0 -10
- package/es/libs/client.d.ts +0 -2
- package/es/libs/client.js +0 -2
- package/es/libs/spaces.d.ts +0 -2
- package/es/libs/spaces.js +0 -13
- package/es/types.d.ts +0 -2
- package/es/types.js +0 -43
- package/es/utils.d.ts +0 -8
- package/es/utils.js +0 -78
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { Box, Chip, Tooltip, Typography } from "@mui/material";
|
|
3
|
-
import Avatar from "@arcblock/ux/lib/Avatar";
|
|
4
|
-
import { useCreation } from "ahooks";
|
|
5
|
-
import { temp as colors } from "@arcblock/ux/lib/Colors";
|
|
6
|
-
export default function UserSessionInfo({ user, sessionUser }) {
|
|
7
|
-
const currentRole = useCreation(() => {
|
|
8
|
-
return (user?.passports || [])?.find((item) => item.name === sessionUser.role);
|
|
9
|
-
}, [user?.passports, sessionUser?.role]);
|
|
10
|
-
return /* @__PURE__ */ jsxs(
|
|
11
|
-
Box,
|
|
12
|
-
{
|
|
13
|
-
sx: {
|
|
14
|
-
display: "flex",
|
|
15
|
-
alignItems: "center",
|
|
16
|
-
gap: 1
|
|
17
|
-
},
|
|
18
|
-
children: [
|
|
19
|
-
/* @__PURE__ */ jsx(
|
|
20
|
-
Avatar,
|
|
21
|
-
{
|
|
22
|
-
size: 40,
|
|
23
|
-
variant: "circle",
|
|
24
|
-
shape: "circle",
|
|
25
|
-
src: sessionUser.avatar,
|
|
26
|
-
did: sessionUser.did,
|
|
27
|
-
sx: { flexShrink: 0 }
|
|
28
|
-
}
|
|
29
|
-
),
|
|
30
|
-
/* @__PURE__ */ jsxs(Box, { sx: { flex: 1, overflow: "hidden" }, children: [
|
|
31
|
-
/* @__PURE__ */ jsxs(
|
|
32
|
-
Box,
|
|
33
|
-
{
|
|
34
|
-
sx: {
|
|
35
|
-
display: "flex",
|
|
36
|
-
alignItems: "center",
|
|
37
|
-
gap: 1
|
|
38
|
-
},
|
|
39
|
-
children: [
|
|
40
|
-
/* @__PURE__ */ jsx(Tooltip, { title: sessionUser.fullName, children: /* @__PURE__ */ jsx(
|
|
41
|
-
Typography,
|
|
42
|
-
{
|
|
43
|
-
sx: {
|
|
44
|
-
whiteSpace: "nowrap",
|
|
45
|
-
overflow: "hidden",
|
|
46
|
-
textOverflow: "ellipsis",
|
|
47
|
-
flex: 1
|
|
48
|
-
},
|
|
49
|
-
children: sessionUser.fullName
|
|
50
|
-
}
|
|
51
|
-
) }),
|
|
52
|
-
/* @__PURE__ */ jsx(
|
|
53
|
-
Chip,
|
|
54
|
-
{
|
|
55
|
-
label: currentRole?.title || currentRole?.name || "Guest",
|
|
56
|
-
size: "small",
|
|
57
|
-
variant: "outlined",
|
|
58
|
-
sx: {
|
|
59
|
-
flexShrink: 0,
|
|
60
|
-
fontWeight: "bold",
|
|
61
|
-
fontSize: "12px",
|
|
62
|
-
color: colors.textBase,
|
|
63
|
-
borderColor: colors.strokeBorderStrong,
|
|
64
|
-
backgroundColor: "transparent",
|
|
65
|
-
textTransform: "capitalize",
|
|
66
|
-
pr: 0.5,
|
|
67
|
-
pl: 0,
|
|
68
|
-
height: "auto"
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
)
|
|
72
|
-
]
|
|
73
|
-
}
|
|
74
|
-
),
|
|
75
|
-
/* @__PURE__ */ jsx(Tooltip, { title: sessionUser.email, children: /* @__PURE__ */ jsx(
|
|
76
|
-
Typography,
|
|
77
|
-
{
|
|
78
|
-
variant: "body2",
|
|
79
|
-
color: "grey",
|
|
80
|
-
sx: {
|
|
81
|
-
whiteSpace: "nowrap",
|
|
82
|
-
overflow: "hidden",
|
|
83
|
-
textOverflow: "ellipsis"
|
|
84
|
-
},
|
|
85
|
-
children: sessionUser.email
|
|
86
|
-
}
|
|
87
|
-
) })
|
|
88
|
-
] })
|
|
89
|
-
]
|
|
90
|
-
}
|
|
91
|
-
);
|
|
92
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
|
-
import { User } from '../../@types';
|
|
3
|
-
export default function UserSessions({ user, showAction, showUser, }: {
|
|
4
|
-
readonly user: User & {
|
|
5
|
-
userSessions?: any[];
|
|
6
|
-
};
|
|
7
|
-
readonly showAction?: boolean;
|
|
8
|
-
readonly showUser?: boolean;
|
|
9
|
-
}): import("react").JSX.Element;
|
|
@@ -1,265 +0,0 @@
|
|
|
1
|
-
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
-
import Datatable from "@arcblock/ux/lib/Datatable";
|
|
3
|
-
import { useCreation, useMemoizedFn, useRequest } from "ahooks";
|
|
4
|
-
import { translate } from "@arcblock/ux/lib/Locale/util";
|
|
5
|
-
import { useLocaleContext } from "@arcblock/ux/lib/Locale/context";
|
|
6
|
-
import RelativeTime from "@arcblock/ux/lib/RelativeTime";
|
|
7
|
-
import sortBy from "lodash/sortBy";
|
|
8
|
-
import UAParser from "ua-parser-js";
|
|
9
|
-
import { getVisitorId } from "@arcblock/ux/lib/Util";
|
|
10
|
-
import { useConfirm } from "@arcblock/ux/lib/Dialog";
|
|
11
|
-
import pAll from "p-all";
|
|
12
|
-
import { Box, Button, Tooltip, Typography } from "@mui/material";
|
|
13
|
-
import UserSessionInfo from "./user-session-info.js";
|
|
14
|
-
import { client } from "../../libs/client.js";
|
|
15
|
-
import { translations } from "../libs/locales.js";
|
|
16
|
-
import { batchIp2Region } from "../libs/utils.js";
|
|
17
|
-
const parseUa = (ua) => {
|
|
18
|
-
const parser = new UAParser(ua, {
|
|
19
|
-
// eslint-disable-next-line no-useless-escape
|
|
20
|
-
browser: [[/(ArcWallet)\/([\w\.]+)/i], [UAParser.BROWSER.NAME, UAParser.BROWSER.VERSION]]
|
|
21
|
-
});
|
|
22
|
-
const result = parser.getResult();
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
export default function UserSessions({
|
|
26
|
-
user,
|
|
27
|
-
showAction = true,
|
|
28
|
-
showUser = true
|
|
29
|
-
}) {
|
|
30
|
-
const currentVisitorId = getVisitorId();
|
|
31
|
-
const { locale } = useLocaleContext();
|
|
32
|
-
const { confirmApi, confirmHolder } = useConfirm();
|
|
33
|
-
const t = useMemoizedFn((key, data = {}) => {
|
|
34
|
-
return translate(translations, key, locale, "en", data);
|
|
35
|
-
});
|
|
36
|
-
const getData = useMemoizedFn(async () => {
|
|
37
|
-
let data = user?.userSessions;
|
|
38
|
-
if (!data) {
|
|
39
|
-
data = await client.userSession.getUserSessions({ did: user.did });
|
|
40
|
-
}
|
|
41
|
-
try {
|
|
42
|
-
const ipIndexList = data?.map((x, index) => [index, x.lastLoginIp]).filter((x) => !!x[1]);
|
|
43
|
-
const ipList = ipIndexList?.map((x) => x[1]);
|
|
44
|
-
const result = await batchIp2Region(ipList);
|
|
45
|
-
for (let index = 0; index < result.length; index++) {
|
|
46
|
-
const x = result[index];
|
|
47
|
-
const ipIndexItem = ipIndexList[index];
|
|
48
|
-
const dataItem = data[ipIndexItem[0]];
|
|
49
|
-
dataItem.ipRegion = x;
|
|
50
|
-
}
|
|
51
|
-
} catch (e) {
|
|
52
|
-
console.warn("Failed to convert ip to region");
|
|
53
|
-
console.error(e);
|
|
54
|
-
}
|
|
55
|
-
const now = (/* @__PURE__ */ new Date()).getTime();
|
|
56
|
-
return sortBy(data, (x) => {
|
|
57
|
-
if (x.visitorId === currentVisitorId) {
|
|
58
|
-
return -1;
|
|
59
|
-
}
|
|
60
|
-
return now - new Date(x.updatedAt).getTime();
|
|
61
|
-
});
|
|
62
|
-
});
|
|
63
|
-
const pageState = useRequest(getData);
|
|
64
|
-
const safeData = useCreation(() => {
|
|
65
|
-
return pageState.data || [];
|
|
66
|
-
}, [pageState.data]);
|
|
67
|
-
const ipRegionMap = useCreation(() => {
|
|
68
|
-
return safeData.reduce((acc, x) => {
|
|
69
|
-
acc[x.lastLoginIp] = x.ipRegion;
|
|
70
|
-
return acc;
|
|
71
|
-
}, {});
|
|
72
|
-
}, [safeData]);
|
|
73
|
-
const logout = useMemoizedFn(({ visitorId }) => {
|
|
74
|
-
confirmApi.open({
|
|
75
|
-
title: t("logoutThisSession"),
|
|
76
|
-
content: t("logoutThisSessionConfirm"),
|
|
77
|
-
confirmButtonText: t("confirm"),
|
|
78
|
-
cancelButtonText: t("cancel"),
|
|
79
|
-
onConfirm: async () => {
|
|
80
|
-
await client.user.logout({ visitorId });
|
|
81
|
-
pageState.refresh();
|
|
82
|
-
confirmApi.close();
|
|
83
|
-
}
|
|
84
|
-
});
|
|
85
|
-
});
|
|
86
|
-
const otherUserSessions = useCreation(() => {
|
|
87
|
-
const list = safeData.filter((x) => x.visitorId !== currentVisitorId);
|
|
88
|
-
return list;
|
|
89
|
-
}, [safeData]);
|
|
90
|
-
const logoutAll = useMemoizedFn(() => {
|
|
91
|
-
confirmApi.open({
|
|
92
|
-
title: t("logoutAllSession"),
|
|
93
|
-
content: t("logoutAllSessionConfirm"),
|
|
94
|
-
confirmButtonText: t("confirm"),
|
|
95
|
-
cancelButtonText: t("cancel"),
|
|
96
|
-
onConfirm: async () => {
|
|
97
|
-
const list = otherUserSessions.map((x) => {
|
|
98
|
-
return () => client.user.logout({ visitorId: x.visitorId });
|
|
99
|
-
});
|
|
100
|
-
await pAll(list, {
|
|
101
|
-
concurrency: 3,
|
|
102
|
-
stopOnError: false
|
|
103
|
-
});
|
|
104
|
-
pageState.refresh();
|
|
105
|
-
confirmApi.close();
|
|
106
|
-
}
|
|
107
|
-
});
|
|
108
|
-
});
|
|
109
|
-
const customButtons = [];
|
|
110
|
-
if (showAction) {
|
|
111
|
-
customButtons.push(
|
|
112
|
-
/* @__PURE__ */ jsx(Tooltip, { title: t("logoutAllTips"), children: /* @__PURE__ */ jsx(
|
|
113
|
-
Button,
|
|
114
|
-
{
|
|
115
|
-
sx: { ml: 0.5 },
|
|
116
|
-
size: "small",
|
|
117
|
-
variant: "contained",
|
|
118
|
-
color: "error",
|
|
119
|
-
onClick: logoutAll,
|
|
120
|
-
disabled: otherUserSessions.length === 0,
|
|
121
|
-
children: t("logoutAll")
|
|
122
|
-
}
|
|
123
|
-
) }, "logoutAll")
|
|
124
|
-
);
|
|
125
|
-
}
|
|
126
|
-
const tableOptions = useCreation(() => {
|
|
127
|
-
return {
|
|
128
|
-
// viewColumns: false,
|
|
129
|
-
search: false,
|
|
130
|
-
sort: false,
|
|
131
|
-
download: false,
|
|
132
|
-
filter: false,
|
|
133
|
-
print: false,
|
|
134
|
-
expandableRowsOnClick: false,
|
|
135
|
-
searchDebounceTime: 600
|
|
136
|
-
};
|
|
137
|
-
}, []);
|
|
138
|
-
const columns = [
|
|
139
|
-
{
|
|
140
|
-
label: t("platform"),
|
|
141
|
-
name: "platform",
|
|
142
|
-
options: {
|
|
143
|
-
customBodyRenderLite: (rawIndex) => {
|
|
144
|
-
const x = safeData[rawIndex];
|
|
145
|
-
const result = parseUa(x.ua);
|
|
146
|
-
return /* @__PURE__ */ jsx(Box, { children: [result.os?.name, result.os?.version].filter(Boolean).join("/") || t("unknown") });
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
},
|
|
150
|
-
{
|
|
151
|
-
label: t("deviceType"),
|
|
152
|
-
name: "deviceType",
|
|
153
|
-
options: {
|
|
154
|
-
customBodyRenderLite: (rawIndex) => {
|
|
155
|
-
const x = safeData[rawIndex];
|
|
156
|
-
const result = parseUa(x.ua);
|
|
157
|
-
return /* @__PURE__ */ jsx(Box, { children: [result.browser?.name, result.browser?.version].filter(Boolean).join("/") || t("unknown") });
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
},
|
|
161
|
-
{
|
|
162
|
-
label: t("walletOS"),
|
|
163
|
-
name: "walletOS",
|
|
164
|
-
options: {
|
|
165
|
-
customBodyRenderLite: (rawIndex) => {
|
|
166
|
-
const x = safeData[rawIndex];
|
|
167
|
-
return /* @__PURE__ */ jsx(Box, { children: x.extra?.walletOS || t("unknown") });
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
},
|
|
171
|
-
showUser && {
|
|
172
|
-
label: t("user"),
|
|
173
|
-
name: "user",
|
|
174
|
-
options: {
|
|
175
|
-
customBodyRenderLite: (rawIndex) => {
|
|
176
|
-
const x = safeData[rawIndex];
|
|
177
|
-
return /* @__PURE__ */ jsx(Box, { sx: { minWidth: 150, maxWidth: 250 }, children: /* @__PURE__ */ jsx(UserSessionInfo, { sessionUser: x.user, user }) });
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
},
|
|
181
|
-
{
|
|
182
|
-
label: t("createdAt"),
|
|
183
|
-
name: "createdAt",
|
|
184
|
-
options: {
|
|
185
|
-
customBodyRenderLite: (rawIndex) => {
|
|
186
|
-
const x = safeData[rawIndex];
|
|
187
|
-
return x.createdAt ? /* @__PURE__ */ jsx(RelativeTime, { value: x.createdAt, relativeRange: 3 * 86400 * 1e3, locale }) : t("unknown");
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
},
|
|
191
|
-
{
|
|
192
|
-
label: t("updatedAt"),
|
|
193
|
-
name: "updatedAt",
|
|
194
|
-
options: {
|
|
195
|
-
customBodyRenderLite: (rawIndex) => {
|
|
196
|
-
const x = safeData[rawIndex];
|
|
197
|
-
return x.status === "expired" ? t("expired") : /* @__PURE__ */ jsx(RelativeTime, { value: x.updatedAt, relativeRange: 3 * 86400 * 1e3, locale });
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
|
-
},
|
|
201
|
-
{
|
|
202
|
-
label: t("lastLoginIp"),
|
|
203
|
-
name: "lastLoginIp",
|
|
204
|
-
options: {
|
|
205
|
-
customBodyRenderLite: (rawIndex) => {
|
|
206
|
-
const x = safeData[rawIndex];
|
|
207
|
-
return /* @__PURE__ */ jsx(Box, { children: ipRegionMap[x.lastLoginIp] ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
208
|
-
/* @__PURE__ */ jsx(Typography, { variant: "body2", children: ipRegionMap[x.lastLoginIp] }),
|
|
209
|
-
/* @__PURE__ */ jsx(Typography, { variant: "body2", color: "grey", children: x.lastLoginIp || t("unknown") })
|
|
210
|
-
] }) : /* @__PURE__ */ jsx(Typography, { children: x.lastLoginIp || t("unknown") }) });
|
|
211
|
-
}
|
|
212
|
-
}
|
|
213
|
-
},
|
|
214
|
-
showAction && {
|
|
215
|
-
label: t("actions"),
|
|
216
|
-
name: "actions",
|
|
217
|
-
options: {
|
|
218
|
-
customBodyRenderLite: (rawIndex) => {
|
|
219
|
-
const x = safeData[rawIndex];
|
|
220
|
-
return /* @__PURE__ */ jsx(Box, { children: /* @__PURE__ */ jsx(
|
|
221
|
-
Button,
|
|
222
|
-
{
|
|
223
|
-
sx: {
|
|
224
|
-
whiteSpace: "nowrap",
|
|
225
|
-
fontSize: "12px",
|
|
226
|
-
px: 1
|
|
227
|
-
},
|
|
228
|
-
disabled: currentVisitorId === x.visitorId,
|
|
229
|
-
variant: "outlined",
|
|
230
|
-
size: "small",
|
|
231
|
-
color: "error",
|
|
232
|
-
onClick: () => logout({ visitorId: x.visitorId }),
|
|
233
|
-
children: x.status === "expired" ? t("remove") : currentVisitorId === x.visitorId ? t("currentSession") : t("logout")
|
|
234
|
-
}
|
|
235
|
-
) });
|
|
236
|
-
}
|
|
237
|
-
}
|
|
238
|
-
}
|
|
239
|
-
].filter(Boolean);
|
|
240
|
-
return /* @__PURE__ */ jsxs(
|
|
241
|
-
Box,
|
|
242
|
-
{
|
|
243
|
-
sx: {
|
|
244
|
-
".MuiTableCell-head": {
|
|
245
|
-
whiteSpace: "nowrap",
|
|
246
|
-
fontWeight: "bold"
|
|
247
|
-
}
|
|
248
|
-
},
|
|
249
|
-
children: [
|
|
250
|
-
confirmHolder,
|
|
251
|
-
/* @__PURE__ */ jsx(
|
|
252
|
-
Datatable,
|
|
253
|
-
{
|
|
254
|
-
locale,
|
|
255
|
-
data: safeData,
|
|
256
|
-
columns,
|
|
257
|
-
customButtons,
|
|
258
|
-
options: tableOptions,
|
|
259
|
-
loading: pageState.loading
|
|
260
|
-
}
|
|
261
|
-
)
|
|
262
|
-
]
|
|
263
|
-
}
|
|
264
|
-
);
|
|
265
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default as UserSessions } from './components/user-sessions';
|
package/es/UserSessions/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default as UserSessions } from "./components/user-sessions.js";
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
export declare const translations: {
|
|
2
|
-
zh: {
|
|
3
|
-
confirm: string;
|
|
4
|
-
cancel: string;
|
|
5
|
-
visitorId: string;
|
|
6
|
-
deviceType: string;
|
|
7
|
-
platform: string;
|
|
8
|
-
walletOS: string;
|
|
9
|
-
role: string;
|
|
10
|
-
fullname: string;
|
|
11
|
-
email: string;
|
|
12
|
-
avatar: string;
|
|
13
|
-
user: string;
|
|
14
|
-
createdAt: string;
|
|
15
|
-
updatedAt: string;
|
|
16
|
-
lastLoginIp: string;
|
|
17
|
-
actions: string;
|
|
18
|
-
logoutAll: string;
|
|
19
|
-
logoutAllTips: string;
|
|
20
|
-
logout: string;
|
|
21
|
-
currentSession: string;
|
|
22
|
-
unknown: string;
|
|
23
|
-
expired: string;
|
|
24
|
-
remove: string;
|
|
25
|
-
logoutThisSession: string;
|
|
26
|
-
logoutThisSessionConfirm: string;
|
|
27
|
-
logoutAllSession: string;
|
|
28
|
-
logoutAllSessionConfirm: string;
|
|
29
|
-
};
|
|
30
|
-
en: {
|
|
31
|
-
confirm: string;
|
|
32
|
-
cancel: string;
|
|
33
|
-
visitorId: string;
|
|
34
|
-
deviceType: string;
|
|
35
|
-
platform: string;
|
|
36
|
-
walletOS: string;
|
|
37
|
-
role: string;
|
|
38
|
-
fullname: string;
|
|
39
|
-
email: string;
|
|
40
|
-
avatar: string;
|
|
41
|
-
user: string;
|
|
42
|
-
createdAt: string;
|
|
43
|
-
updatedAt: string;
|
|
44
|
-
actions: string;
|
|
45
|
-
lastLoginIp: string;
|
|
46
|
-
logoutAll: string;
|
|
47
|
-
logoutAllTips: string;
|
|
48
|
-
logout: string;
|
|
49
|
-
currentSession: string;
|
|
50
|
-
unknown: string;
|
|
51
|
-
expired: string;
|
|
52
|
-
remove: string;
|
|
53
|
-
logoutThisSession: string;
|
|
54
|
-
logoutThisSessionConfirm: string;
|
|
55
|
-
logoutAllSession: string;
|
|
56
|
-
logoutAllSessionConfirm: string;
|
|
57
|
-
};
|
|
58
|
-
};
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
export const translations = {
|
|
2
|
-
zh: {
|
|
3
|
-
confirm: "\u786E\u8BA4",
|
|
4
|
-
cancel: "\u53D6\u6D88",
|
|
5
|
-
visitorId: "\u8BBE\u5907\u6807\u8BC6",
|
|
6
|
-
deviceType: "\u8BBE\u5907\u7C7B\u578B",
|
|
7
|
-
platform: "\u64CD\u4F5C\u7CFB\u7EDF",
|
|
8
|
-
walletOS: "\u94B1\u5305\u7C7B\u578B",
|
|
9
|
-
role: "\u89D2\u8272",
|
|
10
|
-
fullname: "\u59D3\u540D",
|
|
11
|
-
email: "\u90AE\u7BB1",
|
|
12
|
-
avatar: "\u5934\u50CF",
|
|
13
|
-
user: "\u7528\u6237",
|
|
14
|
-
createdAt: "\u9996\u6B21\u6D3B\u52A8\u65F6\u95F4",
|
|
15
|
-
updatedAt: "\u6700\u8FD1\u6D3B\u52A8\u65F6\u95F4",
|
|
16
|
-
lastLoginIp: "\u6700\u8FD1\u6D3B\u52A8\u5730\u5740",
|
|
17
|
-
actions: "\u64CD\u4F5C",
|
|
18
|
-
logoutAll: "\u6CE8\u9500\u6240\u6709\u4F1A\u8BDD",
|
|
19
|
-
logoutAllTips: "\u4E0D\u4F1A\u6CE8\u9500\u5F53\u524D\u4F1A\u8BDD",
|
|
20
|
-
logout: "\u6CE8\u9500",
|
|
21
|
-
currentSession: "\u5F53\u524D\u4F1A\u8BDD",
|
|
22
|
-
unknown: "\u672A\u77E5",
|
|
23
|
-
expired: "\u5DF2\u8FC7\u671F",
|
|
24
|
-
remove: "\u5220\u9664",
|
|
25
|
-
logoutThisSession: "\u6CE8\u9500\u6307\u5B9A\u4F1A\u8BDD",
|
|
26
|
-
logoutThisSessionConfirm: "\u786E\u5B9A\u8981\u6CE8\u9500\u6B64\u4F1A\u8BDD\u5417?",
|
|
27
|
-
logoutAllSession: "\u6CE8\u9500\u6240\u6709\u4F1A\u8BDD",
|
|
28
|
-
logoutAllSessionConfirm: "\u786E\u5B9A\u8981\u6CE8\u9500\u6240\u6709\u4F1A\u8BDD\u5417?"
|
|
29
|
-
},
|
|
30
|
-
en: {
|
|
31
|
-
confirm: "Confirm",
|
|
32
|
-
cancel: "Cancel",
|
|
33
|
-
visitorId: "Device ID",
|
|
34
|
-
deviceType: "Device Type",
|
|
35
|
-
platform: "Platform",
|
|
36
|
-
walletOS: "Wallet OS",
|
|
37
|
-
role: "Role",
|
|
38
|
-
fullname: "Fullname",
|
|
39
|
-
email: "Email",
|
|
40
|
-
avatar: "Avatar",
|
|
41
|
-
user: "User",
|
|
42
|
-
createdAt: "First Active Time",
|
|
43
|
-
updatedAt: "Last Active Time",
|
|
44
|
-
actions: "Actions",
|
|
45
|
-
lastLoginIp: "Last Login IP",
|
|
46
|
-
logoutAll: "Logout all",
|
|
47
|
-
logoutAllTips: "Will not logout current session",
|
|
48
|
-
logout: "Logout",
|
|
49
|
-
currentSession: "Current Session",
|
|
50
|
-
unknown: "Unknown",
|
|
51
|
-
expired: "Expired",
|
|
52
|
-
remove: "Remove",
|
|
53
|
-
logoutThisSession: "Logout this session",
|
|
54
|
-
logoutThisSessionConfirm: "Are you sure to logout this session?",
|
|
55
|
-
logoutAllSession: "Logout all sessions",
|
|
56
|
-
logoutAllSessionConfirm: "Are you sure to logout all sessions?"
|
|
57
|
-
}
|
|
58
|
-
};
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
const RESERVED_IP = "Reserved IP";
|
|
2
|
-
const IP_REGION_CACHE = "ip-region-cache";
|
|
3
|
-
async function getIpRegionFromIpApi(ip) {
|
|
4
|
-
const url = `https://ipapi.co/${ip}/json/`;
|
|
5
|
-
const result = await fetch(url);
|
|
6
|
-
const data = await result.json();
|
|
7
|
-
let region = "";
|
|
8
|
-
if (data.error) {
|
|
9
|
-
if (data.reserved) {
|
|
10
|
-
region = RESERVED_IP;
|
|
11
|
-
}
|
|
12
|
-
} else {
|
|
13
|
-
region = [data.country_name, data.region, data.city].filter(Boolean).join("/");
|
|
14
|
-
}
|
|
15
|
-
return region;
|
|
16
|
-
}
|
|
17
|
-
async function getIpRegionFromIpSb(ip) {
|
|
18
|
-
const url = `https://api.ip.sb/geoip/${ip}`;
|
|
19
|
-
const result = await fetch(url);
|
|
20
|
-
const data = await result.json();
|
|
21
|
-
let region = "";
|
|
22
|
-
if (data.error) {
|
|
23
|
-
if (data.reserved) {
|
|
24
|
-
region = RESERVED_IP;
|
|
25
|
-
}
|
|
26
|
-
} else {
|
|
27
|
-
region = [data.country, data.region, data.city].filter(Boolean).join("/");
|
|
28
|
-
}
|
|
29
|
-
return region;
|
|
30
|
-
}
|
|
31
|
-
export async function ip2Region(ip) {
|
|
32
|
-
let region = "";
|
|
33
|
-
let ipRegionCache = {};
|
|
34
|
-
try {
|
|
35
|
-
const tmpCache = localStorage.getItem(IP_REGION_CACHE);
|
|
36
|
-
if (tmpCache) {
|
|
37
|
-
ipRegionCache = JSON.parse(tmpCache);
|
|
38
|
-
}
|
|
39
|
-
} catch {
|
|
40
|
-
ipRegionCache = {};
|
|
41
|
-
}
|
|
42
|
-
if (ipRegionCache[ip]) {
|
|
43
|
-
region = ipRegionCache[ip];
|
|
44
|
-
} else {
|
|
45
|
-
try {
|
|
46
|
-
region = await getIpRegionFromIpSb(ip);
|
|
47
|
-
} catch {
|
|
48
|
-
console.warn("Fail to get ip region from ip.sb");
|
|
49
|
-
}
|
|
50
|
-
if (!region) {
|
|
51
|
-
try {
|
|
52
|
-
region = await getIpRegionFromIpApi(ip);
|
|
53
|
-
} catch {
|
|
54
|
-
console.warn("Fail to get ip region from ip-api.co");
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
if (region) {
|
|
59
|
-
const ipList = Object.keys(ipRegionCache);
|
|
60
|
-
if (ipList.length > 100) {
|
|
61
|
-
delete ipRegionCache[ipList[0]];
|
|
62
|
-
}
|
|
63
|
-
if (ipRegionCache[ip]) {
|
|
64
|
-
delete ipRegionCache[ip];
|
|
65
|
-
}
|
|
66
|
-
ipRegionCache[ip] = region;
|
|
67
|
-
localStorage.setItem(IP_REGION_CACHE, JSON.stringify(ipRegionCache));
|
|
68
|
-
}
|
|
69
|
-
return region;
|
|
70
|
-
}
|
|
71
|
-
export async function batchIp2Region(ips) {
|
|
72
|
-
return Promise.all(ips.map((ip) => ip2Region(ip)));
|
|
73
|
-
}
|
package/es/blocklets.d.ts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
export const publicPath: any;
|
|
2
|
-
export function formatTheme(theme: any): any;
|
|
3
|
-
export function getLocalizedNavigation(navigation: any, locale?: string): any;
|
|
4
|
-
export function formatNavigation(navigation: any): any;
|
|
5
|
-
export function parseNavigation(navigation: any): {
|
|
6
|
-
header: never[];
|
|
7
|
-
footer: never[];
|
|
8
|
-
social: never[];
|
|
9
|
-
bottom: never[];
|
|
10
|
-
dashboard: never[];
|
|
11
|
-
sessionManager: never[];
|
|
12
|
-
userCenter: never[];
|
|
13
|
-
} | null;
|
|
14
|
-
export function formatBlockletInfo(blockletInfo: any): any;
|
|
15
|
-
export function filterValidNavItems(navigation?: any[]): any;
|
|
16
|
-
export function filterNavByRole(nav: object[], userRole: string): any;
|