style:权限处理
Showing
9 changed files
with
47 additions
and
38 deletions
| ... | @@ -19,7 +19,9 @@ | ... | @@ -19,7 +19,9 @@ |
| 19 | "nprogress": "0.2.0", | 19 | "nprogress": "0.2.0", |
| 20 | "vue": "2.6.10", | 20 | "vue": "2.6.10", |
| 21 | "vue-router": "3.0.2", | 21 | "vue-router": "3.0.2", |
| 22 | "vuex": "3.1.0" | 22 | "vuex": "3.1.0", |
| 23 | "bpmn-js": "^7.4.0", | ||
| 24 | "diagram-js": "^6.8.2" | ||
| 23 | }, | 25 | }, |
| 24 | "devDependencies": { | 26 | "devDependencies": { |
| 25 | "@vue/cli-plugin-babel": "4.4.4", | 27 | "@vue/cli-plugin-babel": "4.4.4", | ... | ... |
src/components/processViewer/index.vue
0 → 100644
This diff is collapsed.
Click to expand it.
| 1 | <template> | 1 | <template> |
| 2 | <div v-if="!item.hidden"> | 2 | <div v-if="!item.hidden"> |
| 3 | <template v-if="hasOneShowingChild(item.children,item) && (!onlyOneChild.children||onlyOneChild.noShowingChildren)&&!item.alwaysShow"> | 3 | <template v-if="hasOneShowingChild(item.children,item) && (!onlyOneChild.children||onlyOneChild.noShowingChildren)"> |
| 4 | <app-link v-if="onlyOneChild.meta" :to="resolvePath(onlyOneChild.path)"> | 4 | <app-link v-if="onlyOneChild.meta" :to="resolvePath(onlyOneChild.path)"> |
| 5 | <el-menu-item :index="resolvePath(onlyOneChild.path)" :class="{'submenu-title-noDropdown':!isNest}"> | 5 | <el-menu-item :index="resolvePath(onlyOneChild.path)" :class="{'submenu-title-noDropdown':!isNest}"> |
| 6 | <item :icon="onlyOneChild.meta.icon||(item.meta&&item.meta.icon)" :title="onlyOneChild.meta.title" class="menu-icon" /> | 6 | <item :icon="onlyOneChild.meta.icon||(item.meta&&item.meta.icon)" :title="onlyOneChild.meta.title" |
| 7 | class="menu-icon" /> | ||
| 7 | </el-menu-item> | 8 | </el-menu-item> |
| 8 | </app-link> | 9 | </app-link> |
| 9 | </template> | 10 | </template> |
| ... | @@ -12,14 +13,8 @@ | ... | @@ -12,14 +13,8 @@ |
| 12 | <template slot="title"> | 13 | <template slot="title"> |
| 13 | <item v-if="item.meta" :icon="item.meta && item.meta.icon" :title="item.meta.title" /> | 14 | <item v-if="item.meta" :icon="item.meta && item.meta.icon" :title="item.meta.title" /> |
| 14 | </template> | 15 | </template> |
| 15 | <sidebar-item | 16 | <sidebar-item v-for="child in item.children" :key="child.path" :is-nest="true" :item="child" |
| 16 | v-for="child in item.children" | 17 | :base-path="resolvePath(child.path)" class="nest-menu" /> |
| 17 | :key="child.path" | ||
| 18 | :is-nest="true" | ||
| 19 | :item="child" | ||
| 20 | :base-path="resolvePath(child.path)" | ||
| 21 | class="nest-menu" | ||
| 22 | /> | ||
| 23 | </el-submenu> | 18 | </el-submenu> |
| 24 | </div> | 19 | </div> |
| 25 | </template> | 20 | </template> |
| ... | @@ -50,14 +45,14 @@ export default { | ... | @@ -50,14 +45,14 @@ export default { |
| 50 | default: '' | 45 | default: '' |
| 51 | } | 46 | } |
| 52 | }, | 47 | }, |
| 53 | data() { | 48 | data () { |
| 54 | // To fix https://github.com/PanJiaChen/vue-admin-template/issues/237 | 49 | // To fix https://github.com/PanJiaChen/vue-admin-template/issues/237 |
| 55 | // TODO: refactor with render function | 50 | // TODO: refactor with render function |
| 56 | this.onlyOneChild = null | 51 | this.onlyOneChild = null |
| 57 | return {} | 52 | return {} |
| 58 | }, | 53 | }, |
| 59 | methods: { | 54 | methods: { |
| 60 | hasOneShowingChild(children = [], parent) { | 55 | hasOneShowingChild (children = [], parent) { |
| 61 | const showingChildren = children.filter(item => { | 56 | const showingChildren = children.filter(item => { |
| 62 | if (item.hidden) { | 57 | if (item.hidden) { |
| 63 | return false | 58 | return false |
| ... | @@ -75,13 +70,13 @@ export default { | ... | @@ -75,13 +70,13 @@ export default { |
| 75 | 70 | ||
| 76 | // Show parent if there are no child router to display | 71 | // Show parent if there are no child router to display |
| 77 | if (showingChildren.length === 0) { | 72 | if (showingChildren.length === 0) { |
| 78 | this.onlyOneChild = { ... parent, path: '', noShowingChildren: true } | 73 | this.onlyOneChild = { ...parent, path: '', noShowingChildren: true } |
| 79 | return true | 74 | return true |
| 80 | } | 75 | } |
| 81 | 76 | ||
| 82 | return false | 77 | return false |
| 83 | }, | 78 | }, |
| 84 | resolvePath(routePath) { | 79 | resolvePath (routePath) { |
| 85 | if (isExternal(routePath)) { | 80 | if (isExternal(routePath)) { |
| 86 | return routePath | 81 | return routePath |
| 87 | } | 82 | } | ... | ... |
| ... | @@ -5,9 +5,9 @@ | ... | @@ -5,9 +5,9 @@ |
| 5 | :unique-opened="true" :active-text-color="variables.menuActiveText" :collapse-transition="false" | 5 | :unique-opened="true" :active-text-color="variables.menuActiveText" :collapse-transition="false" |
| 6 | mode="vertical"> | 6 | mode="vertical"> |
| 7 | <!-- 权限菜单 --> | 7 | <!-- 权限菜单 --> |
| 8 | <!-- <sidebar-item v-for="route in permission_routes" :key="route.path" :item="route" :base-path="route.path" /> --> | 8 | <sidebar-item v-for="route in permission_routes" :key="route.path" :item="route" :base-path="route.path" /> |
| 9 | <!-- 菜单全部展示 --> | 9 | <!-- 菜单全部展示 --> |
| 10 | <sidebar-item v-for="route in asyncRoutes" :key="route.path" :item="route" :base-path="route.path" /> | 10 | <!-- <sidebar-item v-for="route in asyncRoutes" :key="route.path" :item="route" :base-path="route.path" /> --> |
| 11 | </el-menu> | 11 | </el-menu> |
| 12 | </el-scrollbar> | 12 | </el-scrollbar> |
| 13 | </div> | 13 | </div> | ... | ... |
| ... | @@ -20,17 +20,16 @@ router.beforeEach(async (to, from, next) => { | ... | @@ -20,17 +20,16 @@ router.beforeEach(async (to, from, next) => { |
| 20 | next() | 20 | next() |
| 21 | } else { | 21 | } else { |
| 22 | const { result: getMenuData } = await getMenuInfo() | 22 | const { result: getMenuData } = await getMenuInfo() |
| 23 | console.log(getMenuData); | 23 | const accessRoutes = await store.dispatch('permission/generateRoutes', getMenuData) |
| 24 | // const accessRoutes = await store.dispatch('permission/generateRoutes', getMenuData) | 24 | router.addRoutes(accessRoutes) |
| 25 | // router.addRoutes(accessRoutes) | 25 | console.log(router); |
| 26 | next() | 26 | next({ ...to, replace: true }) |
| 27 | } | 27 | } |
| 28 | NProgress.done() | 28 | NProgress.done() |
| 29 | 29 | ||
| 30 | }) | 30 | }) |
| 31 | router.afterEach(to => { | 31 | router.afterEach(to => { |
| 32 | // 解决刷新页面报404问题 | 32 | // 解决刷新页面报404问题 |
| 33 | sessionStorage.setItem('routerTo', to.fullPath) | ||
| 34 | Cookies.set("routerTo", to.fullPath) | 33 | Cookies.set("routerTo", to.fullPath) |
| 35 | NProgress.done() | 34 | NProgress.done() |
| 36 | }) | 35 | }) | ... | ... |
| ... | @@ -25,7 +25,6 @@ export const constantRoutes = [ | ... | @@ -25,7 +25,6 @@ export const constantRoutes = [ |
| 25 | component: () => import('@/views/error-page/404'), | 25 | component: () => import('@/views/error-page/404'), |
| 26 | hidden: true | 26 | hidden: true |
| 27 | }, | 27 | }, |
| 28 | { path: '*', redirect: '/404', hidden: true }, | ||
| 29 | // 业务流程框架 | 28 | // 业务流程框架 |
| 30 | { | 29 | { |
| 31 | path: '/workFrame', | 30 | path: '/workFrame', |
| ... | @@ -58,7 +57,7 @@ export const asyncRoutes = [ | ... | @@ -58,7 +57,7 @@ export const asyncRoutes = [ |
| 58 | { | 57 | { |
| 59 | path: 'home', | 58 | path: 'home', |
| 60 | component: () => import('@/views/home/index'), | 59 | component: () => import('@/views/home/index'), |
| 61 | name: 'Dashboard', | 60 | name: 'home', |
| 62 | meta: { title: '工作台', icon: 'workbench', affix: true } | 61 | meta: { title: '工作台', icon: 'workbench', affix: true } |
| 63 | } | 62 | } |
| 64 | ] | 63 | ] |
| ... | @@ -273,7 +272,7 @@ export const asyncRoutes = [ | ... | @@ -273,7 +272,7 @@ export const asyncRoutes = [ |
| 273 | const createRouter = () => | 272 | const createRouter = () => |
| 274 | new Router({ | 273 | new Router({ |
| 275 | scrollBehavior: () => ({ y: 0 }), | 274 | scrollBehavior: () => ({ y: 0 }), |
| 276 | routes: [...constantRoutes, ...asyncRoutes] | 275 | routes: [...constantRoutes] |
| 277 | }) | 276 | }) |
| 278 | 277 | ||
| 279 | const router = createRouter() | 278 | const router = createRouter() | ... | ... |
| 1 | import { asyncRoutes, constantRoutes, resetRouter } from '@/router' | 1 | import { asyncRoutes, constantRoutes, resetRouter } from '@/router' |
| 2 | 2 | import asyncRouter from '@/utils/asyncRouter.js' | |
| 3 | const state = { | 3 | const state = { |
| 4 | routes: [], | 4 | routes: [], |
| 5 | addRoutes: false, | 5 | addRoutes: false, |
| ... | @@ -8,26 +8,18 @@ const state = { | ... | @@ -8,26 +8,18 @@ const state = { |
| 8 | const mutations = { | 8 | const mutations = { |
| 9 | SET_ROUTES: (state, routes) => { | 9 | SET_ROUTES: (state, routes) => { |
| 10 | state.addRoutes = true | 10 | state.addRoutes = true |
| 11 | state.routes = constantRoutes.concat(routes) | 11 | state.routes = routes |
| 12 | }, | 12 | }, |
| 13 | RESET_ROUTE: (state) => { | 13 | RESET_ROUTE: (state) => { |
| 14 | state.addRoutes = false | 14 | state.addRoutes = false |
| 15 | } | 15 | } |
| 16 | } | 16 | } |
| 17 | |||
| 18 | const actions = { | 17 | const actions = { |
| 19 | // 添加全部菜单 | 18 | // 添加全部菜单 |
| 20 | generateRoutes ({ commit }, getMenuInfo) { | 19 | generateRoutes ({ commit }, getMenuInfo) { |
| 21 | return new Promise(resolve => { | 20 | return new Promise(resolve => { |
| 22 | // 将路由树数据转成数组结构 | ||
| 23 | let arr1 = [] | ||
| 24 | dfs(_.cloneDeep(asyncRoutes), node => arr1.push(node)) | ||
| 25 | _.each(arr1, i => { | ||
| 26 | i.parentId = i.parentId ? i.parentId : null | ||
| 27 | }) | ||
| 28 | let permission_arr = _.intersectionBy(arr1, getMenuInfo, 'name') | ||
| 29 | // 将权限菜单数组转成路由树数据结构 | 21 | // 将权限菜单数组转成路由树数据结构 |
| 30 | let permission_tree = array2Tree(permission_arr, null) | 22 | let permission_tree = asyncRouter(getMenuInfo) |
| 31 | commit('SET_ROUTES', permission_tree) | 23 | commit('SET_ROUTES', permission_tree) |
| 32 | resolve(permission_tree) | 24 | resolve(permission_tree) |
| 33 | }) | 25 | }) | ... | ... |
src/utils/asyncRouter.js
0 → 100644
| 1 | import Layout from '@/layout' | ||
| 2 | export default function filterAsyncRouter (routers) { | ||
| 3 | routers.forEach(item => { | ||
| 4 | if (!item.children) { | ||
| 5 | delete item.children | ||
| 6 | delete item.redirect | ||
| 7 | } | ||
| 8 | if (!item.parentId) { | ||
| 9 | item.component = Layout | ||
| 10 | } else { | ||
| 11 | item.component = loadView(item.uri) | ||
| 12 | } | ||
| 13 | item.meta.icon = item.icon | ||
| 14 | if (item.children) { | ||
| 15 | item.children = filterAsyncRouter(item.children) | ||
| 16 | } | ||
| 17 | }) | ||
| 18 | return routers | ||
| 19 | } | ||
| 20 | function loadView (view) { | ||
| 21 | return r => require.ensure([], () => r(require(`@/views${view}.vue`))) | ||
| 22 | } | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| ... | @@ -11,9 +11,9 @@ const service = axios.create({ | ... | @@ -11,9 +11,9 @@ const service = axios.create({ |
| 11 | withCredentials: true, //是否允许跨域 | 11 | withCredentials: true, //是否允许跨域 |
| 12 | headers: { | 12 | headers: { |
| 13 | 'Content-Type': 'application/json; charset=utf-8', | 13 | 'Content-Type': 'application/json; charset=utf-8', |
| 14 | // 'Authorization': 'bearer AT-16-oqkOHiUSsDdFA-eAZ49k2rJQDTzQpClO' | 14 | 'Authorization': 'bearer AT-16-oqkOHiUSsDdFA-eAZ49k2rJQDTzQpClO' |
| 15 | //token列表 | 15 | //token列表 |
| 16 | 'Authorization': 'bearer AT-12-eRKHta5I8ZWftIU86sSyJ8rUkPhMvMJU' | 16 | // 'Authorization': 'bearer AT-12-eRKHta5I8ZWftIU86sSyJ8rUkPhMvMJU' |
| 17 | //renc:bearer AT-30-KHB4LXc8-CZXwBEyaFJa9lRmMTc5sHVI | 17 | //renc:bearer AT-30-KHB4LXc8-CZXwBEyaFJa9lRmMTc5sHVI |
| 18 | //tianh:bearer AT-33-3zFTGkhQ4eUv4nXvzAmbgN5RPZppzEY6 | 18 | //tianh:bearer AT-33-3zFTGkhQ4eUv4nXvzAmbgN5RPZppzEY6 |
| 19 | //zhangh:bearer AT-7-Tx8dlZH0LNRc33UjD1CX1xwa-1D7kQmQ | 19 | //zhangh:bearer AT-7-Tx8dlZH0LNRc33UjD1CX1xwa-1D7kQmQ | ... | ... |
-
Please register or sign in to post a comment