imatrix-ui 0.2.3-up → 0.2.5-up

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.
@@ -1,145 +1,145 @@
1
- import { protectedRouterMap } from '../../router'
2
-
3
- /**
4
- * 通过meta.role判断是否与当前用户权限匹配
5
- * @param roles
6
- * @param route
7
- */
8
- function hasPermission(currentUserPermissions, route) {
9
- let result = true
10
- const orgPermission = route.meta.permission
11
- if (orgPermission) {
12
- result = false
13
- const currentPermission = orgPermission.replace(/\./g, '__')
14
- const permissionResult = currentUserPermissions[currentPermission]
15
- if (permissionResult !== undefined && permissionResult === true) {
16
- result = true
17
- }
18
- }
19
- return result
20
- }
21
-
22
- /**
23
- * 递归过滤受权限保护的路由表,返回符合用户权限的路由表
24
- * @param allRoutes 即protectedRouterMap
25
- * @param currentUserPermissions 后台返回的当前用户具有的权限
26
- */
27
- function filterProtectedRouter(allRoutes, currentUserPermissions) {
28
- // console.log('filterProtectedRouter--', allRoutes)
29
- const res = []
30
- const menuRouters = []
31
-
32
- allRoutes.forEach((route) => {
33
- const tmp = { ...route }
34
-
35
- if (tmp.children && tmp.children.length > 0) {
36
- const routerResult = filterProtectedRouter(
37
- tmp.children,
38
- currentUserPermissions
39
- )
40
- // 所有有权限的路由,包括不是菜单的路由
41
- tmp.children = routerResult.allRouters
42
- // 所有菜单路由
43
- tmp.menuChildren = routerResult.menuRouters
44
- if (tmp.menuChildren && tmp.menuChildren.length > 0) {
45
- if (tmp.redirectTmp) {
46
- tmp.redirectTmp = tmp.redirectTmp + '/' + tmp.menuChildren[0].path
47
- } else {
48
- tmp.redirectTmp = tmp.path + '/' + tmp.menuChildren[0].path
49
- }
50
- res.push(tmp)
51
- menuRouters.push(tmp)
52
- }
53
- } else {
54
- if (tmp.path === '') {
55
- // 表示是空路由,即系统路由
56
- res.push(tmp)
57
- } else {
58
- if (hasPermission(currentUserPermissions, tmp)) {
59
- if (
60
- typeof tmp.hidden === 'undefined' ||
61
- (typeof tmp.hidden !== 'undefined' && tmp.hidden === false)
62
- ) {
63
- menuRouters.push(tmp)
64
- }
65
- res.push(tmp)
66
- }
67
- }
68
- }
69
- })
70
-
71
- return { allRouters: res, menuRouters: menuRouters }
72
- }
73
-
74
- const permission = {
75
- state: {
76
- // routers: publicRouterMap,
77
- protectedRouters: [],
78
- currentUserPermissions: [],
79
- },
80
- mutations: {
81
- setCurrentUserPermissions: (state, currentUserPermissions) => {
82
- state.currentUserPermissions = currentUserPermissions
83
- },
84
- setRouters: (state, routers) => {
85
- state.protectedRouters = routers
86
- // 把公共路由,用户有权限的路由,错误路由合并后就是当前用户的完整路由表
87
- // state.routers = publicRouterMap.concat(routers).concat(errorRouterMap)
88
- },
89
- },
90
- actions: {
91
- generateRoutes({ commit }, data) {
92
- return new Promise((resolve) => {
93
- const currentUserPermissions = data
94
- // commit('setCurrentUserPermissions', currentUserPermissions)
95
- const a = new Date().getTime()
96
- const accessableRoutersResult = filterProtectedRouter(
97
- protectedRouterMap,
98
- currentUserPermissions
99
- )
100
- const b = new Date().getTime()
101
- window.sessionStorage.setItem('generateRoutes==>执行时间:', b - a + '')
102
- const accessableRouters = accessableRoutersResult.allRouters
103
- const allMenuRoutes = accessableRoutersResult.menuRouters
104
- // console.log('有权限的路由表结果==', accessableRouters)
105
- // 动态添加空路由(即系统路由)
106
- if (accessableRouters.length > 0) {
107
- // 获得所有菜单路由
108
- // console.log('allMenuRoutes==', allMenuRoutes)
109
- const emptyPathRouter = {
110
- path: '',
111
- }
112
- if (allMenuRoutes.length > 0) {
113
- if (accessableRouters[0].path !== '') {
114
- // 表示不包含空路由,需要添加空路由
115
- if (allMenuRoutes[0].redirectTmp) {
116
- emptyPathRouter.redirect = allMenuRoutes[0].redirectTmp
117
- }
118
- accessableRouters.push(emptyPathRouter)
119
- } else if (
120
- allMenuRoutes.length > 0 &&
121
- accessableRouters[0].path === '' &&
122
- (!allMenuRoutes[0].children ||
123
- allMenuRoutes[0].children.length === 0)
124
- ) {
125
- // 表示自己配置了空路由,且没有子路由
126
- if (allMenuRoutes[0].redirectTmp) {
127
- accessableRouters[0].redirect = allMenuRoutes[0].redirectTmp
128
- }
129
- }
130
- // console.log('更新后的有权限的路由表结果,更新了根路由跳转的地址==', accessableRouters)
131
- }
132
- }
133
- commit('setRouters', accessableRouters)
134
- const c = new Date().getTime()
135
- window.sessionStorage.setItem(
136
- 'generateRoutes==>执行时间c-a:',
137
- c - a + ''
138
- )
139
- resolve()
140
- })
141
- },
142
- },
143
- }
144
-
145
- export default permission
1
+ import { protectedRouterMap } from '../../router'
2
+
3
+ /**
4
+ * 通过meta.role判断是否与当前用户权限匹配
5
+ * @param roles
6
+ * @param route
7
+ */
8
+ function hasPermission(currentUserPermissions, route) {
9
+ let result = true
10
+ const orgPermission = route.meta.permission
11
+ if (orgPermission) {
12
+ result = false
13
+ const currentPermission = orgPermission.replace(/\./g, '__')
14
+ const permissionResult = currentUserPermissions[currentPermission]
15
+ if (permissionResult !== undefined && permissionResult === true) {
16
+ result = true
17
+ }
18
+ }
19
+ return result
20
+ }
21
+
22
+ /**
23
+ * 递归过滤受权限保护的路由表,返回符合用户权限的路由表
24
+ * @param allRoutes 即protectedRouterMap
25
+ * @param currentUserPermissions 后台返回的当前用户具有的权限
26
+ */
27
+ function filterProtectedRouter(allRoutes, currentUserPermissions) {
28
+ // console.log('filterProtectedRouter--', allRoutes)
29
+ const res = []
30
+ const menuRouters = []
31
+
32
+ allRoutes.forEach((route) => {
33
+ const tmp = { ...route }
34
+
35
+ if (tmp.children && tmp.children.length > 0) {
36
+ const routerResult = filterProtectedRouter(
37
+ tmp.children,
38
+ currentUserPermissions
39
+ )
40
+ // 所有有权限的路由,包括不是菜单的路由
41
+ tmp.children = routerResult.allRouters
42
+ // 所有菜单路由
43
+ tmp.menuChildren = routerResult.menuRouters
44
+ if (tmp.menuChildren && tmp.menuChildren.length > 0) {
45
+ if (tmp.redirectTmp) {
46
+ tmp.redirectTmp = tmp.redirectTmp + '/' + tmp.menuChildren[0].path
47
+ } else {
48
+ tmp.redirectTmp = tmp.path + '/' + tmp.menuChildren[0].path
49
+ }
50
+ res.push(tmp)
51
+ menuRouters.push(tmp)
52
+ }
53
+ } else {
54
+ if (tmp.path === '') {
55
+ // 表示是空路由,即系统路由
56
+ res.push(tmp)
57
+ } else {
58
+ if (hasPermission(currentUserPermissions, tmp)) {
59
+ if (
60
+ typeof tmp.hidden === 'undefined' ||
61
+ (typeof tmp.hidden !== 'undefined' && tmp.hidden === false)
62
+ ) {
63
+ menuRouters.push(tmp)
64
+ }
65
+ res.push(tmp)
66
+ }
67
+ }
68
+ }
69
+ })
70
+
71
+ return { allRouters: res, menuRouters: menuRouters }
72
+ }
73
+
74
+ const permission = {
75
+ state: {
76
+ // routers: publicRouterMap,
77
+ protectedRouters: [],
78
+ currentUserPermissions: [],
79
+ },
80
+ mutations: {
81
+ setCurrentUserPermissions: (state, currentUserPermissions) => {
82
+ state.currentUserPermissions = currentUserPermissions
83
+ },
84
+ setRouters: (state, routers) => {
85
+ state.protectedRouters = routers
86
+ // 把公共路由,用户有权限的路由,错误路由合并后就是当前用户的完整路由表
87
+ // state.routers = publicRouterMap.concat(routers).concat(errorRouterMap)
88
+ },
89
+ },
90
+ actions: {
91
+ generateRoutes({ commit }, data) {
92
+ return new Promise((resolve) => {
93
+ const currentUserPermissions = data
94
+ // commit('setCurrentUserPermissions', currentUserPermissions)
95
+ const a = new Date().getTime()
96
+ const accessableRoutersResult = filterProtectedRouter(
97
+ protectedRouterMap,
98
+ currentUserPermissions
99
+ )
100
+ const b = new Date().getTime()
101
+ window.sessionStorage.setItem('generateRoutes==>执行时间:', b - a + '')
102
+ const accessableRouters = accessableRoutersResult.allRouters
103
+ const allMenuRoutes = accessableRoutersResult.menuRouters
104
+ // console.log('有权限的路由表结果==', accessableRouters)
105
+ // 动态添加空路由(即系统路由)
106
+ if (accessableRouters.length > 0) {
107
+ // 获得所有菜单路由
108
+ // console.log('allMenuRoutes==', allMenuRoutes)
109
+ const emptyPathRouter = {
110
+ path: '',
111
+ }
112
+ if (allMenuRoutes.length > 0) {
113
+ if (accessableRouters[0].path !== '') {
114
+ // 表示不包含空路由,需要添加空路由
115
+ if (allMenuRoutes[0].redirectTmp) {
116
+ emptyPathRouter.redirect = allMenuRoutes[0].redirectTmp
117
+ }
118
+ accessableRouters.push(emptyPathRouter)
119
+ } else if (
120
+ allMenuRoutes.length > 0 &&
121
+ accessableRouters[0].path === '' &&
122
+ (!allMenuRoutes[0].children ||
123
+ allMenuRoutes[0].children.length === 0)
124
+ ) {
125
+ // 表示自己配置了空路由,且没有子路由
126
+ if (allMenuRoutes[0].redirectTmp) {
127
+ accessableRouters[0].redirect = allMenuRoutes[0].redirectTmp
128
+ }
129
+ }
130
+ // console.log('更新后的有权限的路由表结果,更新了根路由跳转的地址==', accessableRouters)
131
+ }
132
+ }
133
+ commit('setRouters', accessableRouters)
134
+ const c = new Date().getTime()
135
+ window.sessionStorage.setItem(
136
+ 'generateRoutes==>执行时间c-a:',
137
+ c - a + ''
138
+ )
139
+ resolve()
140
+ })
141
+ },
142
+ },
143
+ }
144
+
145
+ export default permission
@@ -6,4 +6,10 @@
6
6
  background: $--button-opt-background-color;
7
7
  border-color: $--button-opt-background-color;
8
8
  }
9
+
10
+ .el-button--default {
11
+ border-radius: 4px;
12
+ border-color: $--color-primary;
13
+ color: $--color-primary;
14
+ }
9
15
  }
@@ -190,7 +190,8 @@
190
190
  }
191
191
 
192
192
  .el-pagination {
193
- text-align: right;
193
+ display: flex;
194
+ justify-content: flex-end;
194
195
  }
195
196
 
196
197
  .el-table td {
@@ -209,7 +210,7 @@
209
210
  /**表格内容纵向分隔线去掉**/
210
211
  .el-table--border td,
211
212
  .el-table--border th,
212
- .el-table__body-wrapper .el-table--border.is-scrolling-left~.el-table__fixed {
213
+ .el-table__body-wrapper .el-table--border.is-scrolling-left ~ .el-table__fixed {
213
214
  border-right: 0px
214
215
  }
215
216
 
@@ -217,7 +218,7 @@
217
218
  .el-table--border td,
218
219
  .el-table--border th,
219
220
  .el-table--border th.is-leaf,
220
- .el-table__body-wrapper .el-table--border.is-scrolling-left~.el-table__fixed {
221
+ .el-table__body-wrapper .el-table--border.is-scrolling-left ~ .el-table__fixed {
221
222
  border-right: 1px solid #fefefe;
222
223
  }
223
224
 
@@ -231,7 +232,7 @@
231
232
  text-align: left;
232
233
  }
233
234
 
234
- .el-button+.el-button {
235
+ .el-button + .el-button {
235
236
  margin-left: 10px;
236
237
  }
237
238
 
@@ -269,4 +270,4 @@
269
270
  border-radius: 0;
270
271
  box-shadow: 0 0px 0px #ccc;
271
272
  }
272
- }
273
+ }
@@ -11,4 +11,8 @@
11
11
  background-color: $--button-default-font-color;
12
12
  }
13
13
  }
14
+
15
+ .el-pagination.is-background .el-pager li.is-active {
16
+ background-color: $--button-default-font-color;
17
+ }
14
18
  }
@@ -1,159 +1,161 @@
1
- import * as Cookies from 'js-cookie'
2
- import * as Vue from 'vue'
3
-
4
- const jwtKey = 'JWT'
5
- const currentUserNameKey = 'USERNAME'
6
- const currentUserInfoKey = 'CURRENT_USER'
7
- const currentSystemUrlKey = 'CURRENT_SYSTEM_URL_'
8
-
9
- function getToken() {
10
- let token = getCookieCache(jwtKey)
11
- const projectModel = window.$vueApp.config.globalProperties.projectModel
12
- if (!token && projectModel && projectModel === 'developing.model') {
13
- // 如果是开发环境从window.sessionStorage中获得token
14
- token = getSessionCache(jwtKey)
15
- }
16
- return token
17
- }
18
-
19
- function setToken(token) {
20
- setCookieCache(jwtKey, token)
21
- setSessionCache(jwtKey, token)
22
- }
23
-
24
- function removeToken() {
25
- removeCookieCache(jwtKey)
26
- removeSessionCache(jwtKey)
27
- }
28
-
29
- function getUsername() {
30
- let username = getCookieCache(currentUserNameKey)
31
- if (!username) {
32
- username = getSessionCache(currentUserNameKey)
33
- }
34
- return username
35
- }
36
-
37
- function setUsername(username) {
38
- setSessionCache(currentUserNameKey, username)
39
- setCookieCache(currentUserNameKey, username)
40
- }
41
-
42
- function removeUsername() {
43
- removeSessionCache(currentUserNameKey)
44
- removeCookieCache(currentUserNameKey)
45
- }
46
-
47
- function getCurrentUser() {
48
- let userJson = getCookieCache(currentUserInfoKey)
49
- if (!userJson) {
50
- userJson = getSessionCache(currentUserInfoKey)
51
- }
52
- if (userJson) {
53
- return JSON.parse(userJson)
54
- }
55
- }
56
-
57
- function setCurrentUser(userInfo) {
58
- if (userInfo) {
59
- if (userInfo.password) {
60
- userInfo.password = null
61
- }
62
- const userinfoStr = JSON.stringify(userInfo)
63
- setSessionCache(currentUserInfoKey, userinfoStr)
64
- setCookieCache(currentUserInfoKey, userinfoStr)
65
- }
66
- }
67
-
68
- function removeCurrentUser() {
69
- removeSessionCache(currentUserInfoKey)
70
- removeCookieCache(currentUserInfoKey)
71
- }
72
-
73
- function getCookieCache(key) {
74
- return Cookies.get(key)
75
- }
76
-
77
- function setCookieCache(key, value) {
78
- Cookies.set(key, value, {
79
- path: '/',
80
- })
81
- }
82
-
83
- function removeCookieCache(key) {
84
- Cookies.remove(key, {
85
- path: '/',
86
- })
87
- }
88
-
89
- function getSessionCache(key) {
90
- return window.sessionStorage.getItem(key)
91
- }
92
-
93
- function setSessionCache(key, value) {
94
- return window.sessionStorage.setItem(key, value)
95
- }
96
-
97
- function removeSessionCache(key) {
98
- window.sessionStorage.removeItem(key)
99
- }
100
-
101
- function getSystemCacheUrlByCode(systemCode) {
102
- if (!systemCode) {
103
- systemCode = window.$vueApp.config.globalProperties.customSystem
104
- }
105
- if (!systemCode) {
106
- systemCode = window.$vueApp.config.globalProperties.systemCode
107
- }
108
- if (systemCode) {
109
- const systemUrls = getSystemCacheUrl()
110
- if (systemUrls) {
111
- return systemUrls[systemCode]
112
- }
113
- }
114
- }
115
-
116
- function getSystemCacheUrl() {
117
- let systemUrlJson = getCookieCache(currentSystemUrlKey)
118
- if (!systemUrlJson) {
119
- systemUrlJson = getSessionCache(currentSystemUrlKey)
120
- }
121
- if (systemUrlJson) {
122
- return JSON.parse(systemUrlJson)
123
- }
124
- }
125
-
126
- function setSystemCacheUrl(systemUrlObj) {
127
- if (systemUrlObj) {
128
- const systemUrlStr = JSON.stringify(systemUrlObj)
129
- setSessionCache(currentSystemUrlKey, systemUrlStr)
130
- setCookieCache(currentSystemUrlKey, systemUrlStr)
131
- }
132
- }
133
-
134
- function removeSystemCacheUrl() {
135
- removeSessionCache(currentSystemUrlKey)
136
- removeCookieCache(currentSystemUrlKey)
137
- }
138
-
139
- export default {
140
- getToken,
141
- setToken,
142
- removeToken,
143
- getUsername,
144
- setUsername,
145
- removeUsername,
146
- getCurrentUser,
147
- setCurrentUser,
148
- removeCurrentUser,
149
- getCookieCache,
150
- setCookieCache,
151
- removeCookieCache,
152
- getSessionCache,
153
- setSessionCache,
154
- removeSessionCache,
155
- getSystemCacheUrlByCode,
156
- getSystemCacheUrl,
157
- setSystemCacheUrl,
158
- removeSystemCacheUrl,
159
- }
1
+ import Cookies from 'js-cookie'
2
+ // const Cookies = require('js-cookie')
3
+
4
+ const jwtKey = 'JWT'
5
+ const currentUserNameKey = 'USERNAME'
6
+ const currentUserInfoKey = 'CURRENT_USER'
7
+ const currentSystemUrlKey = 'CURRENT_SYSTEM_URL_'
8
+
9
+ function getToken() {
10
+ let token = getCookieCache(jwtKey)
11
+ const projectModel = window.$vueApp.config.globalProperties.projectModel
12
+ if (!token && projectModel && projectModel === 'developing.model') {
13
+ // 如果是开发环境从window.sessionStorage中获得token
14
+ token = getSessionCache(jwtKey)
15
+ }
16
+ return token
17
+ }
18
+
19
+ function setToken(token) {
20
+ setCookieCache(jwtKey, token)
21
+ setSessionCache(jwtKey, token)
22
+ }
23
+
24
+ function removeToken() {
25
+ removeCookieCache(jwtKey)
26
+ removeSessionCache(jwtKey)
27
+ }
28
+
29
+ function getUsername() {
30
+ let username = getCookieCache(currentUserNameKey)
31
+ if (!username) {
32
+ username = getSessionCache(currentUserNameKey)
33
+ }
34
+ return username
35
+ }
36
+
37
+ function setUsername(username) {
38
+ setSessionCache(currentUserNameKey, username)
39
+ setCookieCache(currentUserNameKey, username)
40
+ }
41
+
42
+ function removeUsername() {
43
+ removeSessionCache(currentUserNameKey)
44
+ removeCookieCache(currentUserNameKey)
45
+ }
46
+
47
+ function getCurrentUser() {
48
+ let userJson = getCookieCache(currentUserInfoKey)
49
+ if (!userJson) {
50
+ userJson = getSessionCache(currentUserInfoKey)
51
+ }
52
+ if (userJson) {
53
+ return JSON.parse(userJson)
54
+ }
55
+ }
56
+
57
+ function setCurrentUser(userInfo) {
58
+ if (userInfo) {
59
+ if (userInfo.password) {
60
+ userInfo.password = null
61
+ }
62
+ const userinfoStr = JSON.stringify(userInfo)
63
+ setSessionCache(currentUserInfoKey, userinfoStr)
64
+ setCookieCache(currentUserInfoKey, userinfoStr)
65
+ }
66
+ }
67
+
68
+ function removeCurrentUser() {
69
+ removeSessionCache(currentUserInfoKey)
70
+ removeCookieCache(currentUserInfoKey)
71
+ }
72
+
73
+ function getCookieCache(key) {
74
+ console.log('%c描述-173122', 'color:#2E3435;background:#F8BB07;padding:3px;border-radius:2px', Cookies);
75
+ console.dir(Cookies);
76
+ return Cookies.get(key)
77
+ }
78
+
79
+ function setCookieCache(key, value) {
80
+ Cookies.set(key, value, {
81
+ path: '/',
82
+ })
83
+ }
84
+
85
+ function removeCookieCache(key) {
86
+ Cookies.remove(key, {
87
+ path: '/',
88
+ })
89
+ }
90
+
91
+ function getSessionCache(key) {
92
+ return window.sessionStorage.getItem(key)
93
+ }
94
+
95
+ function setSessionCache(key, value) {
96
+ return window.sessionStorage.setItem(key, value)
97
+ }
98
+
99
+ function removeSessionCache(key) {
100
+ window.sessionStorage.removeItem(key)
101
+ }
102
+
103
+ function getSystemCacheUrlByCode(systemCode) {
104
+ if (!systemCode) {
105
+ systemCode = window.$vueApp.config.globalProperties.customSystem
106
+ }
107
+ if (!systemCode) {
108
+ systemCode = window.$vueApp.config.globalProperties.systemCode
109
+ }
110
+ if (systemCode) {
111
+ const systemUrls = getSystemCacheUrl()
112
+ if (systemUrls) {
113
+ return systemUrls[systemCode]
114
+ }
115
+ }
116
+ }
117
+
118
+ function getSystemCacheUrl() {
119
+ let systemUrlJson = getCookieCache(currentSystemUrlKey)
120
+ if (!systemUrlJson) {
121
+ systemUrlJson = getSessionCache(currentSystemUrlKey)
122
+ }
123
+ if (systemUrlJson) {
124
+ return JSON.parse(systemUrlJson)
125
+ }
126
+ }
127
+
128
+ function setSystemCacheUrl(systemUrlObj) {
129
+ if (systemUrlObj) {
130
+ const systemUrlStr = JSON.stringify(systemUrlObj)
131
+ setSessionCache(currentSystemUrlKey, systemUrlStr)
132
+ setCookieCache(currentSystemUrlKey, systemUrlStr)
133
+ }
134
+ }
135
+
136
+ function removeSystemCacheUrl() {
137
+ removeSessionCache(currentSystemUrlKey)
138
+ removeCookieCache(currentSystemUrlKey)
139
+ }
140
+
141
+ export default {
142
+ getToken,
143
+ setToken,
144
+ removeToken,
145
+ getUsername,
146
+ setUsername,
147
+ removeUsername,
148
+ getCurrentUser,
149
+ setCurrentUser,
150
+ removeCurrentUser,
151
+ getCookieCache,
152
+ setCookieCache,
153
+ removeCookieCache,
154
+ getSessionCache,
155
+ setSessionCache,
156
+ removeSessionCache,
157
+ getSystemCacheUrlByCode,
158
+ getSystemCacheUrl,
159
+ setSystemCacheUrl,
160
+ removeSystemCacheUrl,
161
+ }