@blocklet/ui-react 2.9.35 → 2.9.36
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/es/UserCenter/components/user-basic-info.d.ts +1 -1
- package/es/UserCenter/components/user-basic-info.js +3 -0
- package/es/UserCenter/components/user-center.js +24 -6
- package/es/UserCenter/components/user-info.js +1 -1
- package/es/UserCenter/libs/locales.d.ts +4 -0
- package/es/UserCenter/libs/locales.js +6 -2
- package/lib/UserCenter/components/user-basic-info.d.ts +1 -1
- package/lib/UserCenter/components/user-basic-info.js +3 -0
- package/lib/UserCenter/components/user-center.js +30 -6
- package/lib/UserCenter/components/user-info.js +1 -1
- package/lib/UserCenter/libs/locales.d.ts +4 -0
- package/lib/UserCenter/libs/locales.js +6 -2
- package/package.json +4 -4
- package/src/UserCenter/components/user-basic-info.tsx +4 -0
- package/src/UserCenter/components/user-center.tsx +26 -7
- package/src/UserCenter/components/user-info.tsx +1 -1
- package/src/UserCenter/libs/locales.ts +4 -0
|
@@ -6,6 +6,7 @@ import pWaitFor from "p-wait-for";
|
|
|
6
6
|
import { SessionContext } from "@arcblock/did-connect/lib/Session";
|
|
7
7
|
import Tabs from "@arcblock/ux/lib/Tabs";
|
|
8
8
|
import Empty from "@arcblock/ux/lib/Empty";
|
|
9
|
+
import Button from "@arcblock/ux/lib/Button";
|
|
9
10
|
import { temp as colors } from "@arcblock/ux/lib/Colors";
|
|
10
11
|
import { useConfirm } from "@arcblock/ux/lib/Dialog";
|
|
11
12
|
import { translate } from "@arcblock/ux/lib/Locale/util";
|
|
@@ -61,17 +62,16 @@ export default function UserCenter({
|
|
|
61
62
|
}, [currentDid, session?.user?.did]);
|
|
62
63
|
const userState = useRequest(
|
|
63
64
|
async () => {
|
|
64
|
-
await pWaitFor(() => session
|
|
65
|
+
await pWaitFor(() => session?.initialized);
|
|
65
66
|
if (isMyself) {
|
|
66
67
|
return session.user;
|
|
67
68
|
}
|
|
68
69
|
if (currentDid) {
|
|
69
70
|
return await client.user.getUserPublicInfo({ did: currentDid });
|
|
70
71
|
}
|
|
71
|
-
throw new Error(t("noUserFound"));
|
|
72
72
|
},
|
|
73
73
|
{
|
|
74
|
-
refreshDeps: [currentDid, isMyself]
|
|
74
|
+
refreshDeps: [currentDid, isMyself, session?.initialized]
|
|
75
75
|
}
|
|
76
76
|
);
|
|
77
77
|
const privacyState = useRequest(
|
|
@@ -177,6 +177,24 @@ export default function UserCenter({
|
|
|
177
177
|
};
|
|
178
178
|
return /* @__PURE__ */ jsx(Box, { sx: { width: "100%" }, children: /* @__PURE__ */ jsx(ErrorFallback, { error: formatError }) });
|
|
179
179
|
}
|
|
180
|
+
if (!currentDid && !userState.data) {
|
|
181
|
+
return /* @__PURE__ */ jsx(Box, { sx: { width: "100%" }, children: /* @__PURE__ */ jsxs(
|
|
182
|
+
Box,
|
|
183
|
+
{
|
|
184
|
+
sx: {
|
|
185
|
+
display: "flex",
|
|
186
|
+
flexDirection: "column",
|
|
187
|
+
justifyContent: "center",
|
|
188
|
+
alignItems: "center",
|
|
189
|
+
gap: 1
|
|
190
|
+
},
|
|
191
|
+
children: [
|
|
192
|
+
/* @__PURE__ */ jsx(Empty, { children: t("viewAfterLogin") }),
|
|
193
|
+
/* @__PURE__ */ jsx(Button, { size: "small", variant: "contained", onClick: () => session.login(), children: t("loginNow") })
|
|
194
|
+
]
|
|
195
|
+
}
|
|
196
|
+
) });
|
|
197
|
+
}
|
|
180
198
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
181
199
|
/* @__PURE__ */ jsxs(Box, { sx: { flex: 1, overflow: "hidden" }, children: [
|
|
182
200
|
userState?.data?.fullName ? /* @__PURE__ */ jsx(
|
|
@@ -284,15 +302,15 @@ export default function UserCenter({
|
|
|
284
302
|
md: 400
|
|
285
303
|
},
|
|
286
304
|
maxWidth: "100%",
|
|
287
|
-
display: "flex",
|
|
288
|
-
flexDirection: "column",
|
|
289
|
-
gap: 2.5,
|
|
290
305
|
position: "relative"
|
|
291
306
|
},
|
|
292
307
|
children: /* @__PURE__ */ jsxs(
|
|
293
308
|
Box,
|
|
294
309
|
{
|
|
295
310
|
sx: {
|
|
311
|
+
display: "flex",
|
|
312
|
+
flexDirection: "column",
|
|
313
|
+
gap: 2.5,
|
|
296
314
|
position: {
|
|
297
315
|
xs: "static",
|
|
298
316
|
md: stickySidebar ? "sticky" : "static"
|
|
@@ -25,7 +25,7 @@ export default function UserInfo({
|
|
|
25
25
|
wallet: "DID Wallet",
|
|
26
26
|
auth0: "Auth0"
|
|
27
27
|
};
|
|
28
|
-
return nameMap[user.sourceProvider] || t("unknown");
|
|
28
|
+
return user?.sourceProvider && nameMap[user.sourceProvider] || t("unknown");
|
|
29
29
|
}, [user?.sourceProvider]);
|
|
30
30
|
const userInfoListData = [];
|
|
31
31
|
userInfoListData.push({
|
|
@@ -39,6 +39,8 @@ export declare const translations: {
|
|
|
39
39
|
switchProfile: string;
|
|
40
40
|
userInfo: string;
|
|
41
41
|
myInfo: string;
|
|
42
|
+
loginNow: string;
|
|
43
|
+
viewAfterLogin: string;
|
|
42
44
|
};
|
|
43
45
|
en: {
|
|
44
46
|
settings: string;
|
|
@@ -80,5 +82,7 @@ export declare const translations: {
|
|
|
80
82
|
switchProfile: string;
|
|
81
83
|
userInfo: string;
|
|
82
84
|
myInfo: string;
|
|
85
|
+
loginNow: string;
|
|
86
|
+
viewAfterLogin: string;
|
|
83
87
|
};
|
|
84
88
|
};
|
|
@@ -38,7 +38,9 @@ export const translations = {
|
|
|
38
38
|
currentPassport: "\u5F53\u524D\u4F7F\u7528\u7684\u901A\u884C\u8BC1",
|
|
39
39
|
switchProfile: "\u5207\u6362",
|
|
40
40
|
userInfo: "\u4E2A\u4EBA\u4FE1\u606F",
|
|
41
|
-
myInfo: "\u6211\u7684\u4FE1\u606F"
|
|
41
|
+
myInfo: "\u6211\u7684\u4FE1\u606F",
|
|
42
|
+
loginNow: "\u7ACB\u5373\u767B\u5F55",
|
|
43
|
+
viewAfterLogin: "\u767B\u5F55\u540E\u624D\u53EF\u4EE5\u67E5\u770B"
|
|
42
44
|
},
|
|
43
45
|
en: {
|
|
44
46
|
settings: "Settings",
|
|
@@ -79,6 +81,8 @@ export const translations = {
|
|
|
79
81
|
currentPassport: "Passport currently in use",
|
|
80
82
|
switchProfile: "Switch",
|
|
81
83
|
userInfo: "User Info",
|
|
82
|
-
myInfo: "My Info"
|
|
84
|
+
myInfo: "My Info",
|
|
85
|
+
loginNow: "Login",
|
|
86
|
+
viewAfterLogin: "View after login"
|
|
83
87
|
}
|
|
84
88
|
};
|
|
@@ -37,6 +37,9 @@ function UserBasicInfo({
|
|
|
37
37
|
const currentRole = (0, _ahooks.useCreation)(() => (user?.passports || [])?.find(item => item.name === user.role), [user?.passports, user?.role]);
|
|
38
38
|
const theme = (0, _Theme.useTheme)();
|
|
39
39
|
const isSmallView = theme.breakpoints.down("md");
|
|
40
|
+
if (!user) {
|
|
41
|
+
return null;
|
|
42
|
+
}
|
|
40
43
|
return /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Box, {
|
|
41
44
|
...rest,
|
|
42
45
|
sx: {
|
|
@@ -12,6 +12,7 @@ var _pWaitFor = _interopRequireDefault(require("p-wait-for"));
|
|
|
12
12
|
var _Session = require("@arcblock/did-connect/lib/Session");
|
|
13
13
|
var _Tabs = _interopRequireDefault(require("@arcblock/ux/lib/Tabs"));
|
|
14
14
|
var _Empty = _interopRequireDefault(require("@arcblock/ux/lib/Empty"));
|
|
15
|
+
var _Button = _interopRequireDefault(require("@arcblock/ux/lib/Button"));
|
|
15
16
|
var _Colors = require("@arcblock/ux/lib/Colors");
|
|
16
17
|
var _Dialog = require("@arcblock/ux/lib/Dialog");
|
|
17
18
|
var _util = require("@arcblock/ux/lib/Locale/util");
|
|
@@ -69,7 +70,7 @@ function UserCenter({
|
|
|
69
70
|
return false;
|
|
70
71
|
}, [currentDid, session?.user?.did]);
|
|
71
72
|
const userState = (0, _ahooks.useRequest)(async () => {
|
|
72
|
-
await (0, _pWaitFor.default)(() => session
|
|
73
|
+
await (0, _pWaitFor.default)(() => session?.initialized);
|
|
73
74
|
if (isMyself) {
|
|
74
75
|
return session.user;
|
|
75
76
|
}
|
|
@@ -78,9 +79,8 @@ function UserCenter({
|
|
|
78
79
|
did: currentDid
|
|
79
80
|
});
|
|
80
81
|
}
|
|
81
|
-
throw new Error(t("noUserFound"));
|
|
82
82
|
}, {
|
|
83
|
-
refreshDeps: [currentDid, isMyself]
|
|
83
|
+
refreshDeps: [currentDid, isMyself, session?.initialized]
|
|
84
84
|
});
|
|
85
85
|
const privacyState = (0, _ahooks.useRequest)(async () => {
|
|
86
86
|
if (userState.data && currentTab) {
|
|
@@ -191,6 +191,30 @@ function UserCenter({
|
|
|
191
191
|
})
|
|
192
192
|
});
|
|
193
193
|
}
|
|
194
|
+
if (!currentDid && !userState.data) {
|
|
195
|
+
return /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Box, {
|
|
196
|
+
sx: {
|
|
197
|
+
width: "100%"
|
|
198
|
+
},
|
|
199
|
+
children: /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Box, {
|
|
200
|
+
sx: {
|
|
201
|
+
display: "flex",
|
|
202
|
+
flexDirection: "column",
|
|
203
|
+
justifyContent: "center",
|
|
204
|
+
alignItems: "center",
|
|
205
|
+
gap: 1
|
|
206
|
+
},
|
|
207
|
+
children: [/* @__PURE__ */(0, _jsxRuntime.jsx)(_Empty.default, {
|
|
208
|
+
children: t("viewAfterLogin")
|
|
209
|
+
}), /* @__PURE__ */(0, _jsxRuntime.jsx)(_Button.default, {
|
|
210
|
+
size: "small",
|
|
211
|
+
variant: "contained",
|
|
212
|
+
onClick: () => session.login(),
|
|
213
|
+
children: t("loginNow")
|
|
214
|
+
})]
|
|
215
|
+
})
|
|
216
|
+
});
|
|
217
|
+
}
|
|
194
218
|
return /* @__PURE__ */(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
195
219
|
children: [/* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Box, {
|
|
196
220
|
sx: {
|
|
@@ -290,13 +314,13 @@ function UserCenter({
|
|
|
290
314
|
md: 400
|
|
291
315
|
},
|
|
292
316
|
maxWidth: "100%",
|
|
293
|
-
display: "flex",
|
|
294
|
-
flexDirection: "column",
|
|
295
|
-
gap: 2.5,
|
|
296
317
|
position: "relative"
|
|
297
318
|
},
|
|
298
319
|
children: /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Box, {
|
|
299
320
|
sx: {
|
|
321
|
+
display: "flex",
|
|
322
|
+
flexDirection: "column",
|
|
323
|
+
gap: 2.5,
|
|
300
324
|
position: {
|
|
301
325
|
xs: "static",
|
|
302
326
|
md: stickySidebar ? "sticky" : "static"
|
|
@@ -34,7 +34,7 @@ function UserInfo({
|
|
|
34
34
|
wallet: "DID Wallet",
|
|
35
35
|
auth0: "Auth0"
|
|
36
36
|
};
|
|
37
|
-
return nameMap[user.sourceProvider] || t("unknown");
|
|
37
|
+
return user?.sourceProvider && nameMap[user.sourceProvider] || t("unknown");
|
|
38
38
|
}, [user?.sourceProvider]);
|
|
39
39
|
const userInfoListData = [];
|
|
40
40
|
userInfoListData.push({
|
|
@@ -39,6 +39,8 @@ export declare const translations: {
|
|
|
39
39
|
switchProfile: string;
|
|
40
40
|
userInfo: string;
|
|
41
41
|
myInfo: string;
|
|
42
|
+
loginNow: string;
|
|
43
|
+
viewAfterLogin: string;
|
|
42
44
|
};
|
|
43
45
|
en: {
|
|
44
46
|
settings: string;
|
|
@@ -80,5 +82,7 @@ export declare const translations: {
|
|
|
80
82
|
switchProfile: string;
|
|
81
83
|
userInfo: string;
|
|
82
84
|
myInfo: string;
|
|
85
|
+
loginNow: string;
|
|
86
|
+
viewAfterLogin: string;
|
|
83
87
|
};
|
|
84
88
|
};
|
|
@@ -44,7 +44,9 @@ const translations = exports.translations = {
|
|
|
44
44
|
currentPassport: "\u5F53\u524D\u4F7F\u7528\u7684\u901A\u884C\u8BC1",
|
|
45
45
|
switchProfile: "\u5207\u6362",
|
|
46
46
|
userInfo: "\u4E2A\u4EBA\u4FE1\u606F",
|
|
47
|
-
myInfo: "\u6211\u7684\u4FE1\u606F"
|
|
47
|
+
myInfo: "\u6211\u7684\u4FE1\u606F",
|
|
48
|
+
loginNow: "\u7ACB\u5373\u767B\u5F55",
|
|
49
|
+
viewAfterLogin: "\u767B\u5F55\u540E\u624D\u53EF\u4EE5\u67E5\u770B"
|
|
48
50
|
},
|
|
49
51
|
en: {
|
|
50
52
|
settings: "Settings",
|
|
@@ -85,6 +87,8 @@ const translations = exports.translations = {
|
|
|
85
87
|
currentPassport: "Passport currently in use",
|
|
86
88
|
switchProfile: "Switch",
|
|
87
89
|
userInfo: "User Info",
|
|
88
|
-
myInfo: "My Info"
|
|
90
|
+
myInfo: "My Info",
|
|
91
|
+
loginNow: "Login",
|
|
92
|
+
viewAfterLogin: "View after login"
|
|
89
93
|
}
|
|
90
94
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blocklet/ui-react",
|
|
3
|
-
"version": "2.9.
|
|
3
|
+
"version": "2.9.36",
|
|
4
4
|
"description": "Some useful front-end web components that can be used in Blocklets.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -63,8 +63,8 @@
|
|
|
63
63
|
},
|
|
64
64
|
"dependencies": {
|
|
65
65
|
"@abtnode/constant": "1.16.23",
|
|
66
|
-
"@arcblock/did-connect": "^2.9.
|
|
67
|
-
"@arcblock/ux": "^2.9.
|
|
66
|
+
"@arcblock/did-connect": "^2.9.36",
|
|
67
|
+
"@arcblock/ux": "^2.9.36",
|
|
68
68
|
"@blocklet/js-sdk": "1.16.23",
|
|
69
69
|
"@emotion/react": "^11.10.4",
|
|
70
70
|
"@emotion/styled": "^11.10.4",
|
|
@@ -100,5 +100,5 @@
|
|
|
100
100
|
"jest": "^28.1.3",
|
|
101
101
|
"unbuild": "^2.0.0"
|
|
102
102
|
},
|
|
103
|
-
"gitHead": "
|
|
103
|
+
"gitHead": "6074556a8d968c427c3a4e47d8e26deaa4639251"
|
|
104
104
|
}
|
|
@@ -7,6 +7,7 @@ import pWaitFor from 'p-wait-for';
|
|
|
7
7
|
import { SessionContext } from '@arcblock/did-connect/lib/Session';
|
|
8
8
|
import Tabs from '@arcblock/ux/lib/Tabs';
|
|
9
9
|
import Empty from '@arcblock/ux/lib/Empty';
|
|
10
|
+
import Button from '@arcblock/ux/lib/Button';
|
|
10
11
|
import { temp as colors } from '@arcblock/ux/lib/Colors';
|
|
11
12
|
import { useConfirm } from '@arcblock/ux/lib/Dialog';
|
|
12
13
|
import { translate } from '@arcblock/ux/lib/Locale/util';
|
|
@@ -82,18 +83,16 @@ export default function UserCenter({
|
|
|
82
83
|
|
|
83
84
|
const userState = useRequest(
|
|
84
85
|
async () => {
|
|
85
|
-
await pWaitFor(() => session
|
|
86
|
+
await pWaitFor(() => session?.initialized);
|
|
86
87
|
if (isMyself) {
|
|
87
88
|
return session.user;
|
|
88
89
|
}
|
|
89
90
|
if (currentDid) {
|
|
90
91
|
return await client.user.getUserPublicInfo({ did: currentDid });
|
|
91
92
|
}
|
|
92
|
-
|
|
93
|
-
throw new Error(t('noUserFound'));
|
|
94
93
|
},
|
|
95
94
|
{
|
|
96
|
-
refreshDeps: [currentDid, isMyself],
|
|
95
|
+
refreshDeps: [currentDid, isMyself, session?.initialized],
|
|
97
96
|
}
|
|
98
97
|
);
|
|
99
98
|
|
|
@@ -217,6 +216,26 @@ export default function UserCenter({
|
|
|
217
216
|
);
|
|
218
217
|
}
|
|
219
218
|
|
|
219
|
+
if (!currentDid && !userState.data) {
|
|
220
|
+
return (
|
|
221
|
+
<Box sx={{ width: '100%' }}>
|
|
222
|
+
<Box
|
|
223
|
+
sx={{
|
|
224
|
+
display: 'flex',
|
|
225
|
+
flexDirection: 'column',
|
|
226
|
+
justifyContent: 'center',
|
|
227
|
+
alignItems: 'center',
|
|
228
|
+
gap: 1,
|
|
229
|
+
}}>
|
|
230
|
+
<Empty>{t('viewAfterLogin')}</Empty>
|
|
231
|
+
<Button size="small" variant="contained" onClick={() => session.login()}>
|
|
232
|
+
{t('loginNow')}
|
|
233
|
+
</Button>
|
|
234
|
+
</Box>
|
|
235
|
+
</Box>
|
|
236
|
+
);
|
|
237
|
+
}
|
|
238
|
+
|
|
220
239
|
return (
|
|
221
240
|
<>
|
|
222
241
|
<Box sx={{ flex: 1, overflow: 'hidden' }}>
|
|
@@ -318,13 +337,13 @@ export default function UserCenter({
|
|
|
318
337
|
md: 400,
|
|
319
338
|
},
|
|
320
339
|
maxWidth: '100%',
|
|
321
|
-
display: 'flex',
|
|
322
|
-
flexDirection: 'column',
|
|
323
|
-
gap: 2.5,
|
|
324
340
|
position: 'relative',
|
|
325
341
|
}}>
|
|
326
342
|
<Box
|
|
327
343
|
sx={{
|
|
344
|
+
display: 'flex',
|
|
345
|
+
flexDirection: 'column',
|
|
346
|
+
gap: 2.5,
|
|
328
347
|
position: {
|
|
329
348
|
xs: 'static',
|
|
330
349
|
md: stickySidebar ? 'sticky' : 'static',
|
|
@@ -31,7 +31,7 @@ export default function UserInfo({
|
|
|
31
31
|
wallet: 'DID Wallet',
|
|
32
32
|
auth0: 'Auth0',
|
|
33
33
|
};
|
|
34
|
-
return nameMap[user.sourceProvider as keyof typeof nameMap] || t('unknown');
|
|
34
|
+
return (user?.sourceProvider && nameMap[user.sourceProvider as keyof typeof nameMap]) || t('unknown');
|
|
35
35
|
}, [user?.sourceProvider]);
|
|
36
36
|
|
|
37
37
|
const userInfoListData = [];
|
|
@@ -39,6 +39,8 @@ export const translations = {
|
|
|
39
39
|
switchProfile: '切换',
|
|
40
40
|
userInfo: '个人信息',
|
|
41
41
|
myInfo: '我的信息',
|
|
42
|
+
loginNow: '立即登录',
|
|
43
|
+
viewAfterLogin: '登录后才可以查看',
|
|
42
44
|
},
|
|
43
45
|
en: {
|
|
44
46
|
settings: 'Settings',
|
|
@@ -80,5 +82,7 @@ export const translations = {
|
|
|
80
82
|
switchProfile: 'Switch',
|
|
81
83
|
userInfo: 'User Info',
|
|
82
84
|
myInfo: 'My Info',
|
|
85
|
+
loginNow: 'Login',
|
|
86
|
+
viewAfterLogin: 'View after login',
|
|
83
87
|
},
|
|
84
88
|
};
|