module-menu 0.1.26 → 0.1.27
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/package.json +1 -1
- package/src/assets.zip +0 -0
- package/src/pages/ModuleUser/index.jsx +120 -76
package/package.json
CHANGED
package/src/assets.zip
ADDED
|
Binary file
|
|
@@ -1,85 +1,129 @@
|
|
|
1
1
|
import React, { Component } from 'react';
|
|
2
2
|
import { Popconfirm, message, Dropdown } from 'antd';
|
|
3
|
-
import { userMenuIcon } from './constData'
|
|
4
|
-
import {
|
|
3
|
+
import { userMenuIcon } from './constData';
|
|
4
|
+
import {
|
|
5
|
+
HomeOutlined,
|
|
6
|
+
UserOutlined,
|
|
7
|
+
CaretDownOutlined,
|
|
8
|
+
} from '@ant-design/icons';
|
|
5
9
|
import { Spin, Menu, Avatar } from 'antd';
|
|
6
|
-
import HeaderDropdown from './HeaderDropdown'
|
|
10
|
+
import HeaderDropdown from './HeaderDropdown';
|
|
7
11
|
import Axios from '../util/axios';
|
|
8
|
-
import './index.less'
|
|
12
|
+
import './index.less';
|
|
9
13
|
const ModuleUser = () => {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
const handleClickmenu = (url) => {
|
|
15
|
+
window.location.href = url;
|
|
16
|
+
};
|
|
17
|
+
const { PersonalCenterSrc, MessageCenterSrc, SystemManageSrc, LogoutSrc } =
|
|
18
|
+
userMenuIcon;
|
|
19
|
+
const isHaveSystemManagementPermission = sessionStorage.getItem(
|
|
20
|
+
'bigdata-isHaveSystemManagementPermission',
|
|
21
|
+
);
|
|
22
|
+
const DEFAULT_LOGOUT_URL = '/#/login';
|
|
16
23
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
24
|
+
const getUserName = () => {
|
|
25
|
+
const userInfo = JSON.parse(
|
|
26
|
+
sessionStorage.getItem('bigdata-userInfo') || '{}',
|
|
27
|
+
);
|
|
28
|
+
if (
|
|
29
|
+
userInfo &&
|
|
30
|
+
userInfo.content &&
|
|
31
|
+
Object.keys(userInfo.content).length > 0 &&
|
|
32
|
+
userInfo.content.username
|
|
33
|
+
) {
|
|
34
|
+
return userInfo.content.username;
|
|
35
|
+
}
|
|
36
|
+
return '';
|
|
23
37
|
};
|
|
24
38
|
// 退出登录
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
<
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
}
|
|
39
|
+
const logout = () => {
|
|
40
|
+
Axios('delete', '/auth/token/logout', '', {})
|
|
41
|
+
.then(() => {
|
|
42
|
+
console.log('退出登录接口调用成功');
|
|
43
|
+
// localStorage.clear();
|
|
44
|
+
// sessionStorage.clear();
|
|
45
|
+
window.location.href = DEFAULT_LOGOUT_URL;
|
|
46
|
+
})
|
|
47
|
+
.catch((error) => {
|
|
48
|
+
console.error('Error while logging out, error:', error);
|
|
49
|
+
message.error('服务器错误,请稍后重试');
|
|
50
|
+
});
|
|
51
|
+
};
|
|
52
|
+
const menu = (
|
|
53
|
+
<Menu className="menu" selectedKeys={[]}>
|
|
54
|
+
<Menu.Item
|
|
55
|
+
key="personalCenter"
|
|
56
|
+
onClick={() => handleClickmenu('/#/info/index')}
|
|
57
|
+
>
|
|
58
|
+
<img
|
|
59
|
+
src={PersonalCenterSrc}
|
|
60
|
+
alt=""
|
|
61
|
+
style={{ marginRight: '10px', marginTop: '-3px' }}
|
|
62
|
+
/>
|
|
63
|
+
<span>个人中心</span>
|
|
64
|
+
</Menu.Item>
|
|
65
|
+
<Menu.Item key="messageCenter" onClick={() => handleClickmenu('/alert/')}>
|
|
66
|
+
<img
|
|
67
|
+
src={MessageCenterSrc}
|
|
68
|
+
alt=""
|
|
69
|
+
style={{ marginRight: '10px', marginTop: '-3px' }}
|
|
70
|
+
/>
|
|
71
|
+
<span>消息中心</span>
|
|
72
|
+
</Menu.Item>
|
|
73
|
+
{isHaveSystemManagementPermission && (
|
|
74
|
+
<Menu.Item key="systemManage" onClick={() => handleClickmenu('/')}>
|
|
75
|
+
<img
|
|
76
|
+
src={SystemManageSrc}
|
|
77
|
+
alt=""
|
|
78
|
+
style={{ marginRight: '10px', marginTop: '-3px' }}
|
|
79
|
+
/>
|
|
80
|
+
<span>系统管理</span>
|
|
81
|
+
</Menu.Item>
|
|
82
|
+
)}
|
|
83
|
+
<Menu.Item key="logout" onClick={() => logout()}>
|
|
84
|
+
<img
|
|
85
|
+
src={LogoutSrc}
|
|
86
|
+
alt=""
|
|
87
|
+
style={{ width: '15px', height: '15px', marginRight: '10px' }}
|
|
88
|
+
/>
|
|
89
|
+
<span>退出登录</span>
|
|
90
|
+
</Menu.Item>
|
|
91
|
+
</Menu>
|
|
92
|
+
);
|
|
93
|
+
return (
|
|
94
|
+
<div className="right">
|
|
95
|
+
{getUserName() ? (
|
|
96
|
+
<HeaderDropdown overlay={menu}>
|
|
97
|
+
<span style={{ display: 'inline-block', marginLeft: '12px' }}>
|
|
98
|
+
<Avatar size="small" icon={<UserOutlined />} />
|
|
99
|
+
<span
|
|
100
|
+
style={{
|
|
101
|
+
marginLeft: '10px',
|
|
102
|
+
verticalAlign: '-2px',
|
|
103
|
+
fontSize: '16px',
|
|
104
|
+
fontWeight: '500',
|
|
105
|
+
}}
|
|
106
|
+
>
|
|
107
|
+
{getUserName()}
|
|
108
|
+
</span>
|
|
109
|
+
<CaretDownOutlined
|
|
110
|
+
style={{ marginLeft: '10px', fontSize: '8px', color: '#333333' }}
|
|
111
|
+
/>
|
|
112
|
+
</span>
|
|
113
|
+
</HeaderDropdown>
|
|
114
|
+
) : (
|
|
115
|
+
<Spin
|
|
116
|
+
size="small"
|
|
117
|
+
style={{
|
|
118
|
+
marginLeft: 8,
|
|
119
|
+
marginRight: 8,
|
|
120
|
+
lineHeight: '57px',
|
|
121
|
+
textAlign: 'center',
|
|
122
|
+
}}
|
|
123
|
+
/>
|
|
124
|
+
)}
|
|
125
|
+
</div>
|
|
126
|
+
);
|
|
127
|
+
};
|
|
84
128
|
|
|
85
|
-
export default ModuleUser
|
|
129
|
+
export default ModuleUser;
|