@blocklet/ui-react 2.10.90 → 2.11.1
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 +1 -0
- package/lib/UserCenter/components/config-profile.js +1 -1
- package/lib/UserCenter/components/notification.js +1 -2
- package/lib/UserCenter/components/privacy.d.ts +1 -0
- package/lib/UserCenter/components/privacy.js +3 -0
- package/lib/UserCenter/components/settings.d.ts +1 -1
- package/lib/UserCenter/components/settings.js +20 -18
- package/lib/UserCenter/components/third-party-login/index.js +4 -3
- package/lib/UserCenter/components/user-center.d.ts +1 -1
- package/lib/UserCenter/components/user-center.js +192 -195
- package/lib/UserCenter/components/user-info/index.d.ts +1 -0
- package/lib/UserCenter/components/user-info/index.js +1 -0
- package/lib/UserCenter/components/user-info/switch-role.d.ts +7 -0
- package/lib/UserCenter/components/user-info/switch-role.js +43 -0
- package/lib/UserCenter/components/user-info/user-basic-info.d.ts +1 -2
- package/lib/UserCenter/components/user-info/user-basic-info.js +33 -85
- package/lib/UserCenter/libs/locales.d.ts +4 -0
- package/lib/UserCenter/libs/locales.js +6 -2
- package/lib/common/header-addons.js +8 -0
- package/lib/common/notification-addon.d.ts +13 -0
- package/lib/common/notification-addon.js +41 -0
- package/package.json +5 -5
- package/src/@types/index.ts +1 -0
- package/src/UserCenter/components/config-profile.tsx +3 -1
- package/src/UserCenter/components/notification.tsx +1 -2
- package/src/UserCenter/components/privacy.tsx +4 -0
- package/src/UserCenter/components/settings.tsx +27 -27
- package/src/UserCenter/components/third-party-login/index.tsx +10 -3
- package/src/UserCenter/components/user-center.tsx +195 -180
- package/src/UserCenter/components/user-info/index.tsx +1 -0
- package/src/UserCenter/components/user-info/switch-role.tsx +44 -0
- package/src/UserCenter/components/user-info/user-basic-info.tsx +33 -81
- package/src/UserCenter/libs/locales.ts +4 -0
- package/src/common/header-addons.jsx +10 -0
- package/src/common/notification-addon.jsx +49 -0
|
@@ -38,6 +38,8 @@ export const translations = {
|
|
|
38
38
|
cancel: '取消',
|
|
39
39
|
required: '必填的',
|
|
40
40
|
invalid: '无效',
|
|
41
|
+
setting: '设置',
|
|
42
|
+
profile: '信息',
|
|
41
43
|
},
|
|
42
44
|
toPublic: '公开 “{name}” 页面',
|
|
43
45
|
currentPassport: '当前使用的通行证',
|
|
@@ -131,6 +133,8 @@ export const translations = {
|
|
|
131
133
|
cancel: 'Cancel',
|
|
132
134
|
required: 'Required',
|
|
133
135
|
invalid: 'Invalid',
|
|
136
|
+
setting: 'Settings',
|
|
137
|
+
profile: 'Profile',
|
|
134
138
|
},
|
|
135
139
|
toPublic: 'Public "{name}" page',
|
|
136
140
|
currentPassport: 'Passport currently in use',
|
|
@@ -11,6 +11,12 @@ import LocaleSelector from '@arcblock/ux/lib/Locale/selector';
|
|
|
11
11
|
import { useLocaleContext } from '@arcblock/ux/lib/Locale/context';
|
|
12
12
|
import { SessionManagerProps } from '../types';
|
|
13
13
|
import { getLocalizedNavigation, filterNavByRole } from '../blocklets';
|
|
14
|
+
import NotificationAddon from './notification-addon';
|
|
15
|
+
|
|
16
|
+
const hasNotification = () => {
|
|
17
|
+
const navigations = window?.blocklet?.navigation ?? [];
|
|
18
|
+
return !!navigations.find((n) => n.id === '/userCenter/notification');
|
|
19
|
+
};
|
|
14
20
|
|
|
15
21
|
// eslint-disable-next-line no-shadow
|
|
16
22
|
export default function HeaderAddons({ formattedBlocklet, addons, sessionManagerProps }) {
|
|
@@ -28,6 +34,10 @@ export default function HeaderAddons({ formattedBlocklet, addons, sessionManager
|
|
|
28
34
|
return Array.isArray(addons) ? addons : [addons];
|
|
29
35
|
}
|
|
30
36
|
let addonsArray = [];
|
|
37
|
+
|
|
38
|
+
if (hasNotification()) {
|
|
39
|
+
addonsArray.push(<NotificationAddon key="notification-addon" session={sessionCtx.session} />);
|
|
40
|
+
}
|
|
31
41
|
// 启用了多语言并且检测到了 locale context
|
|
32
42
|
if (enableLocale && locale) {
|
|
33
43
|
addonsArray.push(<LocaleSelector key="locale-selector" showText={false} />);
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import Badge from '@mui/material/Badge';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import { temp as colors } from '@arcblock/ux/lib/Colors';
|
|
4
|
+
import { IconButton } from '@mui/material';
|
|
5
|
+
|
|
6
|
+
// eslint-disable-next-line import/no-extraneous-dependencies
|
|
7
|
+
import NotificationsOutlinedIcon from '@arcblock/icons/lib/Notification';
|
|
8
|
+
import { useCreation } from 'ahooks';
|
|
9
|
+
|
|
10
|
+
export default function NotificationAddon({ session = {} }) {
|
|
11
|
+
const { unReadCount } = session;
|
|
12
|
+
|
|
13
|
+
const viewAllUrl = useCreation(() => {
|
|
14
|
+
const { navigation } = window.blocklet ?? {};
|
|
15
|
+
const notification = navigation?.find((x) => x.id === '/userCenter/notification');
|
|
16
|
+
return notification?.link;
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
if (!session.user || !viewAllUrl) {
|
|
20
|
+
return null;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
return (
|
|
24
|
+
<IconButton
|
|
25
|
+
size="medium"
|
|
26
|
+
variant="outlined"
|
|
27
|
+
href={viewAllUrl}
|
|
28
|
+
sx={{
|
|
29
|
+
borderRadius: 2,
|
|
30
|
+
color: 'rgba(0, 0, 0, 0.6)',
|
|
31
|
+
borderColor: colors.lineBorderStrong,
|
|
32
|
+
'&:hover': {
|
|
33
|
+
borderRadius: '50%',
|
|
34
|
+
},
|
|
35
|
+
}}>
|
|
36
|
+
<Badge variant="dot" color="error" invisible={unReadCount === 0}>
|
|
37
|
+
<NotificationsOutlinedIcon style={{ width: 'auto', height: 24 }} />
|
|
38
|
+
</Badge>
|
|
39
|
+
</IconButton>
|
|
40
|
+
);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
NotificationAddon.propTypes = {
|
|
44
|
+
session: PropTypes.object,
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
NotificationAddon.defaultProps = {
|
|
48
|
+
session: {},
|
|
49
|
+
};
|