imatrix-ui 2.9.35-dw → 2.9.37-dw
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
package/src/permission.js
CHANGED
|
@@ -10,8 +10,8 @@ import Vue from 'vue'
|
|
|
10
10
|
const whiteList = ['/login', '/update-password', '/forget-password', '/reset-password', '/redirect'] // 不重定向白名单
|
|
11
11
|
router.beforeEach((to, from, next) => {
|
|
12
12
|
NProgress.start()
|
|
13
|
-
console.log('router.beforeEach-to=', to)
|
|
14
|
-
console.log('router.beforeEach-from=', from)
|
|
13
|
+
// console.log('router.beforeEach-to=', to)
|
|
14
|
+
// console.log('router.beforeEach-from=', from)
|
|
15
15
|
// console.log('router.beforeEach-to.path=', to.path)
|
|
16
16
|
let token = getToken()
|
|
17
17
|
// console.log('router.beforeEach-to.query.JWT=', to.query.JWT)
|
|
@@ -43,17 +43,17 @@ router.beforeEach((to, from, next) => {
|
|
|
43
43
|
} else {
|
|
44
44
|
isNeedMenu = true
|
|
45
45
|
}
|
|
46
|
-
console.log('iMatrix-router.beforeEach2-isNeedMenu==', isNeedMenu)
|
|
46
|
+
// console.log('iMatrix-router.beforeEach2-isNeedMenu==', isNeedMenu)
|
|
47
47
|
// console.log('router.beforeEach-getToken()=', token)
|
|
48
48
|
if ((['/update-password', '/forget-password', '/reset-password', '/redirect'].indexOf(to.path) === -1 || store.getters.whiteList.indexOf(to.path) !== -1) && token) {
|
|
49
49
|
if (to.path === '/login') {
|
|
50
50
|
next({ path: '/', query: to.query })
|
|
51
51
|
NProgress.done() // if current page is dashboard will not trigger afterEach hook, so manually handle it
|
|
52
52
|
} else {
|
|
53
|
-
console.log('router.beforeEach-to.path!=login')
|
|
53
|
+
// console.log('router.beforeEach-to.path!=login')
|
|
54
54
|
if (store.getters.name === '') {
|
|
55
55
|
// 表示刷新了页面(例如点击了一级菜单)后,会重新走该方法
|
|
56
|
-
console.log('router.beforeEach-store.getters.name === ""')
|
|
56
|
+
// console.log('router.beforeEach-store.getters.name === ""')
|
|
57
57
|
store.dispatch('isLoginTimeOut').then((result) => {
|
|
58
58
|
if (result === true) {
|
|
59
59
|
store.dispatch('clearToken').then(() => {
|
|
@@ -62,15 +62,15 @@ router.beforeEach((to, from, next) => {
|
|
|
62
62
|
})
|
|
63
63
|
} else {
|
|
64
64
|
store.dispatch('getCurrentUser').then(user => {
|
|
65
|
-
console.log('router.beforeEach-getCurrentUser')
|
|
65
|
+
// console.log('router.beforeEach-getCurrentUser')
|
|
66
66
|
return store.dispatch('getCurrentUserPermissions', user.loginName)
|
|
67
67
|
}).then(permissions => {
|
|
68
|
-
console.log('router.beforeEach-getCurrentUserPermissions-result==')
|
|
68
|
+
// console.log('router.beforeEach-getCurrentUserPermissions-result==')
|
|
69
69
|
return store.dispatch('generateRoutes', permissions)
|
|
70
70
|
}).then(() => {
|
|
71
71
|
if (isNeedMenu) {
|
|
72
72
|
// 需要显示左侧菜单
|
|
73
|
-
console.log('iMatrix-router.beforeEach2-getPermissionMenus')
|
|
73
|
+
// console.log('iMatrix-router.beforeEach2-getPermissionMenus')
|
|
74
74
|
return store.dispatch('getPermissionMenus', Vue.prototype.currentSystem)
|
|
75
75
|
} else {
|
|
76
76
|
return new Promise((resolve, reject) => {
|
|
@@ -79,12 +79,12 @@ router.beforeEach((to, from, next) => {
|
|
|
79
79
|
}
|
|
80
80
|
}).then(() => {
|
|
81
81
|
// 根据roles权限生成可访问的路由表
|
|
82
|
-
console.log('router.beforeEach-generateRoutes==to=', to, ',from=', from)
|
|
82
|
+
// console.log('router.beforeEach-generateRoutes==to=', to, ',from=', from)
|
|
83
83
|
router.addRoutes(store.getters.protectedRouters) // 动态添加可访问路由表
|
|
84
84
|
// 404等错误路由一定要放到受权限保护的路由之后
|
|
85
85
|
router.addRoutes(errorRouterMap)
|
|
86
86
|
// sessionStorage.setItem(new Date().getTime() + '-name=null-from~~toPath', from.path + '~~' + to.path)
|
|
87
|
-
console.log('router.beforeEach-generateRoutes==to.path=', to.path)
|
|
87
|
+
// console.log('router.beforeEach-generateRoutes==to.path=', to.path)
|
|
88
88
|
next({ ...to, replace: true })
|
|
89
89
|
}).catch((err) => {
|
|
90
90
|
store.dispatch('clearToken').then(() => {
|
|
@@ -101,14 +101,14 @@ router.beforeEach((to, from, next) => {
|
|
|
101
101
|
})
|
|
102
102
|
} else {
|
|
103
103
|
// sessionStorage.setItem(new Date().getTime() + '-name!==null-from~~toPath', from.path + '~~' + to.path)
|
|
104
|
-
console.log('router.beforeEach-store.getters.name ==', store.getters.name)
|
|
104
|
+
// console.log('router.beforeEach-store.getters.name ==', store.getters.name)
|
|
105
105
|
if (isNeedMenu) {
|
|
106
106
|
// 需要显示左侧菜单
|
|
107
107
|
let systemCode = Vue.prototype.currentSystem
|
|
108
108
|
if (!systemCode && to.query && to.query.customSystem) {
|
|
109
109
|
systemCode = to.query.customSystem
|
|
110
110
|
}
|
|
111
|
-
console.log('iMatrix-router.beforeEach33-getPermissionMenus,Vue.prototype.currentSystem=', Vue.prototype.currentSystem, 'systemCode=', systemCode)
|
|
111
|
+
// console.log('iMatrix-router.beforeEach33-getPermissionMenus,Vue.prototype.currentSystem=', Vue.prototype.currentSystem, 'systemCode=', systemCode)
|
|
112
112
|
return store.dispatch('getPermissionMenus', systemCode).then(() => {
|
|
113
113
|
next()
|
|
114
114
|
})
|
package/src/utils/request.js
CHANGED
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
import store from '../store'
|
|
10
10
|
import checkPermission from './permission'
|
|
11
11
|
import Vue from 'vue'
|
|
12
|
+
import { h } from 'vue'
|
|
12
13
|
import {
|
|
13
14
|
getI18n
|
|
14
15
|
} from './util'
|
|
@@ -83,13 +84,41 @@ service.interceptors.response.use(
|
|
|
83
84
|
}
|
|
84
85
|
} else if (error.response.status === 403) {
|
|
85
86
|
// ForbiddenException(403) 403没权限
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
87
|
+
let message = getI18n().t('imatrixUIMessage.forbiddenException')
|
|
88
|
+
let vnode
|
|
89
|
+
if (Vue.prototype.forbiddenUser || Vue.prototype.forbiddenLinkUrl) {
|
|
90
|
+
if (Vue.prototype.forbiddenUser) {
|
|
91
|
+
message = message + '.' + Vue.prototype.forbiddenUser + '.'
|
|
92
|
+
}
|
|
93
|
+
if (Vue.prototype.forbiddenLinkUrl) {
|
|
94
|
+
vnode = h('p', null, [
|
|
95
|
+
h('span', null, message),
|
|
96
|
+
h('a', {
|
|
97
|
+
style: 'color: #409EFF',
|
|
98
|
+
href: '#',
|
|
99
|
+
on: {
|
|
100
|
+
click: (event) => {
|
|
101
|
+
window.open(Vue.prototype.forbiddenLinkUrl)
|
|
102
|
+
}
|
|
103
|
+
}}, Vue.prototype.forbiddenLinkUrl)
|
|
104
|
+
])
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
if (vnode) {
|
|
108
|
+
Message({
|
|
109
|
+
showClose: true,
|
|
110
|
+
message: vnode,
|
|
111
|
+
type: 'error',
|
|
112
|
+
duration: 10 * 1000
|
|
113
|
+
})
|
|
114
|
+
} else {
|
|
115
|
+
Message({
|
|
116
|
+
showClose: true,
|
|
117
|
+
message: message,
|
|
118
|
+
type: 'error',
|
|
119
|
+
duration: 5 * 1000
|
|
120
|
+
})
|
|
121
|
+
}
|
|
93
122
|
return Promise.reject(error)
|
|
94
123
|
} else if (error.response.status === 400 || error.response.status === 406 || error.response.status === 404) {
|
|
95
124
|
// BadRequestException(400) || BusinessException(406) || ResourceNotFoundException(404)
|
|
@@ -86,11 +86,23 @@ export default {
|
|
|
86
86
|
let src
|
|
87
87
|
let params = ''
|
|
88
88
|
if (tag.routeQuery) {
|
|
89
|
+
const orgParams = []
|
|
90
|
+
const orgPath = tag.routeQuery['src']
|
|
91
|
+
if (orgPath && orgPath.indexOf('?') > 0) {
|
|
92
|
+
const orgParamsStr = orgPath.substring(orgPath.indexOf('?') + 1)
|
|
93
|
+
const orgParamsArr = orgParamsStr.split('&')
|
|
94
|
+
orgParamsArr.forEach(item => {
|
|
95
|
+
orgParams.push(item.substring(0, item.indexOf('=')))
|
|
96
|
+
})
|
|
97
|
+
}
|
|
89
98
|
for (const key in tag.routeQuery) {
|
|
90
99
|
if (key === 'src') {
|
|
91
100
|
src = tag.routeQuery[key]
|
|
92
101
|
} else {
|
|
93
|
-
|
|
102
|
+
if (orgParams.indexOf(key) < 0) {
|
|
103
|
+
// 表示原参数中没有该参数,则拼接该参数
|
|
104
|
+
params += key + '=' + tag.routeQuery[key] + '&'
|
|
105
|
+
}
|
|
94
106
|
}
|
|
95
107
|
}
|
|
96
108
|
}
|