@blocklet/ui-react 2.11.31 → 2.11.33
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/storage/connected.js +1 -0
- package/lib/UserCenter/components/user-center.d.ts +2 -1
- package/lib/UserCenter/components/user-center.js +148 -126
- package/package.json +5 -5
- package/src/UserCenter/components/storage/connected.tsx +1 -0
- package/src/UserCenter/components/user-center.tsx +110 -65
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { BoxProps } from '@mui/material';
|
|
2
|
-
export default function UserCenter({ children, notLoginContent, currentTab, contentProps, disableAutoRedirect, hideFooter, headerProps, footerProps, userDid, stickySidebar, }: {
|
|
2
|
+
export default function UserCenter({ children, notLoginContent, currentTab, contentProps, disableAutoRedirect, hideFooter, headerProps, footerProps, userDid, stickySidebar, embed, }: {
|
|
3
3
|
readonly children: any;
|
|
4
4
|
readonly notLoginContent: any;
|
|
5
5
|
readonly currentTab: string;
|
|
@@ -11,4 +11,5 @@ export default function UserCenter({ children, notLoginContent, currentTab, cont
|
|
|
11
11
|
readonly footerProps?: any;
|
|
12
12
|
readonly userDid?: string;
|
|
13
13
|
readonly stickySidebar?: boolean;
|
|
14
|
+
readonly embed?: boolean;
|
|
14
15
|
}): import("react").JSX.Element | null;
|
|
@@ -13,6 +13,7 @@ import { useConfirm } from "@arcblock/ux/lib/Dialog";
|
|
|
13
13
|
import { translate } from "@arcblock/ux/lib/Locale/util";
|
|
14
14
|
import { useLocaleContext } from "@arcblock/ux/lib/Locale/context";
|
|
15
15
|
import { ErrorFallback } from "@arcblock/ux/lib/ErrorBoundary";
|
|
16
|
+
import { styled } from "@arcblock/ux/lib/Theme";
|
|
16
17
|
import cloneDeep from "lodash/cloneDeep";
|
|
17
18
|
import { getQuery, withQuery, joinURL, withoutTrailingSlash } from "ufo";
|
|
18
19
|
import { PROFILE_URL } from "@arcblock/ux/lib/Util/constant";
|
|
@@ -30,6 +31,27 @@ import DidSpace from "./storage/index.js";
|
|
|
30
31
|
const profileLink = joinURL(PROFILE_URL, "/profile");
|
|
31
32
|
const settingsLink = joinURL(PROFILE_URL, "/settings");
|
|
32
33
|
const didSpacesLink = joinURL(PROFILE_URL, "/did-spaces");
|
|
34
|
+
const Main = styled(Box)(({ theme }) => ({
|
|
35
|
+
flex: 1,
|
|
36
|
+
width: "100%",
|
|
37
|
+
maxWidth: 1200,
|
|
38
|
+
margin: "0 auto",
|
|
39
|
+
p: 3,
|
|
40
|
+
display: "flex",
|
|
41
|
+
alignItems: "stretch",
|
|
42
|
+
gap: 2.5,
|
|
43
|
+
flexDirection: "column",
|
|
44
|
+
[theme.breakpoints.up("md")]: {
|
|
45
|
+
flexDirection: "row"
|
|
46
|
+
}
|
|
47
|
+
}));
|
|
48
|
+
const ContentWrapper = styled(Box)(({ theme }) => ({
|
|
49
|
+
overflow: "hidden",
|
|
50
|
+
flex: "revert",
|
|
51
|
+
[theme.breakpoints.up("md")]: {
|
|
52
|
+
flex: 1
|
|
53
|
+
}
|
|
54
|
+
}));
|
|
33
55
|
export default function UserCenter({
|
|
34
56
|
children,
|
|
35
57
|
notLoginContent = null,
|
|
@@ -40,7 +62,8 @@ export default function UserCenter({
|
|
|
40
62
|
headerProps = {},
|
|
41
63
|
footerProps = {},
|
|
42
64
|
userDid = void 0,
|
|
43
|
-
stickySidebar = false
|
|
65
|
+
stickySidebar = false,
|
|
66
|
+
embed = false
|
|
44
67
|
}) {
|
|
45
68
|
const { locale } = useLocaleContext();
|
|
46
69
|
const isMobile = useMobile({ key: "md" });
|
|
@@ -279,6 +302,47 @@ export default function UserCenter({
|
|
|
279
302
|
}
|
|
280
303
|
return null;
|
|
281
304
|
}, [isSettingTab, isProfileTab, userState, isMyself, stickySidebar, settingContent]);
|
|
305
|
+
const emptyContent = useCreation(() => {
|
|
306
|
+
return /* @__PURE__ */ jsx(
|
|
307
|
+
Box,
|
|
308
|
+
{
|
|
309
|
+
sx: {
|
|
310
|
+
display: {
|
|
311
|
+
xs: isMyself ? "none" : "block",
|
|
312
|
+
md: "block"
|
|
313
|
+
},
|
|
314
|
+
py: 3
|
|
315
|
+
},
|
|
316
|
+
children: /* @__PURE__ */ jsx(Empty, { children: t("emptyContent") })
|
|
317
|
+
}
|
|
318
|
+
);
|
|
319
|
+
}, [isMyself, locale]);
|
|
320
|
+
const tabContent = useCreation(() => {
|
|
321
|
+
if (!privacyState.data || privacyState.loading) {
|
|
322
|
+
return /* @__PURE__ */ jsx(
|
|
323
|
+
Box,
|
|
324
|
+
{
|
|
325
|
+
sx: {
|
|
326
|
+
height: "100%",
|
|
327
|
+
minWidth: "160px",
|
|
328
|
+
minHeight: "160px",
|
|
329
|
+
display: "flex",
|
|
330
|
+
justifyContent: "center",
|
|
331
|
+
alignItems: "center",
|
|
332
|
+
flex: 1
|
|
333
|
+
},
|
|
334
|
+
children: /* @__PURE__ */ jsx(CircularProgress, { sx: { color: colors.primary100 } })
|
|
335
|
+
}
|
|
336
|
+
);
|
|
337
|
+
}
|
|
338
|
+
return (
|
|
339
|
+
// eslint-disable-next-line react/jsx-no-useless-fragment
|
|
340
|
+
/* @__PURE__ */ jsx(Box, { sx: { flex: 1 }, children: currentActiveTab?.protected && !isMyself ? /* @__PURE__ */ jsx(Box, { children: /* @__PURE__ */ jsx(Empty, { children: t("underProtected") }) }) : (
|
|
341
|
+
// eslint-disable-next-line react/jsx-no-useless-fragment
|
|
342
|
+
/* @__PURE__ */ jsx(Fragment, { children: children ? /* @__PURE__ */ jsx(Box, { ...contentProps, children }) : /* @__PURE__ */ jsx(Fragment, { children: renderDefaultTab }) })
|
|
343
|
+
) })
|
|
344
|
+
);
|
|
345
|
+
}, [privacyState, currentActiveTab, isMyself, children, contentProps, renderDefaultTab, locale]);
|
|
282
346
|
const content = useCreation(() => {
|
|
283
347
|
if (userState.loading || session.loading) {
|
|
284
348
|
return null;
|
|
@@ -315,113 +379,84 @@ export default function UserCenter({
|
|
|
315
379
|
}
|
|
316
380
|
) });
|
|
317
381
|
}
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
382
|
+
if (embed) {
|
|
383
|
+
return /* @__PURE__ */ jsxs(ContentWrapper, { children: [
|
|
384
|
+
userCenterTabs.length > 0 && currentTab ? /* @__PURE__ */ jsx(
|
|
385
|
+
Box,
|
|
322
386
|
{
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
387
|
+
sx: {
|
|
388
|
+
display: isMobile ? "block" : "flex",
|
|
389
|
+
height: "100%",
|
|
390
|
+
overflow: "auto",
|
|
391
|
+
padding: "1px"
|
|
326
392
|
},
|
|
327
|
-
|
|
393
|
+
children: tabContent
|
|
328
394
|
}
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
textAlign: "left",
|
|
377
|
-
alignItems: "flex-start",
|
|
378
|
-
justifyContent: "flex-start"
|
|
379
|
-
}
|
|
380
|
-
}
|
|
381
|
-
}
|
|
382
|
-
}
|
|
383
|
-
),
|
|
384
|
-
/* @__PURE__ */ jsx(Divider, { orientation: "vertical", sx: { height: "100%", mr: 3, borderColor: colors.dividerColor } }),
|
|
385
|
-
!privacyState.data || privacyState.loading ? /* @__PURE__ */ jsx(
|
|
386
|
-
Box,
|
|
387
|
-
{
|
|
388
|
-
sx: {
|
|
389
|
-
height: "100%",
|
|
390
|
-
minWidth: "160px",
|
|
391
|
-
minHeight: "160px",
|
|
392
|
-
display: "flex",
|
|
393
|
-
justifyContent: "center",
|
|
394
|
-
alignItems: "center",
|
|
395
|
-
flex: 1
|
|
395
|
+
) : null,
|
|
396
|
+
userCenterTabs.length === 0 && emptyContent
|
|
397
|
+
] });
|
|
398
|
+
}
|
|
399
|
+
return /* @__PURE__ */ jsxs(ContentWrapper, { children: [
|
|
400
|
+
/* @__PURE__ */ jsx(
|
|
401
|
+
UserBasicInfo,
|
|
402
|
+
{
|
|
403
|
+
isMyself,
|
|
404
|
+
switchPassport: handleSwitchPassport,
|
|
405
|
+
switchProfile: session.switchProfile,
|
|
406
|
+
user: userState.data,
|
|
407
|
+
showFullDid: false,
|
|
408
|
+
sx: {
|
|
409
|
+
display: "flex",
|
|
410
|
+
gap: 3,
|
|
411
|
+
mt: 2
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
),
|
|
415
|
+
/* @__PURE__ */ jsx(Divider, { sx: { mt: 3, mb: 3, borderColor: colors.dividerColor } }),
|
|
416
|
+
userCenterTabs.length > 0 && currentTab ? /* @__PURE__ */ jsxs(
|
|
417
|
+
Box,
|
|
418
|
+
{
|
|
419
|
+
display: isMobile ? "block" : "flex",
|
|
420
|
+
sx: {
|
|
421
|
+
height: "100%",
|
|
422
|
+
overflow: "auto",
|
|
423
|
+
padding: "1px"
|
|
424
|
+
},
|
|
425
|
+
children: [
|
|
426
|
+
/* @__PURE__ */ jsx(
|
|
427
|
+
Tabs,
|
|
428
|
+
{
|
|
429
|
+
orientation: isMobile ? "horizontal" : "vertical",
|
|
430
|
+
variant: "line",
|
|
431
|
+
tabs: userCenterTabs,
|
|
432
|
+
current: currentActiveTab?.value ?? currentTab,
|
|
433
|
+
onChange: handleChangeTab,
|
|
434
|
+
sx: {
|
|
435
|
+
width: isMobile ? "100%" : 160,
|
|
436
|
+
marginBottom: isMobile ? "8px" : 0,
|
|
437
|
+
flexShrink: 0,
|
|
438
|
+
".MuiTabs-flexContainer": {
|
|
439
|
+
gap: 1.5,
|
|
440
|
+
".MuiButtonBase-root": {
|
|
441
|
+
fontSize: 16
|
|
396
442
|
},
|
|
397
|
-
|
|
443
|
+
".MuiTab-root": {
|
|
444
|
+
display: "block",
|
|
445
|
+
textAlign: "left",
|
|
446
|
+
alignItems: "flex-start",
|
|
447
|
+
justifyContent: "flex-start"
|
|
448
|
+
}
|
|
398
449
|
}
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
userCenterTabs.length === 0 ? /* @__PURE__ */ jsx(
|
|
410
|
-
Box,
|
|
411
|
-
{
|
|
412
|
-
sx: {
|
|
413
|
-
display: {
|
|
414
|
-
xs: isMyself ? "none" : "block",
|
|
415
|
-
md: "block"
|
|
416
|
-
},
|
|
417
|
-
py: 3
|
|
418
|
-
},
|
|
419
|
-
children: /* @__PURE__ */ jsx(Empty, { children: t("emptyContent") })
|
|
420
|
-
}
|
|
421
|
-
) : null
|
|
422
|
-
]
|
|
423
|
-
}
|
|
424
|
-
);
|
|
450
|
+
}
|
|
451
|
+
}
|
|
452
|
+
),
|
|
453
|
+
/* @__PURE__ */ jsx(Divider, { orientation: "vertical", sx: { height: "100%", mr: 3, borderColor: colors.dividerColor } }),
|
|
454
|
+
tabContent
|
|
455
|
+
]
|
|
456
|
+
}
|
|
457
|
+
) : null,
|
|
458
|
+
userCenterTabs.length === 0 && emptyContent
|
|
459
|
+
] });
|
|
425
460
|
}, [
|
|
426
461
|
userState,
|
|
427
462
|
userCenterTabs,
|
|
@@ -450,6 +485,12 @@ export default function UserCenter({
|
|
|
450
485
|
}
|
|
451
486
|
return null;
|
|
452
487
|
}
|
|
488
|
+
if (embed) {
|
|
489
|
+
return /* @__PURE__ */ jsxs(Main, { children: [
|
|
490
|
+
content,
|
|
491
|
+
confirmHolder
|
|
492
|
+
] });
|
|
493
|
+
}
|
|
453
494
|
return /* @__PURE__ */ jsxs(
|
|
454
495
|
Box,
|
|
455
496
|
{
|
|
@@ -460,29 +501,10 @@ export default function UserCenter({
|
|
|
460
501
|
},
|
|
461
502
|
children: [
|
|
462
503
|
/* @__PURE__ */ jsx(Header, { bordered: true, ...headerProps, maxWidth: "100%" }),
|
|
463
|
-
/* @__PURE__ */ jsxs(
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
sx: {
|
|
468
|
-
width: "100%",
|
|
469
|
-
maxWidth: 1200,
|
|
470
|
-
margin: "0 auto",
|
|
471
|
-
p: 3,
|
|
472
|
-
display: "flex",
|
|
473
|
-
alignItems: "stretch",
|
|
474
|
-
flexDirection: {
|
|
475
|
-
xs: "column",
|
|
476
|
-
md: "row"
|
|
477
|
-
},
|
|
478
|
-
gap: 2.5
|
|
479
|
-
},
|
|
480
|
-
children: [
|
|
481
|
-
content,
|
|
482
|
-
confirmHolder
|
|
483
|
-
]
|
|
484
|
-
}
|
|
485
|
-
),
|
|
504
|
+
/* @__PURE__ */ jsxs(Main, { children: [
|
|
505
|
+
content,
|
|
506
|
+
confirmHolder
|
|
507
|
+
] }),
|
|
486
508
|
hideFooter ? null : /* @__PURE__ */ jsx(Footer, { bordered: true, ...footerProps })
|
|
487
509
|
]
|
|
488
510
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blocklet/ui-react",
|
|
3
|
-
"version": "2.11.
|
|
3
|
+
"version": "2.11.33",
|
|
4
4
|
"description": "Some useful front-end web components that can be used in Blocklets.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -33,10 +33,10 @@
|
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
35
|
"@abtnode/constant": "^1.16.38",
|
|
36
|
-
"@arcblock/bridge": "^2.11.
|
|
37
|
-
"@arcblock/react-hooks": "^2.11.
|
|
36
|
+
"@arcblock/bridge": "^2.11.33",
|
|
37
|
+
"@arcblock/react-hooks": "^2.11.33",
|
|
38
38
|
"@arcblock/ws": "^1.19.9",
|
|
39
|
-
"@blocklet/did-space-react": "^1.0.
|
|
39
|
+
"@blocklet/did-space-react": "^1.0.11",
|
|
40
40
|
"@iconify-icons/logos": "^1.2.36",
|
|
41
41
|
"@iconify-icons/material-symbols": "^1.2.58",
|
|
42
42
|
"@iconify/react": "^4.1.1",
|
|
@@ -84,5 +84,5 @@
|
|
|
84
84
|
"jest": "^29.7.0",
|
|
85
85
|
"unbuild": "^2.0.0"
|
|
86
86
|
},
|
|
87
|
-
"gitHead": "
|
|
87
|
+
"gitHead": "96db26b284912b24165e233da62fb5e50091bf41"
|
|
88
88
|
}
|
|
@@ -28,6 +28,7 @@ function Connected({ spaceGateway }: { spaceGateway: SpaceGateway | undefined })
|
|
|
28
28
|
endpoint={spaceGateway.endpoint}
|
|
29
29
|
deps={[spaceGateway]}
|
|
30
30
|
selected
|
|
31
|
+
footer
|
|
31
32
|
// eslint-disable-next-line react/no-unstable-nested-components
|
|
32
33
|
action={(props) => <Action session={session} {...props} />}
|
|
33
34
|
/>
|
|
@@ -14,6 +14,7 @@ import { useConfirm } from '@arcblock/ux/lib/Dialog';
|
|
|
14
14
|
import { translate } from '@arcblock/ux/lib/Locale/util';
|
|
15
15
|
import { useLocaleContext } from '@arcblock/ux/lib/Locale/context';
|
|
16
16
|
import { ErrorFallback } from '@arcblock/ux/lib/ErrorBoundary';
|
|
17
|
+
import { styled } from '@arcblock/ux/lib/Theme';
|
|
17
18
|
import cloneDeep from 'lodash/cloneDeep';
|
|
18
19
|
import { getQuery, withQuery, joinURL, withoutTrailingSlash } from 'ufo';
|
|
19
20
|
import type { AxiosError } from 'axios';
|
|
@@ -38,6 +39,29 @@ const profileLink = joinURL(PROFILE_URL, '/profile');
|
|
|
38
39
|
const settingsLink = joinURL(PROFILE_URL, '/settings');
|
|
39
40
|
const didSpacesLink = joinURL(PROFILE_URL, '/did-spaces');
|
|
40
41
|
|
|
42
|
+
const Main = styled(Box)(({ theme }) => ({
|
|
43
|
+
flex: 1,
|
|
44
|
+
width: '100%',
|
|
45
|
+
maxWidth: 1200,
|
|
46
|
+
margin: '0 auto',
|
|
47
|
+
p: 3,
|
|
48
|
+
display: 'flex',
|
|
49
|
+
alignItems: 'stretch',
|
|
50
|
+
gap: 2.5,
|
|
51
|
+
flexDirection: 'column',
|
|
52
|
+
[theme.breakpoints.up('md')]: {
|
|
53
|
+
flexDirection: 'row',
|
|
54
|
+
},
|
|
55
|
+
}));
|
|
56
|
+
|
|
57
|
+
const ContentWrapper = styled(Box)(({ theme }) => ({
|
|
58
|
+
overflow: 'hidden',
|
|
59
|
+
flex: 'revert',
|
|
60
|
+
[theme.breakpoints.up('md')]: {
|
|
61
|
+
flex: 1,
|
|
62
|
+
},
|
|
63
|
+
}));
|
|
64
|
+
|
|
41
65
|
export default function UserCenter({
|
|
42
66
|
children,
|
|
43
67
|
notLoginContent = null,
|
|
@@ -49,6 +73,7 @@ export default function UserCenter({
|
|
|
49
73
|
footerProps = {},
|
|
50
74
|
userDid = undefined,
|
|
51
75
|
stickySidebar = false,
|
|
76
|
+
embed = false,
|
|
52
77
|
}: {
|
|
53
78
|
readonly children: any;
|
|
54
79
|
readonly notLoginContent: any;
|
|
@@ -62,6 +87,7 @@ export default function UserCenter({
|
|
|
62
87
|
readonly footerProps?: any;
|
|
63
88
|
readonly userDid?: string;
|
|
64
89
|
readonly stickySidebar?: boolean;
|
|
90
|
+
readonly embed?: boolean;
|
|
65
91
|
}) {
|
|
66
92
|
const { locale } = useLocaleContext();
|
|
67
93
|
const isMobile = useMobile({ key: 'md' });
|
|
@@ -316,6 +342,54 @@ export default function UserCenter({
|
|
|
316
342
|
return null;
|
|
317
343
|
}, [isSettingTab, isProfileTab, userState, isMyself, stickySidebar, settingContent]);
|
|
318
344
|
|
|
345
|
+
const emptyContent = useCreation(() => {
|
|
346
|
+
return (
|
|
347
|
+
<Box
|
|
348
|
+
sx={{
|
|
349
|
+
display: {
|
|
350
|
+
xs: isMyself ? 'none' : 'block',
|
|
351
|
+
md: 'block',
|
|
352
|
+
},
|
|
353
|
+
py: 3,
|
|
354
|
+
}}>
|
|
355
|
+
<Empty>{t('emptyContent')}</Empty>
|
|
356
|
+
</Box>
|
|
357
|
+
);
|
|
358
|
+
}, [isMyself, locale]);
|
|
359
|
+
|
|
360
|
+
const tabContent = useCreation(() => {
|
|
361
|
+
if (!privacyState.data || privacyState.loading) {
|
|
362
|
+
return (
|
|
363
|
+
<Box
|
|
364
|
+
sx={{
|
|
365
|
+
height: '100%',
|
|
366
|
+
minWidth: '160px',
|
|
367
|
+
minHeight: '160px',
|
|
368
|
+
display: 'flex',
|
|
369
|
+
justifyContent: 'center',
|
|
370
|
+
alignItems: 'center',
|
|
371
|
+
flex: 1,
|
|
372
|
+
}}>
|
|
373
|
+
<CircularProgress sx={{ color: colors.primary100 }} />
|
|
374
|
+
</Box>
|
|
375
|
+
);
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
return (
|
|
379
|
+
// eslint-disable-next-line react/jsx-no-useless-fragment
|
|
380
|
+
<Box sx={{ flex: 1 }}>
|
|
381
|
+
{currentActiveTab?.protected && !isMyself ? (
|
|
382
|
+
<Box>
|
|
383
|
+
<Empty>{t('underProtected')}</Empty>
|
|
384
|
+
</Box>
|
|
385
|
+
) : (
|
|
386
|
+
// eslint-disable-next-line react/jsx-no-useless-fragment
|
|
387
|
+
<>{children ? <Box {...contentProps}>{children}</Box> : <>{renderDefaultTab}</>}</>
|
|
388
|
+
)}
|
|
389
|
+
</Box>
|
|
390
|
+
);
|
|
391
|
+
}, [privacyState, currentActiveTab, isMyself, children, contentProps, renderDefaultTab, locale]);
|
|
392
|
+
|
|
319
393
|
const content = useCreation(() => {
|
|
320
394
|
if (userState.loading || session.loading) {
|
|
321
395
|
return null;
|
|
@@ -368,17 +442,28 @@ export default function UserCenter({
|
|
|
368
442
|
);
|
|
369
443
|
}
|
|
370
444
|
|
|
445
|
+
// 嵌入时,只显示 tabContent
|
|
446
|
+
if (embed) {
|
|
447
|
+
return (
|
|
448
|
+
<ContentWrapper>
|
|
449
|
+
{userCenterTabs.length > 0 && currentTab ? (
|
|
450
|
+
<Box
|
|
451
|
+
sx={{
|
|
452
|
+
display: isMobile ? 'block' : 'flex',
|
|
453
|
+
height: '100%',
|
|
454
|
+
overflow: 'auto',
|
|
455
|
+
padding: '1px',
|
|
456
|
+
}}>
|
|
457
|
+
{tabContent}
|
|
458
|
+
</Box>
|
|
459
|
+
) : null}
|
|
460
|
+
{userCenterTabs.length === 0 && emptyContent}
|
|
461
|
+
</ContentWrapper>
|
|
462
|
+
);
|
|
463
|
+
}
|
|
464
|
+
|
|
371
465
|
return (
|
|
372
|
-
<
|
|
373
|
-
sx={[
|
|
374
|
-
{
|
|
375
|
-
flex: {
|
|
376
|
-
xs: 'revert',
|
|
377
|
-
md: 1,
|
|
378
|
-
},
|
|
379
|
-
overflow: 'hidden',
|
|
380
|
-
},
|
|
381
|
-
]}>
|
|
466
|
+
<ContentWrapper>
|
|
382
467
|
<UserBasicInfo
|
|
383
468
|
isMyself={isMyself}
|
|
384
469
|
switchPassport={handleSwitchPassport}
|
|
@@ -425,47 +510,11 @@ export default function UserCenter({
|
|
|
425
510
|
}}
|
|
426
511
|
/>
|
|
427
512
|
<Divider orientation="vertical" sx={{ height: '100%', mr: 3, borderColor: colors.dividerColor }} />
|
|
428
|
-
{
|
|
429
|
-
<Box
|
|
430
|
-
sx={{
|
|
431
|
-
height: '100%',
|
|
432
|
-
minWidth: '160px',
|
|
433
|
-
minHeight: '160px',
|
|
434
|
-
display: 'flex',
|
|
435
|
-
justifyContent: 'center',
|
|
436
|
-
alignItems: 'center',
|
|
437
|
-
flex: 1,
|
|
438
|
-
}}>
|
|
439
|
-
<CircularProgress sx={{ color: colors.primary100 }} />
|
|
440
|
-
</Box>
|
|
441
|
-
) : (
|
|
442
|
-
// eslint-disable-next-line react/jsx-no-useless-fragment
|
|
443
|
-
<Box sx={{ flex: 1 }}>
|
|
444
|
-
{currentActiveTab?.protected && !isMyself ? (
|
|
445
|
-
<Box>
|
|
446
|
-
<Empty>{t('underProtected')}</Empty>
|
|
447
|
-
</Box>
|
|
448
|
-
) : (
|
|
449
|
-
// eslint-disable-next-line react/jsx-no-useless-fragment
|
|
450
|
-
<>{children ? <Box {...contentProps}>{children}</Box> : <>{renderDefaultTab}</>}</>
|
|
451
|
-
)}
|
|
452
|
-
</Box>
|
|
453
|
-
)}
|
|
513
|
+
{tabContent}
|
|
454
514
|
</Box>
|
|
455
515
|
) : null}
|
|
456
|
-
{userCenterTabs.length === 0
|
|
457
|
-
|
|
458
|
-
sx={{
|
|
459
|
-
display: {
|
|
460
|
-
xs: isMyself ? 'none' : 'block',
|
|
461
|
-
md: 'block',
|
|
462
|
-
},
|
|
463
|
-
py: 3,
|
|
464
|
-
}}>
|
|
465
|
-
<Empty>{t('emptyContent')}</Empty>
|
|
466
|
-
</Box>
|
|
467
|
-
) : null}
|
|
468
|
-
</Box>
|
|
516
|
+
{userCenterTabs.length === 0 && emptyContent}
|
|
517
|
+
</ContentWrapper>
|
|
469
518
|
);
|
|
470
519
|
}, [
|
|
471
520
|
userState,
|
|
@@ -500,6 +549,16 @@ export default function UserCenter({
|
|
|
500
549
|
return null;
|
|
501
550
|
}
|
|
502
551
|
|
|
552
|
+
// 嵌入其它页面内时,只展示 content
|
|
553
|
+
if (embed) {
|
|
554
|
+
return (
|
|
555
|
+
<Main>
|
|
556
|
+
{content}
|
|
557
|
+
{confirmHolder}
|
|
558
|
+
</Main>
|
|
559
|
+
);
|
|
560
|
+
}
|
|
561
|
+
|
|
503
562
|
return (
|
|
504
563
|
<Box
|
|
505
564
|
sx={{
|
|
@@ -508,24 +567,10 @@ export default function UserCenter({
|
|
|
508
567
|
flexDirection: 'column',
|
|
509
568
|
}}>
|
|
510
569
|
<Header bordered {...headerProps} maxWidth="100%" />
|
|
511
|
-
<
|
|
512
|
-
flex={1}
|
|
513
|
-
sx={{
|
|
514
|
-
width: '100%',
|
|
515
|
-
maxWidth: 1200,
|
|
516
|
-
margin: '0 auto',
|
|
517
|
-
p: 3,
|
|
518
|
-
display: 'flex',
|
|
519
|
-
alignItems: 'stretch',
|
|
520
|
-
flexDirection: {
|
|
521
|
-
xs: 'column',
|
|
522
|
-
md: 'row',
|
|
523
|
-
},
|
|
524
|
-
gap: 2.5,
|
|
525
|
-
}}>
|
|
570
|
+
<Main>
|
|
526
571
|
{content}
|
|
527
572
|
{confirmHolder}
|
|
528
|
-
</
|
|
573
|
+
</Main>
|
|
529
574
|
{hideFooter ? null : <Footer bordered {...footerProps} />}
|
|
530
575
|
</Box>
|
|
531
576
|
);
|