module-menu-vue 0.0.22 → 0.0.25
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 +2 -1
- package/src/assets/ic_shujuanquan.png +0 -0
- package/src/components/Menu/ModuleMenu.vue +5 -2
- package/src/components/Menu/constant.js +10 -0
- package/src/components/User/UserInfo.vue +2 -27
- package/src/components/Util/axios.js +89 -0
- package/src/components/Util/config.js +10 -0
- package/src/components/Util/permessionUtils.js +29 -0
- package/vue.config.js +43 -0
package/package.json
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "module-menu-vue",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.25",
|
|
4
4
|
"description": "城市大数据平台菜单--Vue版",
|
|
5
5
|
"main": "/index.js",
|
|
6
6
|
"scripts": {
|
|
7
|
+
"dev": "vue-cli-service serve",
|
|
7
8
|
"serve": "vue-cli-service serve",
|
|
8
9
|
"build": "vue-cli-service build",
|
|
9
10
|
"lint": "vue-cli-service lint"
|
|
Binary file
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div>
|
|
3
3
|
<div class='menuPopupAndTitle'>
|
|
4
|
-
<div class='menuIcon' @mouseenter="showMenuList = true" @mouseleave="showMenuList =false">
|
|
4
|
+
<div class='menuIcon' @mouseenter="showMenuList = true" @mouseleave="showMenuList = false">
|
|
5
5
|
<img class="menuIcon_img" :src="menuIconSrc" />
|
|
6
6
|
</div>
|
|
7
7
|
<div class="menu_title_content" v-show="showCollapse" @click="toHref()">
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
<span class="menu_title">{{getLogoAndTitle().title}}</span>
|
|
10
10
|
</div>
|
|
11
11
|
</div>
|
|
12
|
-
<div class='menu_list_content' :style="{ display: showMenuList ? 'block' : 'none' }">
|
|
12
|
+
<div class='menu_list_content' :style="{ display: showMenuList ? 'block' : 'none' }" @mouseenter="showMenuList = true" @mouseleave="showMenuList = false">
|
|
13
13
|
<div v-for="(item, index) in menuList" :key="item.path">
|
|
14
14
|
<div :key="item.name" class="cardLine" :style="{height: item.children.length > 3 ? '90px' : ''}">
|
|
15
15
|
<div class='leftMenu'
|
|
@@ -138,6 +138,9 @@ export default {
|
|
|
138
138
|
case "消息中心":
|
|
139
139
|
thirdPartyServiceJumpPath = "/alert/";
|
|
140
140
|
break;
|
|
141
|
+
case "数据安全":
|
|
142
|
+
thirdPartyServiceJumpPath = "/datasecurity/";
|
|
143
|
+
break;
|
|
141
144
|
default:
|
|
142
145
|
break;
|
|
143
146
|
}
|
|
@@ -94,10 +94,20 @@ export const menuList = [{
|
|
|
94
94
|
childName: '消息中心',
|
|
95
95
|
path: '/alert',
|
|
96
96
|
url:require('../../assets/alert_slogo.svg'),
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
childName: '数据安全',
|
|
100
|
+
path: '/datasecurity',
|
|
101
|
+
url:require('../../assets/ic_shujuanquan.png'),
|
|
97
102
|
}]
|
|
98
103
|
}];
|
|
99
104
|
export const menuIconSrc = require('../../assets/menuIcon.svg');
|
|
100
105
|
export const sysNameMap = [
|
|
106
|
+
{
|
|
107
|
+
sysName: 'datasecurity',
|
|
108
|
+
title: '数据安全',
|
|
109
|
+
logoSrc: require('../../assets/ic_shujuanquan.png'),
|
|
110
|
+
},
|
|
101
111
|
{
|
|
102
112
|
sysName: 'datacollection',
|
|
103
113
|
title: '数据集成',
|
|
@@ -26,10 +26,8 @@
|
|
|
26
26
|
</template>
|
|
27
27
|
|
|
28
28
|
<script >
|
|
29
|
-
// import {logout} from './service.js'
|
|
30
29
|
import {userMenuIcon} from './constant.js'
|
|
31
|
-
import {
|
|
32
|
-
import axios from 'axios'
|
|
30
|
+
import { logout } from '../Util/permessionUtils'
|
|
33
31
|
export default {
|
|
34
32
|
name: 'UserInfo',
|
|
35
33
|
data () {
|
|
@@ -60,30 +58,7 @@ export default {
|
|
|
60
58
|
window.location.href = url;
|
|
61
59
|
},
|
|
62
60
|
logoutFunc () {
|
|
63
|
-
|
|
64
|
-
headers: {}
|
|
65
|
-
}
|
|
66
|
-
// const TENANT_ID = getStore({ name: "tenantId" }) || '1';
|
|
67
|
-
const isToken = (config.headers || {}).isToken === false;
|
|
68
|
-
const token = getStore({ name: 'access_token' });
|
|
69
|
-
if (token && !isToken) {
|
|
70
|
-
config.headers["Authorization"] = `Bearer ${token}`; // token
|
|
71
|
-
}
|
|
72
|
-
// if (TENANT_ID) {
|
|
73
|
-
// config.headers["TENANT-ID"] = TENANT_ID; // 租户ID
|
|
74
|
-
// }
|
|
75
|
-
sessionStorage.clear();
|
|
76
|
-
localStorage.clear();
|
|
77
|
-
axios({
|
|
78
|
-
method: 'delete',
|
|
79
|
-
url: '/auth/token/logout',
|
|
80
|
-
...config
|
|
81
|
-
}).then(res => {
|
|
82
|
-
console.log('res', res)
|
|
83
|
-
this.$router.push({ path: "/login" });
|
|
84
|
-
}).catch((err) => {
|
|
85
|
-
console.error(err)
|
|
86
|
-
})
|
|
61
|
+
logout()
|
|
87
62
|
},
|
|
88
63
|
getUserName () {
|
|
89
64
|
const userInfo = JSON.parse(sessionStorage.getItem('bigdata-userInfo')||"{}");
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import axios from 'axios';
|
|
2
|
+
import baseCof from './config';
|
|
3
|
+
import getStore from './userInfo';
|
|
4
|
+
import { checkToken} from './permessionUtils';
|
|
5
|
+
|
|
6
|
+
let tokenValue = '574536b1-5832-417b-b909-82e204679d67';
|
|
7
|
+
|
|
8
|
+
axios.interceptors.response.use(
|
|
9
|
+
(response) => {
|
|
10
|
+
if (response.status === 200) {
|
|
11
|
+
return response;
|
|
12
|
+
} else if (response.status === 401 || response.status === 302 || response.status === 403) {
|
|
13
|
+
if (process.env.NODE_ENV === 'production') {
|
|
14
|
+
tokenValue = getStore({ name: 'access_token' });
|
|
15
|
+
}
|
|
16
|
+
checkToken(tokenValue);
|
|
17
|
+
} else {
|
|
18
|
+
console.log('接口异常 response');
|
|
19
|
+
return Promise.reject('error');
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
(error) => {
|
|
23
|
+
console.log('error', error)
|
|
24
|
+
if (error.response) {
|
|
25
|
+
if (error.response.status === 401) {
|
|
26
|
+
if (process.env.NODE_ENV === 'production') {
|
|
27
|
+
tokenValue = getStore({ name: 'access_token' });
|
|
28
|
+
}
|
|
29
|
+
checkToken(tokenValue);
|
|
30
|
+
} else if (error.response.status === 403) {
|
|
31
|
+
// 提示无权限等
|
|
32
|
+
} else {
|
|
33
|
+
// 其他错误处理
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
console.log('=========', JSON.stringify(error.response))
|
|
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
|
+
params.headers['Authorization'] = `Bearer ${token}`;
|
|
54
|
+
params.headers['TENANT-ID'] = TENANT_ID;
|
|
55
|
+
return params;
|
|
56
|
+
}
|
|
57
|
+
params.headers['Authorization'] = `Bearer ${tokenValue}`;
|
|
58
|
+
params.headers['TENANT-ID'] = 1;
|
|
59
|
+
console.log('params', JSON.stringify(params))
|
|
60
|
+
return params;
|
|
61
|
+
},
|
|
62
|
+
function (error) {
|
|
63
|
+
// 对请求错误做些什么
|
|
64
|
+
return Promise.reject(error);
|
|
65
|
+
},
|
|
66
|
+
);
|
|
67
|
+
|
|
68
|
+
function Axios(method, api) {
|
|
69
|
+
let httpDefult = {};
|
|
70
|
+
// 退出登录
|
|
71
|
+
httpDefult = {
|
|
72
|
+
method: method,
|
|
73
|
+
url: `${baseCof.baseSever}${api}`,
|
|
74
|
+
params: '',
|
|
75
|
+
};
|
|
76
|
+
console.log('httpDefult', JSON.stringify(httpDefult))
|
|
77
|
+
|
|
78
|
+
return new Promise((resolve, reject) => {
|
|
79
|
+
axios(httpDefult)
|
|
80
|
+
.then((res) => {
|
|
81
|
+
resolve(res);
|
|
82
|
+
})
|
|
83
|
+
.catch((err) => {
|
|
84
|
+
reject(err);
|
|
85
|
+
});
|
|
86
|
+
})
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
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,29 @@
|
|
|
1
|
+
import Axios from './axios';
|
|
2
|
+
|
|
3
|
+
const DEFAULT_LOGOUT_URL = '/#/login'
|
|
4
|
+
// 退出登录
|
|
5
|
+
export const logout = () => {
|
|
6
|
+
console.log('调用了。。。')
|
|
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.log('调用失败')
|
|
16
|
+
console.error('Error while logging out, error:', error);
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
// 校验token是否失效
|
|
20
|
+
export const checkToken = (token) => {
|
|
21
|
+
Axios('get',`/auth/oauth/check_token?token=${token}`, '', {} )
|
|
22
|
+
.then().catch(() =>{
|
|
23
|
+
this.$message.error({content:'用户凭证已过期,请重新登录', onClose: ()=>{
|
|
24
|
+
localStorage.clear();
|
|
25
|
+
sessionStorage.clear();
|
|
26
|
+
window.location.href = DEFAULT_LOGOUT_URL;
|
|
27
|
+
}});
|
|
28
|
+
})
|
|
29
|
+
}
|
package/vue.config.js
CHANGED
|
@@ -2,3 +2,46 @@ const { defineConfig } = require('@vue/cli-service')
|
|
|
2
2
|
module.exports = defineConfig({
|
|
3
3
|
transpileDependencies: true
|
|
4
4
|
})
|
|
5
|
+
// const url = 'https://192.168.108.86:30011/'
|
|
6
|
+
// module.exports = {
|
|
7
|
+
// lintOnSave: true,
|
|
8
|
+
// productionSourceMap: false,
|
|
9
|
+
// css: {
|
|
10
|
+
// // 忽略 CSS order 顺序警告
|
|
11
|
+
// extract: { ignoreOrder: true },
|
|
12
|
+
// // 查看CSS属于哪个css文件
|
|
13
|
+
// sourceMap: process.env.NODE_ENV === "development",
|
|
14
|
+
// },
|
|
15
|
+
// configureWebpack: () => {
|
|
16
|
+
// if (process.env.NODE_ENV === "production") {
|
|
17
|
+
// // 仅在生产环境下启用该配置
|
|
18
|
+
// return {
|
|
19
|
+
// performance: {
|
|
20
|
+
// // 打包后最大文件大小限制
|
|
21
|
+
// maxAssetSize: 1024000,
|
|
22
|
+
// },
|
|
23
|
+
// };
|
|
24
|
+
// } else if (process.env.NODE_ENV === "development") {
|
|
25
|
+
// return {
|
|
26
|
+
// devtool: "source-map",
|
|
27
|
+
// };
|
|
28
|
+
// }
|
|
29
|
+
// },
|
|
30
|
+
// // 配置转发代理
|
|
31
|
+
// devServer: {
|
|
32
|
+
// // disableHostCheck: true,
|
|
33
|
+
// port: 8080,
|
|
34
|
+
// proxy: {
|
|
35
|
+
// "/": {
|
|
36
|
+
// // target:' https://10.136.106.82:30011',
|
|
37
|
+
// target: url,
|
|
38
|
+
// ws: false, // 需要websocket 开启
|
|
39
|
+
// // changOrigin: true, //允许跨域
|
|
40
|
+
// pathRewrite: {
|
|
41
|
+
// "^/": "/",
|
|
42
|
+
// },
|
|
43
|
+
// },
|
|
44
|
+
// // 3.5 以后不需要再配置
|
|
45
|
+
// },
|
|
46
|
+
// },
|
|
47
|
+
// };
|