imatrix-ui 0.0.15 → 0.1.1-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.
Files changed (171) hide show
  1. package/.vscode/extensions.json +3 -0
  2. package/README.md +7 -0
  3. package/components/dynamic-source-select/dynamic-source-select-service.js +106 -0
  4. package/components/dynamic-source-select/dynamic-source-select.vue +673 -0
  5. package/components/dynamic-source-select/events.js +77 -0
  6. package/components/fs-preview/fs-preview.vue +287 -0
  7. package/components/index.js +26 -0
  8. package/components/plugins/export-data-new.js +623 -0
  9. package/components/plugins/export-data.js +431 -0
  10. package/components/plugins/index.js +15 -0
  11. package/components/plugins/public-method.js +47 -0
  12. package/components/rich-editor/index-bak.vue +306 -0
  13. package/components/rich-editor/index.vue +236 -0
  14. package/components/rich-editor/langs/zh-Hans.js +438 -0
  15. package/components/rich-editor/viewer.vue +105 -0
  16. package/components/super-grid/apis.js +1065 -0
  17. package/components/super-grid/columns-config.vue +430 -0
  18. package/components/super-grid/custom-formatter.js +330 -0
  19. package/components/super-grid/dynamic-input.vue +1706 -0
  20. package/components/super-grid/eventBus.js +2 -0
  21. package/components/super-grid/events.js +56 -0
  22. package/components/super-grid/formValidatorUtil.js +300 -0
  23. package/components/super-grid/formatter.js +190 -0
  24. package/components/super-grid/group-column.vue +100 -0
  25. package/components/super-grid/header-context-menu.vue +82 -0
  26. package/components/super-grid/index-column.vue +69 -0
  27. package/components/super-grid/normal-column.vue +1148 -0
  28. package/components/super-grid/public-methods.js +30 -0
  29. package/components/super-grid/row-operation.vue +193 -0
  30. package/components/super-grid/search-button.vue +74 -0
  31. package/components/super-grid/search-condition-input.vue +73 -0
  32. package/components/super-grid/search-condition-list.vue +68 -0
  33. package/components/super-grid/search-form-advancedQuery.vue +820 -0
  34. package/components/super-grid/search-form-dialog.vue +77 -0
  35. package/components/super-grid/search-form-item.vue +470 -0
  36. package/components/super-grid/search-form-number.vue +111 -0
  37. package/components/super-grid/search-form-open.vue +178 -0
  38. package/components/super-grid/search-form-ordinarySearch.vue +218 -0
  39. package/components/super-grid/search-form.vue +756 -0
  40. package/components/super-grid/search-methods.js +484 -0
  41. package/components/super-grid/selection-column.vue +46 -0
  42. package/components/super-grid/store.js +3 -0
  43. package/components/super-grid/super-grid-service.js +682 -0
  44. package/components/super-grid/super-grid.vue +2893 -0
  45. package/components/super-grid/utils.js +851 -0
  46. package/components/super-grid/view-image-dialog.vue +173 -0
  47. package/components/utils/gogocodeTransfer.js +59 -0
  48. package/components/utils/utils.js +180 -0
  49. package/components/utils/value-set.js +98 -0
  50. package/components/z-test-utton/index.vue +82 -0
  51. package/package.json +29 -40
  52. package/public/index.html +13 -0
  53. package/public/vite.svg +1 -0
  54. package/src/api/sso-service.js +172 -19
  55. package/src/api/tab.js +36 -0
  56. package/src/api/user-service.js +11 -11
  57. package/src/assets/401/401.gif +0 -0
  58. package/src/assets/404/404-cloud.png +0 -0
  59. package/src/assets/404/404.png +0 -0
  60. package/src/assets/cloud.png +0 -0
  61. package/src/directives/permission/index.js +13 -13
  62. package/src/directives/permission/permission.js +20 -15
  63. package/src/i18n/i18n.js +16 -0
  64. package/src/i18n/langs/cn.js +254 -0
  65. package/src/i18n/langs/en.js +264 -0
  66. package/src/permission.js +157 -71
  67. package/src/plugins.js +18 -18
  68. package/src/router/index.js +96 -69
  69. package/src/store/getters.js +15 -10
  70. package/src/store/index.js +19 -19
  71. package/src/store/modules/app.js +54 -42
  72. package/src/store/modules/permission.js +137 -73
  73. package/src/store/modules/tab-content.js +36 -0
  74. package/src/store/modules/user.js +293 -80
  75. package/src/styles/display-layout.scss +34 -0
  76. package/src/styles/element-ui.scss +29 -29
  77. package/src/styles/index.scss +157 -78
  78. package/src/styles/mixin.scss +27 -27
  79. package/src/styles/theme/black/font-style.scss +70 -0
  80. package/src/styles/theme/black/index.scss +306 -0
  81. package/src/styles/theme/black/sidebar.scss +189 -0
  82. package/src/styles/theme/blue/font-style.scss +46 -0
  83. package/src/styles/theme/blue/index.scss +172 -0
  84. package/src/styles/{sidebar.scss → theme/blue/sidebar.scss} +171 -141
  85. package/src/styles/theme/blue2/font-style.scss +70 -0
  86. package/src/styles/theme/blue2/index.scss +188 -0
  87. package/src/styles/theme/blue2/sidebar.scss +201 -0
  88. package/src/styles/theme/dark-blue/button.scss +9 -0
  89. package/src/styles/theme/dark-blue/card.scss +62 -0
  90. package/src/styles/theme/dark-blue/checkbox.scss +10 -0
  91. package/src/styles/theme/dark-blue/dark-blue-var.scss +8 -0
  92. package/src/styles/theme/dark-blue/dialog.scss +21 -0
  93. package/src/styles/theme/dark-blue/element-variables.scss +7 -0
  94. package/src/styles/theme/dark-blue/font.scss +71 -0
  95. package/src/styles/theme/dark-blue/form.scss +51 -0
  96. package/src/styles/theme/dark-blue/index.scss +269 -0
  97. package/src/styles/theme/dark-blue/input.scss +15 -0
  98. package/src/styles/theme/dark-blue/message.scss +8 -0
  99. package/src/styles/theme/dark-blue/pagination.scss +14 -0
  100. package/src/styles/theme/dark-blue/scrollbar-style.scss +32 -0
  101. package/src/styles/theme/dark-blue/sidebar.scss +266 -0
  102. package/src/styles/theme/dark-blue/tab.scss +83 -0
  103. package/src/styles/theme/dark-blue/table.scss +60 -0
  104. package/src/styles/theme/dark-blue/tree.scss +31 -0
  105. package/src/styles/theme/dark-blue/var.scss +1028 -0
  106. package/src/styles/theme/gray/card-style.scss +54 -0
  107. package/src/styles/theme/gray/font-style.scss +70 -0
  108. package/src/styles/theme/gray/index.scss +172 -0
  109. package/src/styles/theme/gray/input-style.scss +19 -0
  110. package/src/styles/theme/gray/scrollbar-style.scss +32 -0
  111. package/src/styles/theme/gray/sidebar.scss +231 -0
  112. package/src/styles/theme/gray/tab-style.scss +81 -0
  113. package/src/styles/transition.scss +47 -46
  114. package/src/utils/auth-api.js +159 -0
  115. package/src/utils/auth.js +61 -15
  116. package/src/utils/calculator/calculator-factory-wf.js +558 -0
  117. package/src/utils/calculator/calculator-factory.js +145 -0
  118. package/src/utils/calculator/calculator-util.js +166 -0
  119. package/src/utils/common-util.js +305 -0
  120. package/src/utils/eventBus.js +2 -0
  121. package/src/utils/iconUtils.js +28 -0
  122. package/src/utils/index.js +102 -86
  123. package/src/utils/jump-page-utils.js +814 -0
  124. package/src/utils/local-storage.js +33 -31
  125. package/src/utils/menu.js +19 -0
  126. package/src/utils/permission.js +31 -26
  127. package/src/utils/permissionAuth.js +90 -0
  128. package/src/utils/range-selector.js +188 -0
  129. package/src/utils/request.js +270 -116
  130. package/src/utils/restful-interface-utils.js +57 -0
  131. package/src/utils/util.js +698 -0
  132. package/src/utils/validate.js +34 -33
  133. package/src/utils/watermark.js +108 -0
  134. package/src/utils/workflow-util.js +93 -0
  135. package/src/views/404.vue +248 -228
  136. package/src/views/dsc-component/Sidebar/Item.vue +84 -0
  137. package/src/views/dsc-component/Sidebar/Link.vue +38 -0
  138. package/src/views/dsc-component/Sidebar/SidebarItem.vue +196 -0
  139. package/src/views/dsc-component/Sidebar/index.vue +220 -0
  140. package/src/views/dsc-component/tabs/tab-content.vue +199 -0
  141. package/src/views/error-page/401.vue +106 -91
  142. package/src/views/error-page/404.vue +248 -228
  143. package/src/views/layout/EmptyLayout.vue +3 -0
  144. package/src/views/layout/Layout.vue +81 -68
  145. package/src/views/layout/NewLayout.vue +18 -0
  146. package/src/views/layout/components/AppMain.vue +39 -29
  147. package/src/views/layout/components/Breadcrumb/index.vue +156 -0
  148. package/src/views/layout/components/Menubar/Item.vue +57 -0
  149. package/src/views/layout/components/Menubar/Link.vue +38 -0
  150. package/src/views/layout/components/Menubar/SidebarItem.vue +164 -0
  151. package/src/views/layout/components/Menubar/index.vue +210 -0
  152. package/src/views/layout/components/Sidebar/Item.vue +53 -29
  153. package/src/views/layout/components/Sidebar/Link.vue +38 -39
  154. package/src/views/layout/components/Sidebar/SidebarItem.vue +135 -100
  155. package/src/views/layout/components/Sidebar/index.vue +141 -48
  156. package/src/views/layout/components/iframe-page.vue +38 -0
  157. package/src/views/layout/components/index.js +4 -3
  158. package/src/views/layout/components/tabs/tab-content.vue +207 -0
  159. package/src/views/layout/mixin/ResizeHandler.js +41 -41
  160. package/src/views/layout/tab-content-iframe-index.vue +38 -0
  161. package/src/views/layout/tab-content-index.vue +93 -0
  162. package/src/views/login/authredirect.vue +10 -10
  163. package/src/views/login/index.vue +296 -203
  164. package/src/views/login/update-password.vue +243 -0
  165. package/src/views/redirect/index.vue +14 -12
  166. package/src/views/wf-history/tache-subprocess-history.vue +45 -0
  167. package/vite.config.js +31 -0
  168. package/lib/super-ui.css +0 -1
  169. package/lib/super-ui.umd.min.js +0 -2
  170. package/src/styles/variables.scss +0 -4
  171. package/src/views/layout/components/Navbar.vue +0 -92
@@ -1,69 +1,96 @@
1
- import Vue from 'vue'
2
- import Router from 'vue-router'
3
-
4
- // in development-env not use lazy-loading, because lazy-loading too many pages will cause webpack hot update too slow. so only in production use lazy-loading;
5
- // detail: https://panjiachen.github.io/vue-element-admin-site/#/lazy-loading
6
-
7
- Vue.use(Router)
8
-
9
- /* Layout */
10
- import Layout from '../views/layout/Layout'
11
-
12
- /**
13
- * hidden: true if `hidden:true` will not show in the sidebar(default is false)
14
- * alwaysShow: true if set true, will always show the root menu, whatever its child routes length
15
- * if not set alwaysShow, only more than one route under the children
16
- * it will becomes nested mode, otherwise not show the root menu
17
- * redirect: noredirect if `redirect:noredirect` will no redirect in the breadcrumb
18
- * name:'router-name' the name is used by <keep-alive> (must set!!!)
19
- * meta : {
20
- title: 'title' the name show in submenu and breadcrumb (recommend set)
21
- icon: 'svg-name' the icon show in the sidebar,
22
- }
23
- **/
24
- export const publicRouterMap = [
25
- {
26
- path: '/redirect',
27
- component: Layout,
28
- hidden: true,
29
- children: [
30
- {
31
- path: '/redirect/:path*',
32
- component: () => import('../views/redirect/index')
33
- }
34
- ]
35
- },
36
- // {
37
- // path: '/login',
38
- // component: () => import('../views/login/index'),
39
- // hidden: true
40
- // },
41
- {
42
- path: '/auth-redirect',
43
- component: () => import('../views/login/authredirect'),
44
- hidden: true
45
- },
46
- {
47
- path: '/404',
48
- component: () => import('../views/error-page/404'),
49
- hidden: true
50
- },
51
- {
52
- path: '/401',
53
- component: () => import('../views/error-page/401'),
54
- hidden: true
55
- }
56
-
57
- ]
58
- export const protectedRouterMap = [
59
-
60
- ]
61
- export const errorRouterMap = [
62
- // 404的映射必须是最后一个
63
- { path: '*', redirect: '/404', hidden: true }
64
- ]
65
- export default new Router({
66
- // mode: 'history', //后端支持可开
67
- scrollBehavior: () => ({ y: 0 }),
68
- routes: publicRouterMap
69
- })
1
+ import * as Vue from 'vue'
2
+ import * as VueRouter from 'vue-router'
3
+
4
+ /* Layout */
5
+ import Layout from '../views/layout/NewLayout.vue'
6
+
7
+ export const publicRouterMap = [
8
+ {
9
+ path: '/redirect',
10
+ component: Layout,
11
+ hidden: true,
12
+ children: [
13
+ {
14
+ path: '/redirect/:path*',
15
+ component: Vue.defineAsyncComponent(
16
+ () => import('../views/redirect/index.vue')
17
+ ),
18
+ },
19
+ ],
20
+ },
21
+ {
22
+ path: '/iframe-page',
23
+ component: Layout,
24
+ hidden: true,
25
+ children: [
26
+ {
27
+ path: 'page',
28
+ component: Vue.defineAsyncComponent(
29
+ () => import('../views/layout/components/iframe-page.vue')
30
+ ),
31
+ hidden: true,
32
+ },
33
+ ],
34
+ },
35
+ // {
36
+ // path: '/login',
37
+ // component: () => import('../views/login/index'),
38
+ // hidden: true
39
+ // },
40
+ {
41
+ path: '/auth-redirect',
42
+ component: Vue.defineAsyncComponent(
43
+ () => import('../views/login/authredirect.vue')
44
+ ),
45
+ hidden: true,
46
+ },
47
+ {
48
+ path: '/404',
49
+ component: Vue.defineAsyncComponent(
50
+ () => import('../views/error-page/404.vue')
51
+ ),
52
+ hidden: true,
53
+ },
54
+ {
55
+ path: '/401',
56
+ component: Vue.defineAsyncComponent(
57
+ () => import('../views/error-page/401.vue')
58
+ ),
59
+ hidden: true,
60
+ },
61
+ {
62
+ path: '/show-sub-wf-history',
63
+ component: Vue.defineAsyncComponent(
64
+ () => import('../views/wf-history/tache-subprocess-history.vue')
65
+ ),
66
+ hidden: true,
67
+ },
68
+ {
69
+ path: '/tab-content-index',
70
+ component: Vue.defineAsyncComponent(
71
+ () => import('../views/layout/tab-content-index.vue')
72
+ ),
73
+ hidden: true,
74
+ },
75
+ {
76
+ path: '/tab-content-iframe-index',
77
+ component: Vue.defineAsyncComponent(
78
+ () => import('../views/layout/tab-content-iframe-index.vue')
79
+ ),
80
+ hidden: true,
81
+ },
82
+ ]
83
+ export const protectedRouterMap = []
84
+ // 404的映射必须是最后一个
85
+ export const errorRouterMap = [
86
+ { path: '*', redirect: '/404', hidden: true }
87
+ ]
88
+
89
+
90
+ export default VueRouter.createRouter({
91
+ history: VueRouter.createWebHashHistory(),
92
+ routes: publicRouterMap, // mode: 'history', //后端支持可开
93
+ scrollBehavior: () => ({
94
+ top: 0,
95
+ }),
96
+ })
@@ -1,10 +1,15 @@
1
- const getters = {
2
- sidebar: state => state.app.sidebar,
3
- device: state => state.app.device,
4
- token: state => state.user.token,
5
- name: state => state.user.name,
6
- // routers: state => state.permission.routers,
7
- protectedRouters: state => state.permission.protectedRouters,
8
- currentUserPermissions: state => state.permission.currentUserPermissions
9
- }
10
- export default getters
1
+ const getters = {
2
+ sidebar: (state) => state.app.sidebar,
3
+ device: (state) => state.app.device,
4
+ token: (state) => state.user.token,
5
+ name: (state) => state.user.name,
6
+ // routers: state => state.permission.routers,
7
+ protectedRouters: (state) => state.permission.protectedRouters,
8
+ currentUserPermissions: (state) => state.permission.currentUserPermissions,
9
+ preventReclick: (state) => state.app.preventReclick,
10
+ menus: (state) => state.user.menus,
11
+ openTab: (state) => state.tabContent.openTab,
12
+ activeIndex: (state) => state.tabContent.activeIndex,
13
+ whiteList: (state) => state.app.whiteList,
14
+ }
15
+ export default getters
@@ -1,19 +1,19 @@
1
- import Vue from 'vue'
2
- import Vuex from 'vuex'
3
- import app from './modules/app'
4
- import user from './modules/user'
5
- import permission from './modules/permission'
6
- import getters from './getters'
7
-
8
- Vue.use(Vuex)
9
-
10
- const store = new Vuex.Store({
11
- modules: {
12
- app,
13
- user,
14
- permission
15
- },
16
- getters
17
- })
18
-
19
- export default store
1
+ import * as Vue from 'vue'
2
+ import * as Vuex from 'vuex'
3
+ import app from './modules/app'
4
+ import user from './modules/user'
5
+ import permission from './modules/permission'
6
+ import tabContent from './modules/tab-content'
7
+ import getters from './getters'
8
+
9
+ const store = Vuex.createStore({
10
+ modules: {
11
+ app,
12
+ user,
13
+ permission,
14
+ tabContent,
15
+ },
16
+ getters,
17
+ })
18
+
19
+ export default store
@@ -1,42 +1,54 @@
1
- import sessionStorage from 'sessionstorage'
2
- const app = {
3
- state: {
4
- sidebar: {
5
- opened: !+sessionStorage.getItem('sidebarStatus'),
6
- withoutAnimation: false
7
- },
8
- device: 'desktop'
9
- },
10
- mutations: {
11
- toggleSidebar: state => {
12
- if (state.sidebar.opened) {
13
- sessionStorage.setItem('sidebarStatus', 1)
14
- } else {
15
- sessionStorage.setItem('sidebarStatus', 0)
16
- }
17
- state.sidebar.opened = !state.sidebar.opened
18
- state.sidebar.withoutAnimation = false
19
- },
20
- closeSidebar: (state, withoutAnimation) => {
21
- sessionStorage.setItem('sidebarStatus', 1)
22
- state.sidebar.opened = false
23
- state.sidebar.withoutAnimation = withoutAnimation
24
- },
25
- toggleDevice: (state, device) => {
26
- state.device = device
27
- }
28
- },
29
- actions: {
30
- toggleSidebar: ({ commit }) => {
31
- commit('toggleSidebar')
32
- },
33
- closeSidebar({ commit }, { withoutAnimation }) {
34
- commit('closeSidebar', withoutAnimation)
35
- },
36
- toggelDevice({ commit }, device) {
37
- commit('toggleDevice', device)
38
- }
39
- }
40
- }
41
-
42
- export default app
1
+ const app = {
2
+ state: {
3
+ sidebar: {
4
+ opened: !+window.sessionStorage.getItem('sidebarStatus'),
5
+ withoutAnimation: false,
6
+ },
7
+ device: 'desktop',
8
+ preventReclick: false,
9
+ whiteList: [],
10
+ },
11
+ mutations: {
12
+ toggleSidebar: (state) => {
13
+ if (state.sidebar.opened) {
14
+ window.sessionStorage.setItem('sidebarStatus', 1)
15
+ } else {
16
+ window.sessionStorage.setItem('sidebarStatus', 0)
17
+ }
18
+ state.sidebar.opened = !state.sidebar.opened
19
+ state.sidebar.withoutAnimation = false
20
+ },
21
+ closeSidebar: (state, withoutAnimation) => {
22
+ window.sessionStorage.setItem('sidebarStatus', 1)
23
+ state.sidebar.opened = false
24
+ state.sidebar.withoutAnimation = withoutAnimation
25
+ },
26
+ toggleDevice: (state, device) => {
27
+ state.device = device
28
+ },
29
+ togglePreventReclick: (state, preventReclick) => {
30
+ state.preventReclick = preventReclick
31
+ },
32
+ setWhiteList: (state, whiteList) => {
33
+ if (whiteList instanceof Array) {
34
+ state.whiteList = whiteList
35
+ }
36
+ },
37
+ },
38
+ actions: {
39
+ toggleSidebar: ({ commit }) => {
40
+ commit('toggleSidebar')
41
+ },
42
+ closeSidebar({ commit }, { withoutAnimation }) {
43
+ commit('closeSidebar', withoutAnimation)
44
+ },
45
+ toggelDevice({ commit }, device) {
46
+ commit('toggleDevice', device)
47
+ },
48
+ addWhiteList({ commit }, whiteList) {
49
+ commit('setWhiteList', whiteList)
50
+ },
51
+ },
52
+ }
53
+
54
+ export default app
@@ -1,73 +1,137 @@
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 = false
10
- for (const permission of currentUserPermissions) {
11
- if (permission.toLowerCase() === route.meta.permission.toLowerCase()) {
12
- result = true
13
- break
14
- }
15
- }
16
- return result
17
- }
18
-
19
- /**
20
- * 递归过滤受权限保护的路由表,返回符合用户权限的路由表
21
- * @param allRoutes 即protectedRouterMap
22
- * @param currentUserPermissions 后台返回的当前用户具有的权限
23
- */
24
- function filterProtectedRouter(allRoutes, currentUserPermissions) {
25
- const res = []
26
-
27
- allRoutes.forEach(route => {
28
- const tmp = { ...route }
29
- if (tmp.children) {
30
- tmp.children = filterProtectedRouter(tmp.children, currentUserPermissions)
31
- if (tmp.children) {
32
- res.push(tmp)
33
- }
34
- } else {
35
- if (hasPermission(currentUserPermissions, tmp)) {
36
- res.push(tmp)
37
- }
38
- }
39
- })
40
-
41
- return res
42
- }
43
-
44
- const permission = {
45
- state: {
46
- // routers: publicRouterMap,
47
- protectedRouters: [],
48
- currentUserPermissions: []
49
- },
50
- mutations: {
51
- setCurrentUserPermissions: (state, currentUserPermissions) => {
52
- state.currentUserPermissions = currentUserPermissions
53
- },
54
- setRouters: (state, routers) => {
55
- state.protectedRouters = routers
56
- // 把公共路由,用户有权限的路由,错误路由合并后就是当前用户的完整路由表
57
- // state.routers = publicRouterMap.concat(routers).concat(errorRouterMap)
58
- }
59
- },
60
- actions: {
61
- generateRoutes({ commit }, data) {
62
- return new Promise(resolve => {
63
- const currentUserPermissions = data
64
- commit('setCurrentUserPermissions', currentUserPermissions)
65
- const accessableRouters = filterProtectedRouter(protectedRouterMap, currentUserPermissions)
66
- commit('setRouters', accessableRouters)
67
- resolve()
68
- })
69
- }
70
- }
71
- }
72
-
73
- 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 accessableRoutersResult = filterProtectedRouter(
96
+ protectedRouterMap,
97
+ currentUserPermissions
98
+ )
99
+ const accessableRouters = accessableRoutersResult.allRouters
100
+ const allMenuRoutes = accessableRoutersResult.menuRouters
101
+ // console.log('有权限的路由表结果==', accessableRouters)
102
+ // 动态添加空路由(即系统路由)
103
+ if (accessableRouters.length > 0) {
104
+ // 获得所有菜单路由
105
+ // console.log('allMenuRoutes==', allMenuRoutes)
106
+ const emptyPathRouter = {
107
+ path: '',
108
+ }
109
+ if (allMenuRoutes.length > 0) {
110
+ if (accessableRouters[0].path !== '') {
111
+ // 表示不包含空路由,需要添加空路由
112
+ if (allMenuRoutes[0].redirectTmp) {
113
+ emptyPathRouter.redirect = allMenuRoutes[0].redirectTmp
114
+ }
115
+ accessableRouters.push(emptyPathRouter)
116
+ } else if (
117
+ allMenuRoutes.length > 0 &&
118
+ accessableRouters[0].path === '' &&
119
+ (!allMenuRoutes[0].children ||
120
+ allMenuRoutes[0].children.length === 0)
121
+ ) {
122
+ // 表示自己配置了空路由,且没有子路由
123
+ if (allMenuRoutes[0].redirectTmp) {
124
+ accessableRouters[0].redirect = allMenuRoutes[0].redirectTmp
125
+ }
126
+ }
127
+ // console.log('更新后的有权限的路由表结果,更新了根路由跳转的地址==', accessableRouters)
128
+ }
129
+ }
130
+ commit('setRouters', accessableRouters)
131
+ resolve()
132
+ })
133
+ },
134
+ },
135
+ }
136
+
137
+ export default permission
@@ -0,0 +1,36 @@
1
+ const tabContent = {
2
+ state: {
3
+ openTab: [], // 所有打开的路由
4
+ activeIndex: null, // 激活状态
5
+ },
6
+ mutations: {
7
+ // 添加tabs
8
+ add_tabs(state, data) {
9
+ state.openTab.push(data)
10
+ },
11
+ // 删除tabs
12
+ delete_tabs(state, route) {
13
+ let index = 0
14
+ for (const option of state.openTab) {
15
+ if (option.code === route.code) {
16
+ break
17
+ }
18
+ index++
19
+ }
20
+ state.openTab.splice(index, 1)
21
+ },
22
+ // 设置当前激活的tab
23
+ set_active_index(state, index) {
24
+ state.activeIndex = index
25
+ },
26
+ // 清空tabs
27
+ clear_tabs(state, route) {
28
+ if (state.openTab.length > 0) {
29
+ state.openTab.splice(0, state.openTab.length)
30
+ }
31
+ },
32
+ },
33
+ actions: {},
34
+ }
35
+
36
+ export default tabContent