Skip to content

Commit

Permalink
feat: 🎸 权限管理开发中
Browse files Browse the repository at this point in the history
  • Loading branch information
kailong321200875 committed Jan 17, 2021
1 parent 6d7ea66 commit 38f5211
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 42 deletions.
7 changes: 1 addition & 6 deletions babel.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,5 @@ module.exports = {
'styleLibraryName': 'theme-chalk'
}
]
],
'env': {
'development': {
'plugins': ['dynamic-import-node']
}
}
]
}
71 changes: 42 additions & 29 deletions mock/role/test-role.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export const checkedRoleNodes = [{
export const checkedRoleNodes = [
{
path: '/components-demo',
component: '#',
redirect: '/components-demo/echarts',
Expand All @@ -8,7 +9,8 @@ export const checkedRoleNodes = [{
icon: 'component',
alwaysShow: true
},
children: [{
children: [
{
path: 'echarts',
component: 'pages/index/views/components-demo/echarts/index.vue',
name: 'EchartsDemo',
Expand Down Expand Up @@ -281,14 +283,16 @@ export const checkedRoleNodes = [{
icon: 'clipboard',
alwaysShow: true
},
children: [{
path: 'clipboard',
component: 'pages/index/views/directives-demo/clipboard/index.vue',
name: 'ClipboardDemo',
meta: {
title: 'Clipboard'
children: [
{
path: 'clipboard',
component: 'pages/index/views/directives-demo/clipboard/index.vue',
name: 'ClipboardDemo',
meta: {
title: 'Clipboard'
}
}
}]
]
},
{
path: '/hooks-demo',
Expand All @@ -300,7 +304,8 @@ export const checkedRoleNodes = [{
icon: 'international',
alwaysShow: true
},
children: [{
children: [
{
path: 'watermark',
component: 'pages/index/views/hooks-demo/useWatermark/index.vue',
name: 'UseWatermarkDemo',
Expand All @@ -326,15 +331,17 @@ export const checkedRoleNodes = [{
title: '图标',
icon: 'icon'
},
children: [{
path: 'index',
component: 'pages/index/views/icons/index.vue',
name: 'Icons',
meta: {
title: '图标',
icon: 'icon'
children: [
{
path: 'index',
component: 'pages/index/views/icons/index.vue',
name: 'Icons',
meta: {
title: '图标',
icon: 'icon'
}
}
}]
]
},
{
path: '/level',
Expand All @@ -345,15 +352,17 @@ export const checkedRoleNodes = [{
title: '多级菜单缓存',
icon: 'nested'
},
children: [{
children: [
{
path: 'menu1',
name: 'Menu1Demo',
component: '##Menu1Demo',
redirect: '/level/menu1/menu1-1/menu1-1-1',
meta: {
title: 'Menu1'
},
children: [{
children: [
{
path: 'menu1-1',
name: 'Menu11Demo',
component: '##Menu11Demo',
Expand All @@ -362,14 +371,16 @@ export const checkedRoleNodes = [{
title: 'Menu1-1',
alwaysShow: true
},
children: [{
path: 'menu1-1-1',
name: 'Menu111Demo',
component: 'pages/index/views/level/Menu111.vue',
meta: {
title: 'Menu1-1-1'
children: [
{
path: 'menu1-1-1',
name: 'Menu111Demo',
component: 'pages/index/views/level/Menu111.vue',
meta: {
title: 'Menu1-1-1'
}
}
}]
]
},
{
path: 'menu1-2',
Expand Down Expand Up @@ -401,7 +412,8 @@ export const checkedRoleNodes = [{
icon: 'example',
title: '综合实例'
},
children: [{
children: [
{
path: 'example-dialog',
component: 'pages/index/views/example-demo/example-dialog/index.vue',
name: 'ExampleDialog',
Expand Down Expand Up @@ -468,7 +480,8 @@ export const checkedRoleNodes = [{
icon: 'user',
alwaysShow: true
},
children: [{
children: [
{
path: 'user',
component: 'pages/index/views/role-demo/user/index.vue',
name: 'User',
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
"@vue/eslint-config-typescript": "^5.0.2",
"babel-eslint": "^10.1.0",
"babel-plugin-component": "^1.1.1",
"babel-plugin-dynamic-import-node": "^2.3.3",
"babel-plugin-import": "^1.13.1",
"body-parser": "^1.19.0",
"chalk": "^4.1.0",
Expand Down
1 change: 1 addition & 0 deletions src/pages/index/permission.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import type { RouteRecordRaw } from 'vue-router'

const whiteList: string[] = ['/login'] // 不重定向白名单
router.beforeEach((to, from, next) => {
NProgress.start()
if (wsCache.get(appStore.userInfo)) {
if (to.path === '/login') {
next({ path: '/' })
Expand Down
7 changes: 2 additions & 5 deletions src/pages/index/store/modules/permission.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// import path from 'path'
import { asyncRouterMap, constantRouterMap } from '_p/index/router'
import { deepClone } from '@/utils'
import store from '../index'
Expand Down Expand Up @@ -128,16 +127,14 @@ function getFilterRoutes(routes: any[]): any[] {
name: route.name,
redirect: route.redirect
}
data.meta = Object.assign({}, route.meta || {}, { title: route.title })
data.meta = Object.assign({}, route.meta || {}, { title: route.title || route.meta.title })
if (route.component) {
// 动态加载路由文件,可根据实际情况进行自定义逻辑
data.component = route.component === '#'
? Layout
: (route.component.includes('##')
? getParentLayout(route.component.split('##')[1])
: () => new Promise((resolve) => {
resolve(import(`${route.component}`))
}))
: () => import(`@/${route.component}`))
}
// recursive child routes
if (route.children) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,6 @@
<script lang="ts">
import { setRoleApi, getRoleDetApi } from '../api'
import { defineComponent, PropType, ref, reactive, nextTick, unref } from 'vue'
import { AppRouteRecordRaw } from '_p/index/router/types'
import { isExternal } from '@/utils/validate'
import { Message } from '_c/Message'
const requiredRule = {
Expand Down

0 comments on commit 38f5211

Please sign in to comment.