module-menu 0.1.23 → 0.1.26
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 +3 -2
- package/src/.umi/.cache/babel-loader/03b98dfd43ede9cd0c5d7dc711a0fb56.json.gz +0 -0
- package/src/.umi/.cache/babel-loader/06f59440d6bedb68f24310d60d2b6504.json.gz +0 -0
- package/src/.umi/.cache/babel-loader/0baa5e2ab67778d3566fc30b3066389d.json.gz +0 -0
- package/src/.umi/.cache/babel-loader/128aa5adccc8863930c7650ac429aa00.json.gz +0 -0
- package/src/.umi/.cache/babel-loader/13f028645d8086993d6b8e01ec8086a0.json.gz +0 -0
- package/src/.umi/.cache/babel-loader/147e09f8c51829bd943f13db5e9471ce.json.gz +0 -0
- package/src/.umi/.cache/babel-loader/1d11158dadb83adaae99ccda4b4d1c9c.json.gz +0 -0
- package/src/.umi/.cache/babel-loader/1d77034a1a6c55f06f6f79299d14ef9e.json.gz +0 -0
- package/src/.umi/.cache/babel-loader/1e6343c95192fd8a5499e16a393833ed.json.gz +0 -0
- package/src/.umi/.cache/babel-loader/1f82e74f358347cd7e45d2605719ec47.json.gz +0 -0
- package/src/.umi/.cache/babel-loader/2337c2bb0d1322b5b9efda1122f0ec8b.json.gz +0 -0
- package/src/.umi/.cache/babel-loader/2cc651004a39d7f07a08c051b23593b9.json.gz +0 -0
- package/src/.umi/.cache/babel-loader/392042e4ac71a01698ba1d39f991d0d1.json.gz +0 -0
- package/src/.umi/.cache/babel-loader/51bdbb86cfc89f42b1e4d23ae663b116.json.gz +0 -0
- package/src/.umi/.cache/babel-loader/524399b5907d79571c25ddbf82c72d76.json.gz +0 -0
- package/src/.umi/.cache/babel-loader/5b5b15670673b14da779c72ff08171b0.json.gz +0 -0
- package/src/.umi/.cache/babel-loader/625ff86c841576fb776aa565b2b86384.json.gz +0 -0
- package/src/.umi/.cache/babel-loader/6ec97028f7f0dbf5d2c6bb5a95085da7.json.gz +0 -0
- package/src/.umi/.cache/babel-loader/722d44882a733901dc8faf8adf707048.json.gz +0 -0
- package/src/.umi/.cache/babel-loader/74b8901e905b61d9ba05856042a6dcaa.json.gz +0 -0
- package/src/.umi/.cache/babel-loader/7c778514d12dc443466fa8cb65a3d9fb.json.gz +0 -0
- package/src/.umi/.cache/babel-loader/80564750cb5fe7e934d0913b57b45c69.json.gz +0 -0
- package/src/.umi/.cache/babel-loader/8e0e0787a6635d23580aabba3deae6c6.json.gz +0 -0
- package/src/.umi/.cache/babel-loader/93ccbcd6d515781672001ce69add922d.json.gz +0 -0
- package/src/.umi/.cache/babel-loader/9800f4c48147118fc91c30ce1cebf0ef.json.gz +0 -0
- package/src/.umi/.cache/babel-loader/9ecc19eb4eebf8bef3a43ffc0430b414.json.gz +0 -0
- package/src/.umi/.cache/babel-loader/b105d7a299b6aaf0182fdc5beeb5f69f.json.gz +0 -0
- package/src/.umi/.cache/babel-loader/bcd7bbc28460d4045d5ec8d3c8062ee0.json.gz +0 -0
- package/src/.umi/.cache/babel-loader/c2e89db94faf3bf3d42fadea590621c5.json.gz +0 -0
- package/src/.umi/.cache/babel-loader/c8bd94b75f77db522fb6c398ef34662d.json.gz +0 -0
- package/src/.umi/.cache/babel-loader/cc41f767e8b2397ab81373b7b31d5121.json.gz +0 -0
- package/src/.umi/.cache/babel-loader/d1b9b99091fcb8cebe0ff4a64227086d.json.gz +0 -0
- package/src/.umi/.cache/babel-loader/d37760a083b6a62d9c4cb03c1787773b.json.gz +0 -0
- package/src/.umi/.cache/babel-loader/d3eec01eab85c6ccf3c40d503cb826cb.json.gz +0 -0
- package/src/.umi/.cache/babel-loader/d63e70a818fac501ae68b881b8780832.json.gz +0 -0
- package/src/.umi/.cache/babel-loader/dcf382ea08d8f23655fbcc826224a8ab.json.gz +0 -0
- package/src/.umi/.cache/babel-loader/de2644421de86d458b251f6c3c59bb0e.json.gz +0 -0
- package/src/.umi/.cache/babel-loader/de86231130575e30ffe880704acb19d1.json.gz +0 -0
- package/src/.umi/.cache/babel-loader/ed01b116c5b663979c5590186c505128.json.gz +0 -0
- package/src/.umi/.cache/babel-loader/f088a7033f4d02ce70993c05181fa429.json.gz +0 -0
- package/src/.umi/.cache/babel-loader/f57634317b67618da14290fc4bf254b6.json.gz +0 -0
- package/src/.umi/.cache/babel-loader/f73fb623ed4968dc40e2646c585c6815.json.gz +0 -0
- package/src/.umi/.cache/babel-loader/f9d931cea477056032040d7888d9e156.json.gz +0 -0
- package/src/.umi/.cache/babel-loader/fba14e8a4345ee45432af20b1f3e6d59.json.gz +0 -0
- package/src/pages/ModuleMenu/constData.jsx +1 -1
- package/src/pages/ModuleMenu/index.jsx +4 -3
- package/src/pages/ModuleUser/index.jsx +5 -4
- package/src/pages/ModuleUser/index.less +1 -18
- package/src/pages/util/axios.js +133 -0
- package/src/pages/util/config.js +10 -0
- package/src/pages/util/permessionUtils.js +33 -0
- package/src/pages/util/userInfo.js +50 -0
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "module-menu",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.26",
|
|
4
4
|
"description": "城市大数据平台公共头部及尾部",
|
|
5
|
-
"main":"src/pages/index.jsx",
|
|
5
|
+
"main": "src/pages/index.jsx",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"start": "umi dev",
|
|
8
8
|
"build": "umi build",
|
|
@@ -27,6 +27,7 @@
|
|
|
27
27
|
"dependencies": {
|
|
28
28
|
"@ant-design/pro-layout": "^6.5.0",
|
|
29
29
|
"antd": "^4.17.0",
|
|
30
|
+
"axios": "^0.27.2",
|
|
30
31
|
"react": "^17.0.0",
|
|
31
32
|
"react-dom": "^17.0.0",
|
|
32
33
|
"umi": "^3.5.0"
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { useState, useEffect, useRef, useMemo } from 'react';
|
|
2
|
-
import { Popconfirm, message } from 'antd';
|
|
2
|
+
import { Popconfirm, message, Popover } from 'antd';
|
|
3
3
|
import { menuList as menuListInit, menuIconSrc, sysNameMap } from './constData'
|
|
4
4
|
import HeaderDropdown from '../ModuleUser/HeaderDropdown'
|
|
5
5
|
import './index.less'
|
|
6
6
|
|
|
7
|
-
const ModuleMenu = ({sysName}) => {
|
|
7
|
+
const ModuleMenu = ({ sysName }) => {
|
|
8
8
|
const [sessionMenu, setsessionMenu] = useState([]);
|
|
9
9
|
const [showMenuList, setshowMenuList] = useState(false);
|
|
10
10
|
const [menuList, setMenuList] = useState([]);
|
|
@@ -75,6 +75,7 @@ const ModuleMenu = ({sysName}) => {
|
|
|
75
75
|
message.warning("没有获取到菜单列表,请联系管理员添加权限");
|
|
76
76
|
return;
|
|
77
77
|
}
|
|
78
|
+
console.log('nameStr', nameStr)
|
|
78
79
|
let thirdPartyServiceJumpPath = ""; // 第三方服务跳转路径
|
|
79
80
|
let thirdPartyServiceRootMenuPath = ""; // 第三方服务根菜单路径
|
|
80
81
|
switch (nameStr) {
|
|
@@ -200,7 +201,7 @@ const ModuleMenu = ({sysName}) => {
|
|
|
200
201
|
return (
|
|
201
202
|
<div>
|
|
202
203
|
<div className='menuPopupAndTitle'>
|
|
203
|
-
<div className='menuIcon' onClick={() => setshowMenuList(!showMenuList)}
|
|
204
|
+
<div className='menuIcon' onClick={() => setshowMenuList(!showMenuList)}>
|
|
204
205
|
<img className="menuIcon_img" src={menuIconSrc} />
|
|
205
206
|
</div>
|
|
206
207
|
<div className="menu_title_content">
|
|
@@ -4,6 +4,7 @@ import { userMenuIcon } from './constData'
|
|
|
4
4
|
import { HomeOutlined, UserOutlined, CaretDownOutlined} from '@ant-design/icons';
|
|
5
5
|
import { Spin, Menu, Avatar } from 'antd';
|
|
6
6
|
import HeaderDropdown from './HeaderDropdown'
|
|
7
|
+
import Axios from '../util/axios';
|
|
7
8
|
import './index.less'
|
|
8
9
|
const ModuleUser = () => {
|
|
9
10
|
const handleClickmenu = (url)=>{
|
|
@@ -24,9 +25,9 @@ const ModuleUser = () => {
|
|
|
24
25
|
const logout = () => {
|
|
25
26
|
Axios('delete','/auth/token/logout', '', {} )
|
|
26
27
|
.then(() => {
|
|
27
|
-
|
|
28
|
-
localStorage.clear();
|
|
29
|
-
sessionStorage.clear();
|
|
28
|
+
console.log('退出登录接口调用成功')
|
|
29
|
+
// localStorage.clear();
|
|
30
|
+
// sessionStorage.clear();
|
|
30
31
|
window.location.href = DEFAULT_LOGOUT_URL;
|
|
31
32
|
})
|
|
32
33
|
.catch((error) => {
|
|
@@ -40,7 +41,7 @@ const ModuleUser = () => {
|
|
|
40
41
|
<img src={PersonalCenterSrc} alt="" style={{ marginRight: '10px', marginTop: '-3px' }} />
|
|
41
42
|
<span>个人中心</span>
|
|
42
43
|
</Menu.Item>
|
|
43
|
-
<Menu.Item key="messageCenter" onClick={()=>handleClickmenu('
|
|
44
|
+
<Menu.Item key="messageCenter" onClick={()=>handleClickmenu('/#/alert/')}>
|
|
44
45
|
<img src={MessageCenterSrc} alt="" style={{ marginRight: '10px', marginTop: '-3px' }} />
|
|
45
46
|
<span>消息中心</span>
|
|
46
47
|
</Menu.Item>
|
|
@@ -39,21 +39,4 @@
|
|
|
39
39
|
:global(.ant-dropdown-menu-item) {
|
|
40
40
|
min-width: 160px;
|
|
41
41
|
}
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
@import (reference) '~antd/es/style/themes/index';
|
|
45
|
-
|
|
46
|
-
.container > * {
|
|
47
|
-
background-color: @popover-bg;
|
|
48
|
-
border-radius: 4px;
|
|
49
|
-
box-shadow: @shadow-1-down;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
@media screen and (max-width: @screen-xs) {
|
|
53
|
-
.container {
|
|
54
|
-
width: 100% !important;
|
|
55
|
-
}
|
|
56
|
-
.container > * {
|
|
57
|
-
border-radius: 0 !important;
|
|
58
|
-
}
|
|
59
|
-
}
|
|
42
|
+
}
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import { message } from 'antd';
|
|
2
|
+
import axios from 'axios';
|
|
3
|
+
import baseCof from './config';
|
|
4
|
+
import getStore from './userInfo';
|
|
5
|
+
import { checkToken} from './permessionUtils';
|
|
6
|
+
|
|
7
|
+
let tokenValue='7f288e2a-deb0-44fe-af72-7345ac8a6784';
|
|
8
|
+
|
|
9
|
+
axios.interceptors.response.use(
|
|
10
|
+
(response) => {
|
|
11
|
+
if (response.status === 200) {
|
|
12
|
+
return response;
|
|
13
|
+
} else if (response.status === 401 || response.status === 302 || response.status === 403) {
|
|
14
|
+
if (process.env.NODE_ENV === 'production') {
|
|
15
|
+
tokenValue = getStore({ name: 'access_token' });
|
|
16
|
+
}
|
|
17
|
+
checkToken(tokenValue);
|
|
18
|
+
} else {
|
|
19
|
+
console.log('接口异常 response');
|
|
20
|
+
return Promise.reject('error');
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
(error) => {
|
|
24
|
+
console.log('error', error)
|
|
25
|
+
if (error.response) {
|
|
26
|
+
if (error.response.status === 401) {
|
|
27
|
+
if (process.env.NODE_ENV === 'production') {
|
|
28
|
+
tokenValue = getStore({ name: 'access_token' });
|
|
29
|
+
}
|
|
30
|
+
checkToken(tokenValue);
|
|
31
|
+
} else if (error.response.status === 403) {
|
|
32
|
+
// 提示无权限等
|
|
33
|
+
} else {
|
|
34
|
+
// 其他错误处理
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
return Promise.reject(error.response.data);
|
|
38
|
+
},
|
|
39
|
+
);
|
|
40
|
+
|
|
41
|
+
/** 全局请求拦截器 */
|
|
42
|
+
axios.interceptors.request.use(
|
|
43
|
+
async (params) => {
|
|
44
|
+
// 生产环境,对接门户时,需要在请求头中设置token等信息
|
|
45
|
+
if (process.env.NODE_ENV === 'production') {
|
|
46
|
+
const TENANT_ID = getStore({ name: 'tenantId' }) || '1';
|
|
47
|
+
const isToken = (params.headers || {}).isToken === false;
|
|
48
|
+
const token = getStore({ name: 'access_token' });
|
|
49
|
+
if (!(token && !isToken) || !TENANT_ID) {
|
|
50
|
+
// 如果是调用退出登录接口,则不再执行退出登录逻辑,防止出现重复调用退出登录的循环
|
|
51
|
+
return params;
|
|
52
|
+
}
|
|
53
|
+
const headers = {
|
|
54
|
+
Authorization: `Bearer ${token}`,
|
|
55
|
+
TENANT_ID,
|
|
56
|
+
};
|
|
57
|
+
params.headers.common['Authorization'] = `Bearer ${token}`;
|
|
58
|
+
params.headers.common['TENANT-ID'] = TENANT_ID;
|
|
59
|
+
return params;
|
|
60
|
+
}
|
|
61
|
+
params.headers.common['Authorization'] = `Bearer ${tokenValue}`;
|
|
62
|
+
params.headers.common['TENANT-ID'] = '1';
|
|
63
|
+
return params;
|
|
64
|
+
},
|
|
65
|
+
function (error) {
|
|
66
|
+
// 对请求错误做些什么
|
|
67
|
+
return Promise.reject(error);
|
|
68
|
+
},
|
|
69
|
+
);
|
|
70
|
+
|
|
71
|
+
function Axios(method, api, params, map) {
|
|
72
|
+
// console.log(params)
|
|
73
|
+
|
|
74
|
+
let httpDefult;
|
|
75
|
+
// 几个外部特殊接口
|
|
76
|
+
// 退出登录
|
|
77
|
+
if(api === '/auth/token/logout'){
|
|
78
|
+
httpDefult = {
|
|
79
|
+
method: method,
|
|
80
|
+
url: `${baseCof.baseSever}${api}`,
|
|
81
|
+
params: params,
|
|
82
|
+
...map,
|
|
83
|
+
};
|
|
84
|
+
console.log('httpDefult', httpDefult)
|
|
85
|
+
} else if (api === '/admin/social/logoutUri') {
|
|
86
|
+
httpDefult = {
|
|
87
|
+
method: method,
|
|
88
|
+
url: api,
|
|
89
|
+
params: params,
|
|
90
|
+
...map,
|
|
91
|
+
};
|
|
92
|
+
}else if(api.search("check_token") !== -1){
|
|
93
|
+
httpDefult = {
|
|
94
|
+
method: method,
|
|
95
|
+
url: `${baseCof.baseSever}${api}`,
|
|
96
|
+
params: params,
|
|
97
|
+
...map,
|
|
98
|
+
};
|
|
99
|
+
}else if (method === 'get') {
|
|
100
|
+
httpDefult = {
|
|
101
|
+
method: method,
|
|
102
|
+
url: `${baseCof.baseSever}${baseCof.basePath}${api}`,
|
|
103
|
+
params: params,
|
|
104
|
+
...map,
|
|
105
|
+
};
|
|
106
|
+
} else if (method === 'post') {
|
|
107
|
+
httpDefult = {
|
|
108
|
+
method: method,
|
|
109
|
+
url: `${baseCof.baseSever}${baseCof.basePath}${api}`,
|
|
110
|
+
params: params,
|
|
111
|
+
...map,
|
|
112
|
+
};
|
|
113
|
+
} else {
|
|
114
|
+
httpDefult = {
|
|
115
|
+
method: method,
|
|
116
|
+
url: `${baseCof.baseSever}${baseCof.basePath}${api}`,
|
|
117
|
+
params: params,
|
|
118
|
+
...map,
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
return new Promise((resolve, reject) => {
|
|
123
|
+
axios(httpDefult)
|
|
124
|
+
.then((res) => {
|
|
125
|
+
resolve(res);
|
|
126
|
+
})
|
|
127
|
+
.catch((err) => {
|
|
128
|
+
reject(err);
|
|
129
|
+
});
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
export default Axios;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
const address = window.location.hostname
|
|
2
|
+
const port = window.location.port
|
|
3
|
+
const baseCof = process.env.NODE_ENV === 'production' ?{
|
|
4
|
+
baseSever: `https://${address}:${port}`,
|
|
5
|
+
basePath: `/app/cmcc/data`,
|
|
6
|
+
}:{
|
|
7
|
+
baseSever: 'http://localhost:8000',
|
|
8
|
+
basePath: '/cmcc/data',
|
|
9
|
+
};
|
|
10
|
+
export default baseCof;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import Axios from './axios';
|
|
2
|
+
import { message } from 'antd';
|
|
3
|
+
|
|
4
|
+
const DEFAULT_LOGOUT_URL = '/#/login'
|
|
5
|
+
// 退出登录
|
|
6
|
+
export const logout = () => {
|
|
7
|
+
Axios('delete','/auth/token/logout', '', {} )
|
|
8
|
+
.then(() => {
|
|
9
|
+
// console.log('退出登录接口调用成功')
|
|
10
|
+
localStorage.clear();
|
|
11
|
+
sessionStorage.clear();
|
|
12
|
+
window.location.href = DEFAULT_LOGOUT_URL;
|
|
13
|
+
})
|
|
14
|
+
.catch((error) => {
|
|
15
|
+
console.error('Error while logging out, error:', error);
|
|
16
|
+
message.error('服务器错误,请稍后重试');
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
// 校验token是否失效
|
|
20
|
+
export const checkToken = (token) => {
|
|
21
|
+
Axios('get',`/auth/oauth/check_token?token=${token}`, '', {} ).then(
|
|
22
|
+
).catch(err=>{
|
|
23
|
+
// console.log('token失效')
|
|
24
|
+
message.error({content:'用户凭证已过期,请重新登录', onClose: ()=>{
|
|
25
|
+
localStorage.clear();
|
|
26
|
+
sessionStorage.clear();
|
|
27
|
+
window.location.href = DEFAULT_LOGOUT_URL;
|
|
28
|
+
}});
|
|
29
|
+
// localStorage.clear();
|
|
30
|
+
// sessionStorage.clear();
|
|
31
|
+
// window.location.href = DEFAULT_LOGOUT_URL;
|
|
32
|
+
})
|
|
33
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 获取认证相关的localStorage/SessionStorage
|
|
3
|
+
*/
|
|
4
|
+
function getStore(params) {
|
|
5
|
+
let { name } = params;
|
|
6
|
+
const { debug } = params;
|
|
7
|
+
const keyName = 'bigdata-';
|
|
8
|
+
name = keyName + name;
|
|
9
|
+
let obj = {};
|
|
10
|
+
let content;
|
|
11
|
+
obj = window.sessionStorage.getItem(name);
|
|
12
|
+
if (!obj || Object.keys(obj).length === 0) obj = window.localStorage.getItem(name);
|
|
13
|
+
if (!obj || Object.keys(obj).length === 0) return '';
|
|
14
|
+
try {
|
|
15
|
+
obj = JSON.parse(obj);
|
|
16
|
+
} catch (e) {
|
|
17
|
+
return '';
|
|
18
|
+
}
|
|
19
|
+
if (debug) {
|
|
20
|
+
return '';
|
|
21
|
+
}
|
|
22
|
+
if (obj.dataType === 'string') {
|
|
23
|
+
content = obj.content;
|
|
24
|
+
} else if (obj.dataType === 'number') {
|
|
25
|
+
content = Number(obj.content);
|
|
26
|
+
} else if (obj.dataType === 'boolean') {
|
|
27
|
+
// eslint-disable-next-line no-eval
|
|
28
|
+
content = eval(obj.content);
|
|
29
|
+
} else if (obj.dataType === 'object') {
|
|
30
|
+
content = obj.content;
|
|
31
|
+
}
|
|
32
|
+
return content;
|
|
33
|
+
}
|
|
34
|
+
export default getStore;
|
|
35
|
+
|
|
36
|
+
export const getUserName = () => {
|
|
37
|
+
const userInfo = getStore({ name: 'userInfo' });
|
|
38
|
+
if (userInfo && Object.keys(userInfo).length > 0 && userInfo.username) {
|
|
39
|
+
return userInfo.username;
|
|
40
|
+
}
|
|
41
|
+
return '';
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
export const getUserId = () => {
|
|
45
|
+
const userInfo = getStore({ name: 'userInfo' });
|
|
46
|
+
if (userInfo && Object.keys(userInfo).length > 0 && userInfo.id) {
|
|
47
|
+
return userInfo.id;
|
|
48
|
+
}
|
|
49
|
+
return '';
|
|
50
|
+
};
|