module-menu-vue 0.0.42 → 0.0.44
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/index.js +4 -2
- package/package.json +1 -1
- package/src/App.vue +8 -2
- package/src/assets/ic_muluguanli.png +0 -0
- package/src/assets/ic_ziyuanguanli.png +0 -0
- package/src/components/Menu/ModuleMenu.vue +42 -9
- package/src/components/Menu/constant.js +18 -7
- package/src/components/Menu/menu.css +1 -1
- package/src/components/Menu/service.js +6 -0
- package/src/components/Portal/PortalBtn.vue +23 -0
- package/src/components/Tenant/TenantList.vue +63 -0
- package/src/components/Tenant/service.js +15 -0
- package/src/components/User/UserInfo.vue +32 -27
- package/src/components/Util/axios.js +6 -3
- package/src/components/Util/config.js +2 -2
- package/src/components/Util/permessionUtils.js +5 -20
- package/src/components/Util/userInfo.js +73 -35
- package/src/main.js +1 -3
- package/vue.config.js +38 -4
- package/src/components/User/service.js +0 -7
package/index.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
import ModuleMenu from './src/components/Menu/ModuleMenu.vue';
|
|
2
|
-
import UserInfo from './src/components/User/UserInfo.vue'
|
|
3
|
-
|
|
2
|
+
import UserInfo from './src/components/User/UserInfo.vue';
|
|
3
|
+
import TenantList from './src/components/Tenant/TenantList.vue';
|
|
4
|
+
import PortalBtn from './src/components/Portal/PortalBtn.vue';
|
|
5
|
+
export { ModuleMenu, UserInfo, TenantList, PortalBtn};
|
package/package.json
CHANGED
package/src/App.vue
CHANGED
|
@@ -1,13 +1,17 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div id="app">
|
|
3
3
|
<ModuleMenu></ModuleMenu>
|
|
4
|
+
<TenantList></TenantList>
|
|
5
|
+
<PortalBtn></PortalBtn>
|
|
4
6
|
<UserInfo></UserInfo>
|
|
5
7
|
</div>
|
|
6
8
|
</template>
|
|
7
9
|
|
|
8
10
|
<script>
|
|
9
|
-
import ModuleMenu from '
|
|
10
|
-
import
|
|
11
|
+
import ModuleMenu from '@/components/Menu/ModuleMenu.vue'
|
|
12
|
+
import PortalBtn from '@/components/Portal/PortalBtn.vue'
|
|
13
|
+
import TenantList from '@/components/Tenant/TenantList.vue'
|
|
14
|
+
import UserInfo from '@/components/User/UserInfo.vue'
|
|
11
15
|
export default {
|
|
12
16
|
name: 'App',
|
|
13
17
|
data () {
|
|
@@ -15,6 +19,8 @@ export default {
|
|
|
15
19
|
},
|
|
16
20
|
components: {
|
|
17
21
|
ModuleMenu,
|
|
22
|
+
TenantList,
|
|
23
|
+
PortalBtn,
|
|
18
24
|
UserInfo
|
|
19
25
|
}
|
|
20
26
|
}
|
|
Binary file
|
|
Binary file
|
|
@@ -42,6 +42,7 @@
|
|
|
42
42
|
<script>
|
|
43
43
|
import { menuList as menuListInit, menuIconSrc, sysNameMap } from './constant.js'
|
|
44
44
|
import './menu.css'
|
|
45
|
+
import {getMenuList} from './service.js'
|
|
45
46
|
export default {
|
|
46
47
|
name: 'ModuleMenu',
|
|
47
48
|
props: {
|
|
@@ -52,6 +53,10 @@ export default {
|
|
|
52
53
|
collapse: {
|
|
53
54
|
type: Boolean,
|
|
54
55
|
default: true,
|
|
56
|
+
},
|
|
57
|
+
stash: {
|
|
58
|
+
type: String,
|
|
59
|
+
default: 'integration'
|
|
55
60
|
}
|
|
56
61
|
},
|
|
57
62
|
watch: {
|
|
@@ -71,23 +76,41 @@ export default {
|
|
|
71
76
|
sessionMenu: [],
|
|
72
77
|
menuListInit: menuListInit,
|
|
73
78
|
sysNameMap: sysNameMap,
|
|
74
|
-
showCollapse: true
|
|
79
|
+
showCollapse: true,
|
|
75
80
|
}
|
|
76
81
|
},
|
|
77
82
|
created () {
|
|
78
83
|
this.getSessionMenu();
|
|
79
|
-
this.
|
|
84
|
+
if (this.stash !== "integration") {
|
|
85
|
+
this.getNewMenuList();
|
|
86
|
+
}
|
|
80
87
|
},
|
|
81
88
|
methods: {
|
|
82
89
|
toHref () {
|
|
83
90
|
if (this.sysName === 'admin') {
|
|
84
|
-
|
|
91
|
+
location.href = '/#/admin/user/index'
|
|
85
92
|
}
|
|
86
93
|
},
|
|
87
|
-
getSessionMenu () {
|
|
88
|
-
|
|
89
|
-
if (
|
|
90
|
-
|
|
94
|
+
async getSessionMenu () {
|
|
95
|
+
// 一体化
|
|
96
|
+
if (this.stash === "integration") {
|
|
97
|
+
const rsp = await getMenuList()
|
|
98
|
+
if (rsp.data.data) {
|
|
99
|
+
const pathList = rsp.data.data.map(item => {
|
|
100
|
+
return {
|
|
101
|
+
...item,
|
|
102
|
+
path: item.path.indexOf('/') === -1 ? '/' + item.path : item.path
|
|
103
|
+
}
|
|
104
|
+
})
|
|
105
|
+
this.sessionMenu = [...pathList]
|
|
106
|
+
this.getNewMenuList();
|
|
107
|
+
}
|
|
108
|
+
} else {
|
|
109
|
+
// 轻量级
|
|
110
|
+
const menuObj = JSON.parse(sessionStorage.getItem('bigdata-menu'));
|
|
111
|
+
if (menuObj) {
|
|
112
|
+
this.sessionMenu = [...menuObj.content]
|
|
113
|
+
}
|
|
91
114
|
}
|
|
92
115
|
},
|
|
93
116
|
// 获取系统logo及title
|
|
@@ -141,15 +164,21 @@ export default {
|
|
|
141
164
|
case "数据安全":
|
|
142
165
|
thirdPartyServiceJumpPath = "/datasecurity/";
|
|
143
166
|
break;
|
|
167
|
+
case "目录管理":
|
|
168
|
+
thirdPartyServiceJumpPath = "/admin-ui/catalog/menuClassify/list";
|
|
169
|
+
break;
|
|
170
|
+
case "资源管理":
|
|
171
|
+
thirdPartyServiceJumpPath = "/admin-ui/resource/tableResource/list";
|
|
172
|
+
break;
|
|
144
173
|
default:
|
|
145
174
|
break;
|
|
146
175
|
}
|
|
147
|
-
|
|
176
|
+
location.href = thirdPartyServiceJumpPath
|
|
148
177
|
},
|
|
149
178
|
// 跳转首页
|
|
150
179
|
toHomePage (index) {
|
|
151
180
|
if (index === 0) {
|
|
152
|
-
|
|
181
|
+
location.href = this.stash === "integration" ? '/dataadmin/#/index' : '/#/index'
|
|
153
182
|
}
|
|
154
183
|
},
|
|
155
184
|
getNewMenuList () {
|
|
@@ -176,4 +205,8 @@ export default {
|
|
|
176
205
|
}
|
|
177
206
|
</script>
|
|
178
207
|
<style scoped>
|
|
208
|
+
.iconPad{
|
|
209
|
+
width: 15px;
|
|
210
|
+
height: 15px;
|
|
211
|
+
}
|
|
179
212
|
</style>
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
const token = localStorage.getItem('ACCESS_TOKEN')
|
|
2
|
+
console.log('token', token)
|
|
1
3
|
export const menuList = [{
|
|
2
4
|
name: '首页',
|
|
3
5
|
url: require('../../assets/home.svg'),
|
|
@@ -8,7 +10,7 @@ export const menuList = [{
|
|
|
8
10
|
url: require('../../assets/ic_shujuhuiju_m.svg'),
|
|
9
11
|
children: [{
|
|
10
12
|
childName: '数据集成',
|
|
11
|
-
path: '/datacollection',
|
|
13
|
+
path: token ? '/datacollect' : '/datacollection',
|
|
12
14
|
url:require('../../assets/datacollection_slogo.svg'),
|
|
13
15
|
}]
|
|
14
16
|
},
|
|
@@ -17,7 +19,7 @@ export const menuList = [{
|
|
|
17
19
|
url: require('../../assets/ic_shujuzhili_m.svg'),
|
|
18
20
|
children: [{
|
|
19
21
|
childName: '数据治理',
|
|
20
|
-
path: '/dataManager',
|
|
22
|
+
path: token ? '/datamanage' : '/dataManager',
|
|
21
23
|
url:require('../../assets/datamanager_slogo.svg'),
|
|
22
24
|
},
|
|
23
25
|
{
|
|
@@ -27,7 +29,7 @@ export const menuList = [{
|
|
|
27
29
|
},
|
|
28
30
|
{
|
|
29
31
|
childName: '数据质量',
|
|
30
|
-
path: '/quality/',
|
|
32
|
+
path: token ? '/quality' : '/quality/',
|
|
31
33
|
url:require('../../assets/quality_slogo.svg'),
|
|
32
34
|
}]
|
|
33
35
|
},
|
|
@@ -36,7 +38,7 @@ export const menuList = [{
|
|
|
36
38
|
url: require('../../assets/ic_shujukaifa_m.svg'),
|
|
37
39
|
children: [{
|
|
38
40
|
childName: '离线开发',
|
|
39
|
-
path: '/datadev/',
|
|
41
|
+
path: token ? '/datadev' : '/datadev/',
|
|
40
42
|
url:require('../../assets/datadev_slogo.svg'),
|
|
41
43
|
},
|
|
42
44
|
{
|
|
@@ -62,6 +64,16 @@ export const menuList = [{
|
|
|
62
64
|
childName: '数据共享',
|
|
63
65
|
path: '/datasharing',
|
|
64
66
|
url:require('../../assets/datasharing_slogo.svg'),
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
childName: "目录管理",
|
|
70
|
+
path: "/muluguanli",
|
|
71
|
+
url: require("../../assets/ic_muluguanli.png"),
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
childName: "资源管理",
|
|
75
|
+
path: "/ziyuanguanli",
|
|
76
|
+
url: require("../../assets/ic_ziyuanguanli.png"),
|
|
65
77
|
}]
|
|
66
78
|
},
|
|
67
79
|
{
|
|
@@ -165,7 +177,7 @@ export const sysNameMap = [
|
|
|
165
177
|
},
|
|
166
178
|
{
|
|
167
179
|
sysName: 'admin',
|
|
168
|
-
title: '系统管理',
|
|
180
|
+
title: token ? '数据源管理' : '系统管理',
|
|
169
181
|
logoSrc: require('../../assets/admin_logo.svg'),
|
|
170
182
|
},
|
|
171
183
|
// {
|
|
@@ -178,5 +190,4 @@ export const sysNameMap = [
|
|
|
178
190
|
title: '消息中心',
|
|
179
191
|
logoSrc: require('../../assets/alert_logo.svg'),
|
|
180
192
|
},
|
|
181
|
-
|
|
182
|
-
];
|
|
193
|
+
];
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<el-button @click="handleClick()" style="padding: 10px 30px;">服务门户</el-button>
|
|
3
|
+
</template>
|
|
4
|
+
<script>
|
|
5
|
+
export default {
|
|
6
|
+
name: 'PortalBtn',
|
|
7
|
+
data () {
|
|
8
|
+
return {
|
|
9
|
+
}
|
|
10
|
+
},
|
|
11
|
+
methods: {
|
|
12
|
+
// 跳转至共享交换portal首页
|
|
13
|
+
handleClick () {
|
|
14
|
+
location.href = '/admin-ui/data-share-portal/homePage'
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
</script>
|
|
19
|
+
<style>
|
|
20
|
+
.el-button {
|
|
21
|
+
background: transparent !important;
|
|
22
|
+
}
|
|
23
|
+
</style>
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<el-dropdown @command="handleCommand">
|
|
3
|
+
<span class="el-dropdown-link">
|
|
4
|
+
{{tenantName}}<i class="el-icon-arrow-down el-icon--right"></i>
|
|
5
|
+
</span>
|
|
6
|
+
<el-dropdown-menu slot="dropdown">
|
|
7
|
+
<el-dropdown-item :command="item.id" v-for="item in options" :key="item.value">{{item.name}}</el-dropdown-item>
|
|
8
|
+
</el-dropdown-menu>
|
|
9
|
+
</el-dropdown>
|
|
10
|
+
</template>
|
|
11
|
+
<script>
|
|
12
|
+
import { getTenantList, changeTenantId } from './service.js'
|
|
13
|
+
export default {
|
|
14
|
+
name: 'TenantList',
|
|
15
|
+
data () {
|
|
16
|
+
return {
|
|
17
|
+
options: [],
|
|
18
|
+
tenantName: ''
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
created () {
|
|
22
|
+
// 每次都获取最新的租户列表
|
|
23
|
+
getTenantList().then((res) => {
|
|
24
|
+
console.log('租户列表:', res)
|
|
25
|
+
const rspObj = res.data
|
|
26
|
+
if (rspObj.code === 0) {
|
|
27
|
+
this.options = [...rspObj.data]
|
|
28
|
+
const tenantId = localStorage.getItem('curTenantId')
|
|
29
|
+
// 判断是否存在租户id
|
|
30
|
+
if (tenantId) {
|
|
31
|
+
this.tenantName = this.options.find(item => item.id + '' === tenantId).name
|
|
32
|
+
} else {
|
|
33
|
+
if (this.options.length > 0) {
|
|
34
|
+
this.tenantName = this.options[0].name
|
|
35
|
+
localStorage.setItem('curTenantId', this.options[0].id)
|
|
36
|
+
} else {
|
|
37
|
+
this.tenantName = ''
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
})
|
|
42
|
+
},
|
|
43
|
+
methods: {
|
|
44
|
+
handleCommand (value) {
|
|
45
|
+
const obj = {
|
|
46
|
+
id: value,
|
|
47
|
+
token: localStorage.getItem('ACCESS_TOKEN')
|
|
48
|
+
}
|
|
49
|
+
// 切换租户通知后台
|
|
50
|
+
changeTenantId(obj).then(() => {
|
|
51
|
+
localStorage.setItem('curTenantId', value)
|
|
52
|
+
this.tenantName = this.options.find(item => item.id === value).name
|
|
53
|
+
})
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
</script>
|
|
58
|
+
<style scoped>
|
|
59
|
+
/deep/.el-input__inner{
|
|
60
|
+
height: 35px;
|
|
61
|
+
line-height: 30px;
|
|
62
|
+
}
|
|
63
|
+
</style>
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import request from 'axios'
|
|
2
|
+
// 获取租户列表
|
|
3
|
+
export const getTenantList = () => {
|
|
4
|
+
return request({
|
|
5
|
+
url: '/admin-api/system/user/getUserTenant',
|
|
6
|
+
method: 'get'
|
|
7
|
+
})
|
|
8
|
+
}
|
|
9
|
+
// 更改后台租户id
|
|
10
|
+
export const changeTenantId = (params) => {
|
|
11
|
+
return request({
|
|
12
|
+
url: `/admin-api/system/auth/setRedisTokenOfTenant?tenantId=${params.id}&token=${params.token}`,
|
|
13
|
+
method: 'get'
|
|
14
|
+
})
|
|
15
|
+
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div className="right">
|
|
3
|
-
<el-dropdown v-if="
|
|
3
|
+
<el-dropdown v-if="getName()" @command="handleClickmenu">
|
|
4
4
|
<span class="el-dropdown-link">
|
|
5
5
|
<img src="../../assets/userLogo.svg" style="vertical-align:middle;padding-right:10px"/>
|
|
6
|
-
<span style="color: rgba(0, 0, 0, 0.85);">{{
|
|
6
|
+
<span style="color: rgba(0, 0, 0, 0.85);">{{getName()}}</span>
|
|
7
7
|
<i class="el-icon-arrow-down el-icon--right"></i>
|
|
8
8
|
</span>
|
|
9
9
|
<el-dropdown-menu slot="dropdown">
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
<img :src="PersonalCenterSrc" alt="" class="menuItem" />
|
|
12
12
|
<span>个人中心</span>
|
|
13
13
|
</el-dropdown-item>
|
|
14
|
-
<el-dropdown-item v-show="
|
|
14
|
+
<el-dropdown-item v-show="isShowSys" command="systerm">
|
|
15
15
|
<img :src="SystemManageSrc" alt="" class="menuItem" />
|
|
16
16
|
<span>系统管理</span>
|
|
17
17
|
</el-dropdown-item>
|
|
@@ -21,13 +21,12 @@
|
|
|
21
21
|
</el-dropdown-item>
|
|
22
22
|
</el-dropdown-menu>
|
|
23
23
|
</el-dropdown>
|
|
24
|
-
<v-loading v-else size="small" :style="{ marginLeft: '8px', marginRight: '8px', lineHeight: '57px', textAlign: 'center' }" />
|
|
25
24
|
</div>
|
|
26
25
|
</template>
|
|
27
|
-
|
|
28
|
-
<script >
|
|
26
|
+
<script>
|
|
29
27
|
import Axios from '../Util/axios.js'
|
|
30
|
-
import {userMenuIcon} from './constant.js'
|
|
28
|
+
import { userMenuIcon } from './constant.js'
|
|
29
|
+
import { getUserName } from './../Util/userInfo.js'
|
|
31
30
|
export default {
|
|
32
31
|
name: 'UserInfo',
|
|
33
32
|
data () {
|
|
@@ -39,43 +38,49 @@ export default {
|
|
|
39
38
|
LogoutSrc: userMenuIcon.LogoutSrc,
|
|
40
39
|
}
|
|
41
40
|
},
|
|
41
|
+
computed: {
|
|
42
|
+
// 是否显示系统管理菜单项
|
|
43
|
+
isShowSys () {
|
|
44
|
+
return this.stash === "integration" ? true : this.sysName !== 'admin' && this.isHaveSystemManagementPermission
|
|
45
|
+
}
|
|
46
|
+
},
|
|
42
47
|
props: {
|
|
43
|
-
|
|
48
|
+
sysName: {
|
|
44
49
|
type: String,
|
|
45
50
|
default: 'admin'
|
|
46
51
|
},
|
|
52
|
+
stash: {
|
|
53
|
+
type: String,
|
|
54
|
+
default: ''
|
|
55
|
+
}
|
|
47
56
|
},
|
|
48
57
|
methods: {
|
|
49
58
|
handleClickmenu (flag){
|
|
50
59
|
let url = ''
|
|
51
60
|
if (flag === 'single') {
|
|
52
|
-
url = '/#/info/index'
|
|
61
|
+
url = this.stash === "integration" ? '/admin-ui/user/profile' : '/#/info/index'
|
|
53
62
|
} else if (flag === 'systerm') {
|
|
54
|
-
url = '/#/admin/user/index'
|
|
63
|
+
url = this.stash === "integration" ? '/admin-ui/bpm/manager/user-group' : '/#/admin/user/index'
|
|
55
64
|
} else if (flag === 'logout') {
|
|
56
65
|
this.logoutFunc()
|
|
57
66
|
}
|
|
58
|
-
|
|
67
|
+
location.href = url;
|
|
59
68
|
},
|
|
60
69
|
logoutFunc () {
|
|
61
70
|
console.log('开始调用退出接口...')
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
71
|
+
const url = this.stash === 'integration' ? '/admin-api/system/auth/logout' : '/auth/token/logout'
|
|
72
|
+
const method = this.stash === 'integration'? 'post' : 'delete'
|
|
73
|
+
Axios(url, method).then(() => {
|
|
74
|
+
localStorage.clear();
|
|
75
|
+
sessionStorage.clear();
|
|
76
|
+
location.href = this.stash === "integration" ? '/admin-ui/login' : '/#/login'
|
|
77
|
+
})
|
|
78
|
+
.catch((err) => {
|
|
79
|
+
console.log('err: ', err)
|
|
80
|
+
});
|
|
72
81
|
},
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
if (userInfo && userInfo.content && Object.keys(userInfo.content).length > 0 && userInfo.content.username) {
|
|
76
|
-
return userInfo.content.username;
|
|
77
|
-
}
|
|
78
|
-
return '';
|
|
82
|
+
getName () {
|
|
83
|
+
return getUserName()
|
|
79
84
|
},
|
|
80
85
|
}
|
|
81
86
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import axios from 'axios';
|
|
2
2
|
import getStore from './userInfo';
|
|
3
3
|
import { checkToken } from './permessionUtils';
|
|
4
|
-
let tokenValue = '
|
|
4
|
+
let tokenValue = '64d4c0cf1f334e4fa755780976cdbada';
|
|
5
5
|
axios.interceptors.response.use(
|
|
6
6
|
(response) => {
|
|
7
7
|
if (response.status === 200) {
|
|
@@ -70,9 +70,12 @@ axios.interceptors.request.use(
|
|
|
70
70
|
},
|
|
71
71
|
);
|
|
72
72
|
|
|
73
|
-
function Axios(url) {
|
|
73
|
+
function Axios(url, method) {
|
|
74
74
|
return new Promise((resolve, reject) => {
|
|
75
|
-
|
|
75
|
+
axios({
|
|
76
|
+
method: method,
|
|
77
|
+
url: url,
|
|
78
|
+
})
|
|
76
79
|
.then((res) => {
|
|
77
80
|
console.log('res', res)
|
|
78
81
|
resolve(res);
|
|
@@ -1,21 +1,6 @@
|
|
|
1
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
|
-
}
|
|
2
|
+
const token = localStorage.getItem('ACCESS_TOKEN')
|
|
3
|
+
const DEFAULT_LOGOUT_URL = token ? '/admin-ui/login' : '/#/login'
|
|
19
4
|
// 校验token是否失效
|
|
20
5
|
export const checkToken = (token) => {
|
|
21
6
|
Axios('get',`/auth/oauth/check_token?token=${token}`, '', {} )
|
|
@@ -23,7 +8,7 @@ export const checkToken = (token) => {
|
|
|
23
8
|
this.$message.error({content:'用户凭证已过期,请重新登录', onClose: ()=>{
|
|
24
9
|
localStorage.clear();
|
|
25
10
|
sessionStorage.clear();
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
11
|
+
location.href = DEFAULT_LOGOUT_URL;
|
|
12
|
+
}});
|
|
13
|
+
})
|
|
29
14
|
}
|
|
@@ -2,49 +2,87 @@
|
|
|
2
2
|
* 获取认证相关的localStorage/SessionStorage
|
|
3
3
|
*/
|
|
4
4
|
function getStore(params) {
|
|
5
|
-
let { name } = params;
|
|
6
|
-
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
5
|
+
let { name, debug } = params;
|
|
6
|
+
// 使用 ACCESS_TOKEN 判断是否是一体化
|
|
7
|
+
const token = localStorage.getItem('ACCESS_TOKEN')
|
|
8
|
+
if (token) {
|
|
9
|
+
let storageStr = '';
|
|
10
|
+
if (name === 'access_token') {
|
|
11
|
+
storageStr = localStorage.getItem('ACCESS_TOKEN');
|
|
12
|
+
} else if (name === 'tenantId') {
|
|
13
|
+
// 暂定当前租户 curTenantId
|
|
14
|
+
storageStr = localStorage.getItem('curTenantId');
|
|
15
|
+
} else if (name === 'userName') {
|
|
16
|
+
// 获取当前登录用户名称
|
|
17
|
+
storageStr = localStorage.getItem('userName');
|
|
18
|
+
} else if (name === 'userId') {
|
|
19
|
+
// 获取当前登录用户Id
|
|
20
|
+
storageStr = localStorage.getItem('userId');
|
|
21
|
+
}
|
|
22
|
+
return storageStr;
|
|
23
|
+
} else {
|
|
24
|
+
const keyName = 'bigdata-';
|
|
25
|
+
name = keyName + name;
|
|
26
|
+
let obj = {};
|
|
27
|
+
let content;
|
|
28
|
+
obj = sessionStorage.getItem(name);
|
|
29
|
+
if (!obj || Object.keys(obj).length === 0) obj = localStorage.getItem(name);
|
|
30
|
+
if (!obj || Object.keys(obj).length === 0) return '';
|
|
31
|
+
try {
|
|
32
|
+
obj = JSON.parse(obj);
|
|
33
|
+
} catch (e) {
|
|
34
|
+
return '';
|
|
35
|
+
}
|
|
36
|
+
if (debug) {
|
|
37
|
+
return '';
|
|
38
|
+
}
|
|
39
|
+
if (obj.dataType === 'string') {
|
|
40
|
+
content = obj.content;
|
|
41
|
+
} else if (obj.dataType === 'number') {
|
|
42
|
+
content = Number(obj.content);
|
|
43
|
+
} else if (obj.dataType === 'boolean') {
|
|
44
|
+
// eslint-disable-next-line no-eval
|
|
45
|
+
content = eval(obj.content);
|
|
46
|
+
} else if (obj.dataType === 'object') {
|
|
47
|
+
content = obj.content;
|
|
48
|
+
}
|
|
49
|
+
return content;
|
|
31
50
|
}
|
|
32
|
-
return content;
|
|
33
51
|
}
|
|
34
52
|
export default getStore;
|
|
35
53
|
|
|
36
54
|
export const getUserName = () => {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
55
|
+
// 使用 ACCESS_TOKEN 判断是否是一体化
|
|
56
|
+
const token = localStorage.getItem('ACCESS_TOKEN')
|
|
57
|
+
if (token) {
|
|
58
|
+
const name = getStore({ name: 'userName' });
|
|
59
|
+
if (!name) {
|
|
60
|
+
return '';
|
|
61
|
+
}
|
|
62
|
+
return name;
|
|
63
|
+
} else {
|
|
64
|
+
const userInfo = getStore({ name: 'userInfo' });
|
|
65
|
+
if (userInfo && Object.keys(userInfo).length > 0 && userInfo.username) {
|
|
66
|
+
return userInfo.username;
|
|
67
|
+
}
|
|
68
|
+
return '';
|
|
40
69
|
}
|
|
41
|
-
return '';
|
|
42
70
|
};
|
|
43
71
|
|
|
44
72
|
export const getUserId = () => {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
73
|
+
// 使用 ACCESS_TOKEN 判断是否是一体化
|
|
74
|
+
const token = localStorage.getItem('ACCESS_TOKEN')
|
|
75
|
+
if (token) {
|
|
76
|
+
const id = getStore({ name: 'userId' });
|
|
77
|
+
if (!id) {
|
|
78
|
+
return '';
|
|
79
|
+
}
|
|
80
|
+
return id;
|
|
81
|
+
} else {
|
|
82
|
+
const userInfo = getStore({ name: 'userInfo' });
|
|
83
|
+
if (userInfo && Object.keys(userInfo).length > 0 && userInfo.id) {
|
|
84
|
+
return userInfo.id;
|
|
85
|
+
}
|
|
86
|
+
return '';
|
|
48
87
|
}
|
|
49
|
-
return '';
|
|
50
88
|
};
|
package/src/main.js
CHANGED
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
import Vue from 'vue'
|
|
2
|
-
import App from './App.vue'
|
|
3
2
|
import ElementUI from 'element-ui';
|
|
3
|
+
import App from './App.vue'
|
|
4
4
|
import 'element-ui/lib/theme-chalk/index.css';
|
|
5
5
|
|
|
6
|
-
|
|
7
6
|
Vue.config.productionTip = false
|
|
8
7
|
Vue.use(ElementUI);
|
|
9
8
|
|
|
10
|
-
|
|
11
9
|
new Vue({
|
|
12
10
|
render: h => h(App),
|
|
13
11
|
}).$mount('#app')
|
package/vue.config.js
CHANGED
|
@@ -1,4 +1,38 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
/**npm
|
|
2
|
+
* 配置参考:
|
|
3
|
+
* https://cli.vuejs.org/zh/config/
|
|
4
|
+
*/
|
|
5
|
+
const url = 'http://10.136.106.131:30097'
|
|
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
|
+
// 配置转发代理
|
|
16
|
+
devServer: {
|
|
17
|
+
// disableHostCheck: true,
|
|
18
|
+
port: 8080,
|
|
19
|
+
proxy: {
|
|
20
|
+
"/": {
|
|
21
|
+
// target:' https://10.136.106.82:30011',
|
|
22
|
+
target: url,
|
|
23
|
+
ws: false, // 需要websocket 开启
|
|
24
|
+
// changOrigin: true, //允许跨域
|
|
25
|
+
pathRewrite: {
|
|
26
|
+
"^/": "/",
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
'/admin-api': {
|
|
30
|
+
target: 'http://10.136.106.131:30097',
|
|
31
|
+
changeOrigin: true,
|
|
32
|
+
pathRewrite: { '^': '' },
|
|
33
|
+
}
|
|
34
|
+
// 3.5 以后不需要再配置
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
};
|
|
38
|
+
|