@blocklet/ui-react 2.10.74 → 2.10.75
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/third-party-login/third-party-item.js +1 -0
- package/lib/UserCenter/components/user-info/user-basic-info.js +1 -4
- package/lib/UserSessions/components/user-sessions.js +9 -12
- package/package.json +5 -5
- package/src/UserCenter/components/third-party-login/third-party-item.tsx +1 -0
- package/src/UserCenter/components/user-info/user-basic-info.tsx +0 -1
- package/src/UserSessions/components/user-session-info.tsx +0 -1
- package/src/UserSessions/components/user-sessions.tsx +11 -8
- package/lib/UserCenter/libs/api.d.ts +0 -3
- package/lib/UserCenter/libs/api.js +0 -4
- package/src/UserCenter/libs/api.ts +0 -7
|
@@ -147,10 +147,7 @@ export default function UserBasicInfo({
|
|
|
147
147
|
{
|
|
148
148
|
title: !loading && translate(translations, "refreshProfile.title", locale),
|
|
149
149
|
sx: { display: "flex", alignItems: "center" },
|
|
150
|
-
children: loading ? (
|
|
151
|
-
// @ts-expect-error
|
|
152
|
-
/* @__PURE__ */ jsx(CircularProgress, { size: "16px", sx: { color: theme?.colors?.primary, ml: 0.5 } })
|
|
153
|
-
) : /* @__PURE__ */ jsx(RefreshOutlinedIcon, { onClick: refreshProfile })
|
|
150
|
+
children: loading ? /* @__PURE__ */ jsx(CircularProgress, { size: "16px", sx: { color: theme?.colors?.primary, ml: 0.5 } }) : /* @__PURE__ */ jsx(RefreshOutlinedIcon, { onClick: refreshProfile })
|
|
154
151
|
}
|
|
155
152
|
)
|
|
156
153
|
] }) : null
|
|
@@ -10,6 +10,8 @@ import { getVisitorId } from "@arcblock/ux/lib/Util";
|
|
|
10
10
|
import { useConfirm } from "@arcblock/ux/lib/Dialog";
|
|
11
11
|
import pAll from "p-all";
|
|
12
12
|
import { Box, Button, Tooltip, Typography } from "@mui/material";
|
|
13
|
+
import { useContext } from "react";
|
|
14
|
+
import { SessionContext } from "@arcblock/did-connect/lib/Session";
|
|
13
15
|
import UserSessionInfo from "./user-session-info.js";
|
|
14
16
|
import { client } from "../../libs/client.js";
|
|
15
17
|
import { translations } from "../libs/locales.js";
|
|
@@ -27,6 +29,7 @@ export default function UserSessions({
|
|
|
27
29
|
showAction = true,
|
|
28
30
|
showUser = true
|
|
29
31
|
}) {
|
|
32
|
+
const { session } = useContext(SessionContext);
|
|
30
33
|
const currentVisitorId = getVisitorId();
|
|
31
34
|
const { locale } = useLocaleContext();
|
|
32
35
|
const { confirmApi, confirmHolder } = useConfirm();
|
|
@@ -34,11 +37,11 @@ export default function UserSessions({
|
|
|
34
37
|
return translate(translations, key, locale, "en", data);
|
|
35
38
|
});
|
|
36
39
|
const getData = useMemoizedFn(async () => {
|
|
37
|
-
let data = user?.userSessions;
|
|
38
|
-
if (!data) {
|
|
39
|
-
data = await client.userSession.getUserSessions({ did: user.did });
|
|
40
|
-
}
|
|
40
|
+
let data = user?.userSessions || [];
|
|
41
41
|
try {
|
|
42
|
+
if (!data && session.user) {
|
|
43
|
+
data = await client.userSession.getUserSessionsByMyself();
|
|
44
|
+
}
|
|
42
45
|
const ipIndexList = data?.map((x, index) => [index, x.lastLoginIp]).filter((x) => !!x[1]);
|
|
43
46
|
const ipList = ipIndexList?.map((x) => x[1]);
|
|
44
47
|
const result = await batchIp2Region(ipList);
|
|
@@ -187,10 +190,7 @@ export default function UserSessions({
|
|
|
187
190
|
options: {
|
|
188
191
|
customBodyRenderLite: (rawIndex) => {
|
|
189
192
|
const x = safeData[rawIndex];
|
|
190
|
-
return x.createdAt ? (
|
|
191
|
-
// @ts-expect-error
|
|
192
|
-
/* @__PURE__ */ jsx(RelativeTime, { value: x.createdAt, relativeRange: 3 * 86400 * 1e3, locale })
|
|
193
|
-
) : t("unknown");
|
|
193
|
+
return x.createdAt ? /* @__PURE__ */ jsx(RelativeTime, { value: x.createdAt, relativeRange: 3 * 86400 * 1e3, locale }) : t("unknown");
|
|
194
194
|
}
|
|
195
195
|
}
|
|
196
196
|
},
|
|
@@ -200,10 +200,7 @@ export default function UserSessions({
|
|
|
200
200
|
options: {
|
|
201
201
|
customBodyRenderLite: (rawIndex) => {
|
|
202
202
|
const x = safeData[rawIndex];
|
|
203
|
-
return x.status === "expired" ? t("expired") : (
|
|
204
|
-
// @ts-expect-error
|
|
205
|
-
/* @__PURE__ */ jsx(RelativeTime, { value: x.updatedAt, relativeRange: 3 * 86400 * 1e3, locale })
|
|
206
|
-
);
|
|
203
|
+
return x.status === "expired" ? t("expired") : /* @__PURE__ */ jsx(RelativeTime, { value: x.updatedAt, relativeRange: 3 * 86400 * 1e3, locale });
|
|
207
204
|
}
|
|
208
205
|
}
|
|
209
206
|
},
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blocklet/ui-react",
|
|
3
|
-
"version": "2.10.
|
|
3
|
+
"version": "2.10.75",
|
|
4
4
|
"description": "Some useful front-end web components that can be used in Blocklets.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -32,9 +32,9 @@
|
|
|
32
32
|
"url": "https://github.com/ArcBlock/ux/issues"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@arcblock/bridge": "^2.10.
|
|
36
|
-
"@arcblock/react-hooks": "^2.10.
|
|
37
|
-
"@blocklet/did-space-react": "^0.5.
|
|
35
|
+
"@arcblock/bridge": "^2.10.75",
|
|
36
|
+
"@arcblock/react-hooks": "^2.10.75",
|
|
37
|
+
"@blocklet/did-space-react": "^0.5.75",
|
|
38
38
|
"@iconify-icons/logos": "^1.2.36",
|
|
39
39
|
"@iconify-icons/material-symbols": "^1.2.58",
|
|
40
40
|
"@iconify/react": "^4.1.1",
|
|
@@ -80,5 +80,5 @@
|
|
|
80
80
|
"jest": "^29.7.0",
|
|
81
81
|
"unbuild": "^2.0.0"
|
|
82
82
|
},
|
|
83
|
-
"gitHead": "
|
|
83
|
+
"gitHead": "9e8d12bef56d3cd933ef1cb3a7209068de448dbb"
|
|
84
84
|
}
|
|
@@ -157,7 +157,6 @@ export default function UserBasicInfo({
|
|
|
157
157
|
title={!loading && translate(translations, 'refreshProfile.title', locale)}
|
|
158
158
|
sx={{ display: 'flex', alignItems: 'center' }}>
|
|
159
159
|
{loading ? (
|
|
160
|
-
// @ts-expect-error
|
|
161
160
|
<CircularProgress size="16px" sx={{ color: theme?.colors?.primary, ml: 0.5 }} />
|
|
162
161
|
) : (
|
|
163
162
|
<RefreshOutlinedIcon onClick={refreshProfile} />
|
|
@@ -11,11 +11,12 @@ import { getVisitorId } from '@arcblock/ux/lib/Util';
|
|
|
11
11
|
import { useConfirm } from '@arcblock/ux/lib/Dialog';
|
|
12
12
|
import pAll from 'p-all';
|
|
13
13
|
import { Box, Button, Tooltip, Typography } from '@mui/material';
|
|
14
|
-
import { ReactElement } from 'react';
|
|
14
|
+
import { ReactElement, useContext } from 'react';
|
|
15
15
|
import { UserSession } from '@blocklet/js-sdk';
|
|
16
|
+
import { SessionContext } from '@arcblock/did-connect/lib/Session';
|
|
16
17
|
|
|
17
18
|
import UserSessionInfo from './user-session-info';
|
|
18
|
-
import { User } from '../../@types';
|
|
19
|
+
import { User, SessionContext as TSessionContext } from '../../@types';
|
|
19
20
|
import { client } from '../../libs/client';
|
|
20
21
|
import { translations } from '../libs/locales';
|
|
21
22
|
import { batchIp2Region } from '../libs/utils';
|
|
@@ -40,6 +41,7 @@ export default function UserSessions({
|
|
|
40
41
|
readonly showAction?: boolean;
|
|
41
42
|
readonly showUser?: boolean;
|
|
42
43
|
}) {
|
|
44
|
+
const { session } = useContext<TSessionContext>(SessionContext);
|
|
43
45
|
const currentVisitorId = getVisitorId();
|
|
44
46
|
const { locale } = useLocaleContext();
|
|
45
47
|
const { confirmApi, confirmHolder } = useConfirm();
|
|
@@ -47,11 +49,12 @@ export default function UserSessions({
|
|
|
47
49
|
return translate(translations, key, locale, 'en', data);
|
|
48
50
|
});
|
|
49
51
|
const getData: () => Promise<(UserSession & { ipRegion?: string })[]> = useMemoizedFn(async () => {
|
|
50
|
-
let data = user?.userSessions as (UserSession & { ipRegion?: string })[];
|
|
51
|
-
if (!data) {
|
|
52
|
-
data = await client.userSession.getUserSessions({ did: user.did });
|
|
53
|
-
}
|
|
52
|
+
let data = (user?.userSessions || []) as (UserSession & { ipRegion?: string })[];
|
|
54
53
|
try {
|
|
54
|
+
if (!data && session.user) {
|
|
55
|
+
data = await client.userSession.getUserSessionsByMyself();
|
|
56
|
+
}
|
|
57
|
+
// FIXME: @zhanghan 优化获取 IP 信息的处理逻辑
|
|
55
58
|
const ipIndexList = data?.map((x, index) => [index, x.lastLoginIp] as [number, string]).filter((x) => !!x[1]);
|
|
56
59
|
const ipList = ipIndexList?.map((x) => x[1]);
|
|
57
60
|
const result = await batchIp2Region(ipList);
|
|
@@ -209,7 +212,6 @@ export default function UserSessions({
|
|
|
209
212
|
customBodyRenderLite: (rawIndex: number) => {
|
|
210
213
|
const x = safeData[rawIndex];
|
|
211
214
|
return x.createdAt ? (
|
|
212
|
-
// @ts-expect-error
|
|
213
215
|
<RelativeTime value={x.createdAt} relativeRange={3 * 86400 * 1000} locale={locale} />
|
|
214
216
|
) : (
|
|
215
217
|
t('unknown')
|
|
@@ -226,7 +228,6 @@ export default function UserSessions({
|
|
|
226
228
|
return x.status === 'expired' ? (
|
|
227
229
|
t('expired')
|
|
228
230
|
) : (
|
|
229
|
-
// @ts-expect-error
|
|
230
231
|
<RelativeTime value={x.updatedAt} relativeRange={3 * 86400 * 1000} locale={locale} />
|
|
231
232
|
);
|
|
232
233
|
},
|
|
@@ -299,7 +300,9 @@ export default function UserSessions({
|
|
|
299
300
|
<Datatable
|
|
300
301
|
locale={locale}
|
|
301
302
|
data={safeData}
|
|
303
|
+
// @ts-expect-error
|
|
302
304
|
columns={columns}
|
|
305
|
+
// @ts-expect-error
|
|
303
306
|
customButtons={customButtons}
|
|
304
307
|
options={tableOptions}
|
|
305
308
|
loading={pageState.loading}
|