imatrix-ui 2.8.97-dw-tmp4 → 2.8.97-dw-tmp5
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/lib/super-ui.css +1 -1
- package/lib/super-ui.umd.min.js +35 -5
- package/package.json +4 -2
- package/src/i18n/i18n.js +1 -1
- package/src/i18n/langs/cn.js +1 -1
- package/src/i18n/langs/en.js +1 -1
- package/src/permission.js +1 -1
- package/src/permission111.js +105 -0
- package/src/plugins.js +3 -3
- package/src/store/modules/permission.js +3 -3
- package/src/utils/permissionAuth.js +2 -2
- package/src/utils/request.js +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "imatrix-ui",
|
|
3
|
-
"version": "2.8.97-dw-
|
|
3
|
+
"version": "2.8.97-dw-tmp5",
|
|
4
4
|
"description": "前端组件库:表格、表单、组织结构树等",
|
|
5
5
|
"main": "lib/super-ui.umd.min.js",
|
|
6
6
|
"private": false,
|
|
@@ -30,11 +30,13 @@
|
|
|
30
30
|
"axios": "0.19.0",
|
|
31
31
|
"babel-cli": "^6.26.0",
|
|
32
32
|
"babel-eslint": "^10.0.1",
|
|
33
|
+
"babel-plugin-component": "^1.1.1",
|
|
33
34
|
"chai": "4.2.0",
|
|
35
|
+
"compression-webpack-plugin": "2.0.0",
|
|
34
36
|
"element-ui": "2.15.3",
|
|
35
37
|
"eslint": "5.16.0",
|
|
36
38
|
"eslint-plugin-vue": "5.2.2",
|
|
37
|
-
"node-sass": "4.
|
|
39
|
+
"node-sass": "4.14.0",
|
|
38
40
|
"nprogress": "^0.2.0",
|
|
39
41
|
"sass-loader": "^7.1.0",
|
|
40
42
|
"sessionstorage": "^0.1.0",
|
package/src/i18n/i18n.js
CHANGED
package/src/i18n/langs/cn.js
CHANGED
package/src/i18n/langs/en.js
CHANGED
package/src/permission.js
CHANGED
|
@@ -4,7 +4,7 @@ import { getToken, setToken } from './utils/auth' // 验权
|
|
|
4
4
|
import store from './store'
|
|
5
5
|
import router, { errorRouterMap } from './router'
|
|
6
6
|
NProgress.configure({ showSpinner: false })// NProgress Configuration
|
|
7
|
-
import { Message } from '
|
|
7
|
+
import { Message } from '@gcommon/gcommon-ui'
|
|
8
8
|
import Vue from 'vue'
|
|
9
9
|
|
|
10
10
|
const whiteList = ['/login', '/update-password', '/forget-password', '/reset-password', '/redirect'] // 不重定向白名单
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import NProgress from 'nprogress' // Progress 进度条
|
|
2
|
+
import 'nprogress/nprogress.css'// Progress 进度条样式
|
|
3
|
+
import { getToken, setToken } from './utils/auth' // 验权
|
|
4
|
+
import store from './store'
|
|
5
|
+
import router, { errorRouterMap } from './router'
|
|
6
|
+
NProgress.configure({ showSpinner: false })// NProgress Configuration
|
|
7
|
+
import { Message } from 'element-ui'
|
|
8
|
+
import Vue from 'vue'
|
|
9
|
+
|
|
10
|
+
const whiteList = ['/login', '/update-password', '/forget-password', '/reset-password', '/redirect'] // 不重定向白名单
|
|
11
|
+
router.beforeEach((to, from, next) => {
|
|
12
|
+
NProgress.start()
|
|
13
|
+
console.log('router.beforeEach-to=', to)
|
|
14
|
+
console.log('router.beforeEach-from=', from)
|
|
15
|
+
// console.log('router.beforeEach-to.path=', to.path)
|
|
16
|
+
let token = getToken()
|
|
17
|
+
// console.log('router.beforeEach-to.query.JWT=', to.query.JWT)
|
|
18
|
+
if (!token && to.query && to.query.JWT) {
|
|
19
|
+
token = to.query.JWT
|
|
20
|
+
if (token) {
|
|
21
|
+
// 微信小程序web-view直接访问路径时使用?将JWT传过来
|
|
22
|
+
setToken(token)
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
if (!token && to.query && to.query.jwt) {
|
|
26
|
+
token = to.query.jwt
|
|
27
|
+
if (token) {
|
|
28
|
+
// 微信小程序web-view直接访问路径时使用?将JWT传过来
|
|
29
|
+
setToken(token)
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
if (to.query && to.query._systemName_) {
|
|
33
|
+
// 表示需要设置浏览器页签名
|
|
34
|
+
document.title = to.query._systemName_
|
|
35
|
+
}
|
|
36
|
+
// console.log('router.beforeEach-getToken()=', token)
|
|
37
|
+
if ((['/update-password', '/forget-password', '/reset-password', '/redirect'].indexOf(to.path) === -1 || store.getters.whiteList.indexOf(to.path) !== -1) && token) {
|
|
38
|
+
if (to.path === '/login') {
|
|
39
|
+
next({ path: '/', query: to.query })
|
|
40
|
+
NProgress.done() // if current page is dashboard will not trigger afterEach hook, so manually handle it
|
|
41
|
+
} else {
|
|
42
|
+
console.log('router.beforeEach-to.path!=login')
|
|
43
|
+
if (store.getters.name === '') {
|
|
44
|
+
// 表示刷新了页面(例如点击了一级菜单)后,会重新走该方法
|
|
45
|
+
console.log('router.beforeEach-store.getters.name === ""')
|
|
46
|
+
store.dispatch('isLoginTimeOut').then((result) => {
|
|
47
|
+
if (result === true) {
|
|
48
|
+
store.dispatch('clearToken').then(() => {
|
|
49
|
+
next({ path: '/', replace: true })
|
|
50
|
+
NProgress.done()
|
|
51
|
+
})
|
|
52
|
+
} else {
|
|
53
|
+
store.dispatch('getCurrentUser').then(user => {
|
|
54
|
+
console.log('router.beforeEach-getCurrentUser')
|
|
55
|
+
return store.dispatch('getCurrentUserPermissions', user.loginName)
|
|
56
|
+
}).then(permissions => {
|
|
57
|
+
console.log('router.beforeEach-getCurrentUserPermissions-result==')
|
|
58
|
+
return store.dispatch('generateRoutes', permissions)
|
|
59
|
+
}).then(() => {
|
|
60
|
+
console.log('iMatrix-router.beforeEach2-getPermissionMenus')
|
|
61
|
+
return store.dispatch('getPermissionMenus', Vue.prototype.currentSystem)
|
|
62
|
+
}).then(() => {
|
|
63
|
+
// 根据roles权限生成可访问的路由表
|
|
64
|
+
console.log('router.beforeEach-generateRoutes==to=', to, ',from=', from)
|
|
65
|
+
router.addRoutes(store.getters.protectedRouters) // 动态添加可访问路由表
|
|
66
|
+
// 404等错误路由一定要放到受权限保护的路由之后
|
|
67
|
+
router.addRoutes(errorRouterMap)
|
|
68
|
+
sessionStorage.setItem(new Date().getTime() + '-name=null-from~~toPath', from.path + '~~' + to.path)
|
|
69
|
+
console.log('router.beforeEach-generateRoutes==to.path=', to.path)
|
|
70
|
+
next({ ...to, replace: true })
|
|
71
|
+
}).catch((err) => {
|
|
72
|
+
store.dispatch('clearToken').then(() => {
|
|
73
|
+
Message.error(err || 'Verification failed, please login again')
|
|
74
|
+
next({ path: '/' })
|
|
75
|
+
})
|
|
76
|
+
})
|
|
77
|
+
}
|
|
78
|
+
}).catch((err) => {
|
|
79
|
+
store.dispatch('clearToken').then(() => {
|
|
80
|
+
Message.error(err || 'Verification failed, please login again')
|
|
81
|
+
next({ path: '/' })
|
|
82
|
+
})
|
|
83
|
+
})
|
|
84
|
+
} else {
|
|
85
|
+
sessionStorage.setItem(new Date().getTime() + '-name!==null-from~~toPath', from.path + '~~' + to.path)
|
|
86
|
+
console.log('router.beforeEach-store.getters.name ==', store.getters.name)
|
|
87
|
+
next()
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
} else {
|
|
91
|
+
if (whiteList.indexOf(to.path) !== -1 || store.getters.whiteList.indexOf(to.path) !== -1) {
|
|
92
|
+
next()
|
|
93
|
+
} else {
|
|
94
|
+
// 必须使用to.fullPath,fullPath是带有参数的,to.path没有参数,会导致跳转到的页面参数丢失
|
|
95
|
+
next(`/login?redirect=${to.fullPath}`) // 否则全部重定向到登录页
|
|
96
|
+
NProgress.done()
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
const r2 = new Date().getTime()
|
|
100
|
+
console.log('路由导航所用时间', r2 - r1)
|
|
101
|
+
})
|
|
102
|
+
|
|
103
|
+
router.afterEach(() => {
|
|
104
|
+
NProgress.done() // 结束Progress
|
|
105
|
+
})
|
package/src/plugins.js
CHANGED
|
@@ -3,9 +3,9 @@ import Vue from 'vue'
|
|
|
3
3
|
import 'normalize.css/normalize.css' // A modern alternative to CSS resets
|
|
4
4
|
import './styles/index.scss' // global css
|
|
5
5
|
|
|
6
|
-
import ElementUI from '
|
|
7
|
-
import '
|
|
8
|
-
import locale from '
|
|
6
|
+
import ElementUI from '@gcommon/gcommon-ui'
|
|
7
|
+
import '@gcommon/gcommon-ui/lib/theme-chalk/index.css'
|
|
8
|
+
import locale from '@gcommon/gcommon-ui/lib/locale/lang/zh-CN' // lang i18n
|
|
9
9
|
|
|
10
10
|
import SuperUI from 'imatrix-ui'
|
|
11
11
|
import 'imatrix-ui/lib/super-ui.css'
|
|
@@ -89,7 +89,7 @@ const permission = {
|
|
|
89
89
|
const a = new Date().getTime()
|
|
90
90
|
const accessableRoutersResult = filterProtectedRouter(protectedRouterMap, currentUserPermissions)
|
|
91
91
|
const b = new Date().getTime()
|
|
92
|
-
sessionStorage.setItem('
|
|
92
|
+
sessionStorage.setItem('generateRoutes==>执行时间:', (b - a) + '')
|
|
93
93
|
const accessableRouters = accessableRoutersResult.allRouters
|
|
94
94
|
const allMenuRoutes = accessableRoutersResult.menuRouters
|
|
95
95
|
// console.log('有权限的路由表结果==', accessableRouters)
|
|
@@ -117,9 +117,9 @@ const permission = {
|
|
|
117
117
|
// console.log('更新后的有权限的路由表结果,更新了根路由跳转的地址==', accessableRouters)
|
|
118
118
|
}
|
|
119
119
|
}
|
|
120
|
-
const c = new Date().getTime()
|
|
121
|
-
sessionStorage.setItem('=====generateRoutes====>执行时间c-a=', (c-a)+'')
|
|
122
120
|
commit('setRouters', accessableRouters)
|
|
121
|
+
const c = new Date().getTime()
|
|
122
|
+
sessionStorage.setItem('generateRoutes==>执行时间c-a:', (c - a) + '')
|
|
123
123
|
resolve()
|
|
124
124
|
})
|
|
125
125
|
}
|
|
@@ -25,7 +25,7 @@ export function getPermissions() {
|
|
|
25
25
|
return JSON.parse(permissions)
|
|
26
26
|
}
|
|
27
27
|
const b = new Date().getTime()
|
|
28
|
-
sessionStorage.setItem('
|
|
28
|
+
sessionStorage.setItem('getPermissions==>执行时间:', (b - a) + '')
|
|
29
29
|
return null
|
|
30
30
|
}
|
|
31
31
|
|
|
@@ -39,7 +39,7 @@ export function setPermissions(permissions) {
|
|
|
39
39
|
}
|
|
40
40
|
sessionStorage.setItem(permissionKey + systemCode, JSON.stringify(permissionObjs))
|
|
41
41
|
const b = new Date().getTime()
|
|
42
|
-
sessionStorage.setItem('
|
|
42
|
+
sessionStorage.setItem('setPermissions==>执行时间:', (b - a) + '')
|
|
43
43
|
return permissionObjs
|
|
44
44
|
}
|
|
45
45
|
|