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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "module-menu",
3
- "version": "0.1.26",
3
+ "version": "0.1.27",
4
4
  "description": "城市大数据平台公共头部及尾部",
5
5
  "main": "src/pages/index.jsx",
6
6
  "scripts": {
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 { HomeOutlined, UserOutlined, CaretDownOutlined} from '@ant-design/icons';
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
- const handleClickmenu = (url)=>{
11
- window.location.href = url;
12
- }
13
- const {PersonalCenterSrc,MessageCenterSrc,SystemManageSrc,LogoutSrc} = userMenuIcon;
14
- const isHaveSystemManagementPermission = sessionStorage.getItem('bigdata-isHaveSystemManagementPermission');
15
- const DEFAULT_LOGOUT_URL = "/#/login"
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
- const getUserName = () => {
18
- const userInfo = JSON.parse(sessionStorage.getItem('bigdata-userInfo')||"{}");
19
- if (userInfo && userInfo.content && Object.keys(userInfo.content).length > 0 && userInfo.content.username) {
20
- return userInfo.content.username;
21
- }
22
- return '';
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
- const logout = () => {
26
- Axios('delete','/auth/token/logout', '', {} )
27
- .then(() => {
28
- console.log('退出登录接口调用成功')
29
- // localStorage.clear();
30
- // sessionStorage.clear();
31
- window.location.href = DEFAULT_LOGOUT_URL;
32
- })
33
- .catch((error) => {
34
- console.error('Error while logging out, error:', error);
35
- message.error('服务器错误,请稍后重试');
36
- });
37
- }
38
- const menu = (
39
- <Menu className="menu" selectedKeys={[]} >
40
- <Menu.Item key="personalCenter" onClick={()=>handleClickmenu('/#/info/index')}>
41
- <img src={PersonalCenterSrc} alt="" style={{ marginRight: '10px', marginTop: '-3px' }} />
42
- <span>个人中心</span>
43
- </Menu.Item>
44
- <Menu.Item key="messageCenter" onClick={()=>handleClickmenu('/#/alert/')}>
45
- <img src={MessageCenterSrc} alt="" style={{ marginRight: '10px', marginTop: '-3px' }} />
46
- <span>消息中心</span>
47
- </Menu.Item>
48
- {isHaveSystemManagementPermission &&
49
- <Menu.Item key="systemManage" onClick={()=>handleClickmenu('/')}>
50
- <img src={SystemManageSrc} alt="" style={{ marginRight: '10px', marginTop: '-3px' }} />
51
- <span>系统管理</span>
52
- </Menu.Item>}
53
- <Menu.Item key="logout" onClick={()=>logout()}>
54
- <img src={LogoutSrc} alt="" style={{ width: '15px', height: '15px', marginRight: '10px' }} />
55
- <span>退出登录</span>
56
- </Menu.Item>
57
- </Menu>
58
- );
59
- return (
60
- <div className="right">
61
- {getUserName() ? (
62
- <HeaderDropdown overlay={menu}>
63
- <span style={{ display: 'inline-block', marginLeft: '12px' }}>
64
- <Avatar size="small" icon={<UserOutlined />} />
65
- <span
66
- style={{
67
- marginLeft: '10px',
68
- verticalAlign: '-2px',
69
- fontSize: '16px',
70
- fontWeight: '500',
71
- }}
72
- >
73
- {getUserName()}
74
- </span>
75
- <CaretDownOutlined style={{marginLeft: '10px', fontSize:'8px',color:'#333333'}}/>
76
- </span>
77
- </HeaderDropdown>
78
- ) : (
79
- <Spin size="small" style={{ marginLeft: 8, marginRight: 8, lineHeight: '57px', textAlign: 'center' }} />
80
- )}
81
- </div>
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;