mirror of
https://github.com/soybeanjs/soybean-admin.git
synced 2025-09-17 17:26:38 +08:00
refactor(projects): mock权限相关数据优化
This commit is contained in:
parent
5c75e9d958
commit
41e46a5d80
@ -15,7 +15,7 @@ export default (srcPath: string) => {
|
|||||||
defaultClass: 'inline-block'
|
defaultClass: 'inline-block'
|
||||||
}),
|
}),
|
||||||
Components({
|
Components({
|
||||||
dts: true,
|
dts: 'src/typings/components.d.ts',
|
||||||
resolvers: [NaiveUiResolver(), IconsResolver({ customCollections: ['custom'], componentPrefix: 'icon' })]
|
resolvers: [NaiveUiResolver(), IconsResolver({ customCollections: ['custom'], componentPrefix: 'icon' })]
|
||||||
})
|
})
|
||||||
];
|
];
|
||||||
|
@ -369,7 +369,7 @@ const routes: AuthRoute.Route[] = [
|
|||||||
title: '关于',
|
title: '关于',
|
||||||
requiresAuth: true,
|
requiresAuth: true,
|
||||||
singleLayout: 'basic',
|
singleLayout: 'basic',
|
||||||
permissions: ['super', 'admin', 'test'],
|
permissions: ['super', 'admin', 'user'],
|
||||||
icon: 'fluent:book-information-24-regular',
|
icon: 'fluent:book-information-24-regular',
|
||||||
order: 8
|
order: 8
|
||||||
}
|
}
|
||||||
|
848
mock/model/route.ts
Normal file
848
mock/model/route.ts
Normal file
@ -0,0 +1,848 @@
|
|||||||
|
const routes: Record<Auth.RoleType, AuthRoute.Route[]> = {
|
||||||
|
super: [
|
||||||
|
{
|
||||||
|
name: 'dashboard',
|
||||||
|
path: '/dashboard',
|
||||||
|
component: 'basic',
|
||||||
|
children: [
|
||||||
|
{
|
||||||
|
name: 'dashboard_analysis',
|
||||||
|
path: '/dashboard/analysis',
|
||||||
|
component: 'self',
|
||||||
|
meta: {
|
||||||
|
title: '分析页',
|
||||||
|
requiresAuth: true,
|
||||||
|
icon: 'icon-park-outline:analysis'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'dashboard_workbench',
|
||||||
|
path: '/dashboard/workbench',
|
||||||
|
component: 'self',
|
||||||
|
meta: {
|
||||||
|
title: '工作台',
|
||||||
|
requiresAuth: true,
|
||||||
|
icon: 'icon-park-outline:workbench'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
meta: {
|
||||||
|
title: '仪表盘',
|
||||||
|
icon: 'carbon:dashboard',
|
||||||
|
order: 1
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'document',
|
||||||
|
path: '/document',
|
||||||
|
component: 'basic',
|
||||||
|
children: [
|
||||||
|
{
|
||||||
|
name: 'document_vue',
|
||||||
|
path: '/document/vue',
|
||||||
|
component: 'self',
|
||||||
|
meta: {
|
||||||
|
title: 'vue文档',
|
||||||
|
requiresAuth: true,
|
||||||
|
icon: 'mdi:vuejs'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'document_vue-new',
|
||||||
|
path: '/document/vue-new',
|
||||||
|
component: 'self',
|
||||||
|
meta: {
|
||||||
|
title: 'vue文档(新版)',
|
||||||
|
requiresAuth: true,
|
||||||
|
icon: 'mdi:vuejs'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'document_vite',
|
||||||
|
path: '/document/vite',
|
||||||
|
component: 'self',
|
||||||
|
meta: {
|
||||||
|
title: 'vite文档',
|
||||||
|
requiresAuth: true,
|
||||||
|
icon: 'simple-icons:vite'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'document_project',
|
||||||
|
path: '/document/project',
|
||||||
|
meta: {
|
||||||
|
title: '项目文档(外链)',
|
||||||
|
requiresAuth: true,
|
||||||
|
icon: 'mdi:file-link-outline',
|
||||||
|
href: 'https://docs.soybean.pro/'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
meta: {
|
||||||
|
title: '文档',
|
||||||
|
icon: 'carbon:document',
|
||||||
|
order: 2
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'component',
|
||||||
|
path: '/component',
|
||||||
|
component: 'basic',
|
||||||
|
children: [
|
||||||
|
{
|
||||||
|
name: 'component_button',
|
||||||
|
path: '/component/button',
|
||||||
|
component: 'self',
|
||||||
|
meta: {
|
||||||
|
title: '按钮',
|
||||||
|
requiresAuth: true,
|
||||||
|
icon: 'ic:baseline-radio-button-checked'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'component_card',
|
||||||
|
path: '/component/card',
|
||||||
|
component: 'self',
|
||||||
|
meta: {
|
||||||
|
title: '卡片',
|
||||||
|
requiresAuth: true,
|
||||||
|
icon: 'mdi:card-outline'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'component_table',
|
||||||
|
path: '/component/table',
|
||||||
|
component: 'self',
|
||||||
|
meta: {
|
||||||
|
title: '表格',
|
||||||
|
requiresAuth: true,
|
||||||
|
icon: 'mdi:table-large'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
meta: {
|
||||||
|
title: '组件示例',
|
||||||
|
icon: 'fluent:app-store-24-regular',
|
||||||
|
order: 3
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'plugin',
|
||||||
|
path: '/plugin',
|
||||||
|
component: 'basic',
|
||||||
|
children: [
|
||||||
|
{
|
||||||
|
name: 'plugin_map',
|
||||||
|
path: '/plugin/map',
|
||||||
|
component: 'self',
|
||||||
|
meta: {
|
||||||
|
title: '地图',
|
||||||
|
requiresAuth: true,
|
||||||
|
icon: 'mdi:map'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'plugin_video',
|
||||||
|
path: '/plugin/video',
|
||||||
|
component: 'self',
|
||||||
|
meta: {
|
||||||
|
title: '视频',
|
||||||
|
requiresAuth: true,
|
||||||
|
icon: 'mdi:video'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'plugin_editor',
|
||||||
|
path: '/plugin/editor',
|
||||||
|
component: 'multi',
|
||||||
|
children: [
|
||||||
|
{
|
||||||
|
name: 'plugin_editor_quill',
|
||||||
|
path: '/plugin/editor/quill',
|
||||||
|
component: 'self',
|
||||||
|
meta: {
|
||||||
|
title: '富文本编辑器',
|
||||||
|
requiresAuth: true,
|
||||||
|
icon: 'mdi:file-document-edit-outline'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'plugin_editor_markdown',
|
||||||
|
path: '/plugin/editor/markdown',
|
||||||
|
component: 'self',
|
||||||
|
meta: {
|
||||||
|
title: 'markdown编辑器',
|
||||||
|
requiresAuth: true,
|
||||||
|
icon: 'ri:markdown-line'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
meta: {
|
||||||
|
title: '编辑器',
|
||||||
|
icon: 'icon-park-outline:editor'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'plugin_swiper',
|
||||||
|
path: '/plugin/swiper',
|
||||||
|
component: 'self',
|
||||||
|
meta: {
|
||||||
|
title: 'Swiper插件',
|
||||||
|
requiresAuth: true,
|
||||||
|
icon: 'simple-icons:swiper'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'plugin_copy',
|
||||||
|
path: '/plugin/copy',
|
||||||
|
component: 'self',
|
||||||
|
meta: {
|
||||||
|
title: '剪贴板',
|
||||||
|
requiresAuth: true,
|
||||||
|
icon: 'mdi:clipboard-outline'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'plugin_icon',
|
||||||
|
path: '/plugin/icon',
|
||||||
|
component: 'self',
|
||||||
|
meta: {
|
||||||
|
title: '图标',
|
||||||
|
requiresAuth: true,
|
||||||
|
icon: 'ic:baseline-insert-emoticon'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'plugin_print',
|
||||||
|
path: '/plugin/print',
|
||||||
|
component: 'self',
|
||||||
|
meta: {
|
||||||
|
title: '打印',
|
||||||
|
requiresAuth: true,
|
||||||
|
icon: 'ic:baseline-local-printshop'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
meta: {
|
||||||
|
title: '插件示例',
|
||||||
|
icon: 'clarity:plugin-line',
|
||||||
|
order: 4
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'auth-demo',
|
||||||
|
path: '/auth-demo',
|
||||||
|
component: 'basic',
|
||||||
|
children: [
|
||||||
|
{
|
||||||
|
name: 'auth-demo_permission',
|
||||||
|
path: '/auth-demo/permission',
|
||||||
|
component: 'self',
|
||||||
|
meta: {
|
||||||
|
title: '权限切换',
|
||||||
|
requiresAuth: true,
|
||||||
|
icon: 'ic:round-construction'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'auth-demo_super',
|
||||||
|
path: '/auth-demo/super',
|
||||||
|
component: 'self',
|
||||||
|
meta: {
|
||||||
|
title: '超级管理员可见',
|
||||||
|
requiresAuth: true,
|
||||||
|
icon: 'ic:round-supervisor-account'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
meta: {
|
||||||
|
title: '权限示例',
|
||||||
|
icon: 'ic:baseline-security',
|
||||||
|
order: 5
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'exception',
|
||||||
|
path: '/exception',
|
||||||
|
component: 'basic',
|
||||||
|
children: [
|
||||||
|
{
|
||||||
|
name: 'exception_403',
|
||||||
|
path: '/exception/403',
|
||||||
|
component: 'self',
|
||||||
|
meta: {
|
||||||
|
title: '异常页403',
|
||||||
|
requiresAuth: true,
|
||||||
|
icon: 'ic:baseline-block'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'exception_404',
|
||||||
|
path: '/exception/404',
|
||||||
|
component: 'self',
|
||||||
|
meta: {
|
||||||
|
title: '异常页404',
|
||||||
|
requiresAuth: true,
|
||||||
|
icon: 'ic:baseline-web-asset-off'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'exception_500',
|
||||||
|
path: '/exception/500',
|
||||||
|
component: 'self',
|
||||||
|
meta: {
|
||||||
|
title: '异常页500',
|
||||||
|
requiresAuth: true,
|
||||||
|
icon: 'ic:baseline-wifi-off'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
meta: {
|
||||||
|
title: '异常页',
|
||||||
|
icon: 'ant-design:exception-outlined',
|
||||||
|
order: 6
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'multi-menu',
|
||||||
|
path: '/multi-menu',
|
||||||
|
component: 'basic',
|
||||||
|
children: [
|
||||||
|
{
|
||||||
|
name: 'multi-menu_first',
|
||||||
|
path: '/multi-menu/first',
|
||||||
|
component: 'multi',
|
||||||
|
children: [
|
||||||
|
{
|
||||||
|
name: 'multi-menu_first_second',
|
||||||
|
path: '/multi-menu/first/second',
|
||||||
|
component: 'self',
|
||||||
|
meta: {
|
||||||
|
title: '二级菜单',
|
||||||
|
requiresAuth: true,
|
||||||
|
icon: 'ic:outline-menu'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'multi-menu_first_second-new',
|
||||||
|
path: '/multi-menu/first/second-new',
|
||||||
|
component: 'multi',
|
||||||
|
children: [
|
||||||
|
{
|
||||||
|
name: 'multi-menu_first_second-new_third',
|
||||||
|
path: '/multi-menu/first/second-new/third',
|
||||||
|
component: 'self',
|
||||||
|
meta: {
|
||||||
|
title: '三级菜单',
|
||||||
|
requiresAuth: true,
|
||||||
|
icon: 'ic:outline-menu'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
meta: {
|
||||||
|
title: '二级菜单(有子菜单)',
|
||||||
|
icon: 'ic:outline-menu'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
meta: {
|
||||||
|
title: '一级菜单',
|
||||||
|
icon: 'ic:outline-menu'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
meta: {
|
||||||
|
title: '多级菜单',
|
||||||
|
icon: 'carbon:menu',
|
||||||
|
order: 7
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'about',
|
||||||
|
path: '/about',
|
||||||
|
component: 'self',
|
||||||
|
meta: {
|
||||||
|
title: '关于',
|
||||||
|
requiresAuth: true,
|
||||||
|
singleLayout: 'basic',
|
||||||
|
icon: 'fluent:book-information-24-regular',
|
||||||
|
order: 8
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
admin: [
|
||||||
|
{
|
||||||
|
name: 'dashboard',
|
||||||
|
path: '/dashboard',
|
||||||
|
component: 'basic',
|
||||||
|
children: [
|
||||||
|
{
|
||||||
|
name: 'dashboard_analysis',
|
||||||
|
path: '/dashboard/analysis',
|
||||||
|
component: 'self',
|
||||||
|
meta: {
|
||||||
|
title: '分析页',
|
||||||
|
requiresAuth: true,
|
||||||
|
icon: 'icon-park-outline:analysis'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'dashboard_workbench',
|
||||||
|
path: '/dashboard/workbench',
|
||||||
|
component: 'self',
|
||||||
|
meta: {
|
||||||
|
title: '工作台',
|
||||||
|
requiresAuth: true,
|
||||||
|
icon: 'icon-park-outline:workbench'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
meta: {
|
||||||
|
title: '仪表盘',
|
||||||
|
icon: 'carbon:dashboard',
|
||||||
|
order: 1
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'document',
|
||||||
|
path: '/document',
|
||||||
|
component: 'basic',
|
||||||
|
children: [
|
||||||
|
{
|
||||||
|
name: 'document_vue',
|
||||||
|
path: '/document/vue',
|
||||||
|
component: 'self',
|
||||||
|
meta: {
|
||||||
|
title: 'vue文档',
|
||||||
|
requiresAuth: true,
|
||||||
|
icon: 'mdi:vuejs'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'document_vue-new',
|
||||||
|
path: '/document/vue-new',
|
||||||
|
component: 'self',
|
||||||
|
meta: {
|
||||||
|
title: 'vue文档(新版)',
|
||||||
|
requiresAuth: true,
|
||||||
|
icon: 'mdi:vuejs'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'document_vite',
|
||||||
|
path: '/document/vite',
|
||||||
|
component: 'self',
|
||||||
|
meta: {
|
||||||
|
title: 'vite文档',
|
||||||
|
requiresAuth: true,
|
||||||
|
icon: 'simple-icons:vite'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'document_project',
|
||||||
|
path: '/document/project',
|
||||||
|
meta: {
|
||||||
|
title: '项目文档(外链)',
|
||||||
|
requiresAuth: true,
|
||||||
|
icon: 'mdi:file-link-outline',
|
||||||
|
href: 'https://docs.soybean.pro/'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
meta: {
|
||||||
|
title: '文档',
|
||||||
|
icon: 'carbon:document',
|
||||||
|
order: 2
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'component',
|
||||||
|
path: '/component',
|
||||||
|
component: 'basic',
|
||||||
|
children: [
|
||||||
|
{
|
||||||
|
name: 'component_button',
|
||||||
|
path: '/component/button',
|
||||||
|
component: 'self',
|
||||||
|
meta: {
|
||||||
|
title: '按钮',
|
||||||
|
requiresAuth: true,
|
||||||
|
icon: 'ic:baseline-radio-button-checked'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'component_card',
|
||||||
|
path: '/component/card',
|
||||||
|
component: 'self',
|
||||||
|
meta: {
|
||||||
|
title: '卡片',
|
||||||
|
requiresAuth: true,
|
||||||
|
icon: 'mdi:card-outline'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'component_table',
|
||||||
|
path: '/component/table',
|
||||||
|
component: 'self',
|
||||||
|
meta: {
|
||||||
|
title: '表格',
|
||||||
|
requiresAuth: true,
|
||||||
|
icon: 'mdi:table-large'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
meta: {
|
||||||
|
title: '组件示例',
|
||||||
|
icon: 'fluent:app-store-24-regular',
|
||||||
|
order: 3
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'plugin',
|
||||||
|
path: '/plugin',
|
||||||
|
component: 'basic',
|
||||||
|
children: [
|
||||||
|
{
|
||||||
|
name: 'plugin_map',
|
||||||
|
path: '/plugin/map',
|
||||||
|
component: 'self',
|
||||||
|
meta: {
|
||||||
|
title: '地图',
|
||||||
|
requiresAuth: true,
|
||||||
|
icon: 'mdi:map'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'plugin_video',
|
||||||
|
path: '/plugin/video',
|
||||||
|
component: 'self',
|
||||||
|
meta: {
|
||||||
|
title: '视频',
|
||||||
|
requiresAuth: true,
|
||||||
|
icon: 'mdi:video'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'plugin_editor',
|
||||||
|
path: '/plugin/editor',
|
||||||
|
component: 'multi',
|
||||||
|
children: [
|
||||||
|
{
|
||||||
|
name: 'plugin_editor_quill',
|
||||||
|
path: '/plugin/editor/quill',
|
||||||
|
component: 'self',
|
||||||
|
meta: {
|
||||||
|
title: '富文本编辑器',
|
||||||
|
requiresAuth: true,
|
||||||
|
icon: 'mdi:file-document-edit-outline'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'plugin_editor_markdown',
|
||||||
|
path: '/plugin/editor/markdown',
|
||||||
|
component: 'self',
|
||||||
|
meta: {
|
||||||
|
title: 'markdown编辑器',
|
||||||
|
requiresAuth: true,
|
||||||
|
icon: 'ri:markdown-line'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
meta: {
|
||||||
|
title: '编辑器',
|
||||||
|
icon: 'icon-park-outline:editor'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'plugin_swiper',
|
||||||
|
path: '/plugin/swiper',
|
||||||
|
component: 'self',
|
||||||
|
meta: {
|
||||||
|
title: 'Swiper插件',
|
||||||
|
requiresAuth: true,
|
||||||
|
icon: 'simple-icons:swiper'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'plugin_copy',
|
||||||
|
path: '/plugin/copy',
|
||||||
|
component: 'self',
|
||||||
|
meta: {
|
||||||
|
title: '剪贴板',
|
||||||
|
requiresAuth: true,
|
||||||
|
icon: 'mdi:clipboard-outline'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'plugin_icon',
|
||||||
|
path: '/plugin/icon',
|
||||||
|
component: 'self',
|
||||||
|
meta: {
|
||||||
|
title: '图标',
|
||||||
|
requiresAuth: true,
|
||||||
|
icon: 'ic:baseline-insert-emoticon'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'plugin_print',
|
||||||
|
path: '/plugin/print',
|
||||||
|
component: 'self',
|
||||||
|
meta: {
|
||||||
|
title: '打印',
|
||||||
|
requiresAuth: true,
|
||||||
|
icon: 'ic:baseline-local-printshop'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
meta: {
|
||||||
|
title: '插件示例',
|
||||||
|
icon: 'clarity:plugin-line',
|
||||||
|
order: 4
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'auth-demo',
|
||||||
|
path: '/auth-demo',
|
||||||
|
component: 'basic',
|
||||||
|
children: [
|
||||||
|
{
|
||||||
|
name: 'auth-demo_permission',
|
||||||
|
path: '/auth-demo/permission',
|
||||||
|
component: 'self',
|
||||||
|
meta: {
|
||||||
|
title: '权限切换',
|
||||||
|
requiresAuth: true,
|
||||||
|
icon: 'ic:round-construction'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
meta: {
|
||||||
|
title: '权限示例',
|
||||||
|
icon: 'ic:baseline-security',
|
||||||
|
order: 5
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'exception',
|
||||||
|
path: '/exception',
|
||||||
|
component: 'basic',
|
||||||
|
children: [
|
||||||
|
{
|
||||||
|
name: 'exception_403',
|
||||||
|
path: '/exception/403',
|
||||||
|
component: 'self',
|
||||||
|
meta: {
|
||||||
|
title: '异常页403',
|
||||||
|
requiresAuth: true,
|
||||||
|
icon: 'ic:baseline-block'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'exception_404',
|
||||||
|
path: '/exception/404',
|
||||||
|
component: 'self',
|
||||||
|
meta: {
|
||||||
|
title: '异常页404',
|
||||||
|
requiresAuth: true,
|
||||||
|
icon: 'ic:baseline-web-asset-off'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'exception_500',
|
||||||
|
path: '/exception/500',
|
||||||
|
component: 'self',
|
||||||
|
meta: {
|
||||||
|
title: '异常页500',
|
||||||
|
requiresAuth: true,
|
||||||
|
icon: 'ic:baseline-wifi-off'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
meta: {
|
||||||
|
title: '异常页',
|
||||||
|
icon: 'ant-design:exception-outlined',
|
||||||
|
order: 6
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'multi-menu',
|
||||||
|
path: '/multi-menu',
|
||||||
|
component: 'basic',
|
||||||
|
children: [
|
||||||
|
{
|
||||||
|
name: 'multi-menu_first',
|
||||||
|
path: '/multi-menu/first',
|
||||||
|
component: 'multi',
|
||||||
|
children: [
|
||||||
|
{
|
||||||
|
name: 'multi-menu_first_second',
|
||||||
|
path: '/multi-menu/first/second',
|
||||||
|
component: 'self',
|
||||||
|
meta: {
|
||||||
|
title: '二级菜单',
|
||||||
|
requiresAuth: true,
|
||||||
|
icon: 'ic:outline-menu'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'multi-menu_first_second-new',
|
||||||
|
path: '/multi-menu/first/second-new',
|
||||||
|
component: 'multi',
|
||||||
|
children: [
|
||||||
|
{
|
||||||
|
name: 'multi-menu_first_second-new_third',
|
||||||
|
path: '/multi-menu/first/second-new/third',
|
||||||
|
component: 'self',
|
||||||
|
meta: {
|
||||||
|
title: '三级菜单',
|
||||||
|
requiresAuth: true,
|
||||||
|
icon: 'ic:outline-menu'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
meta: {
|
||||||
|
title: '二级菜单(有子菜单)',
|
||||||
|
icon: 'ic:outline-menu'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
meta: {
|
||||||
|
title: '一级菜单',
|
||||||
|
icon: 'ic:outline-menu'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
meta: {
|
||||||
|
title: '多级菜单',
|
||||||
|
icon: 'carbon:menu',
|
||||||
|
order: 7
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'about',
|
||||||
|
path: '/about',
|
||||||
|
component: 'self',
|
||||||
|
meta: {
|
||||||
|
title: '关于',
|
||||||
|
requiresAuth: true,
|
||||||
|
singleLayout: 'basic',
|
||||||
|
icon: 'fluent:book-information-24-regular',
|
||||||
|
order: 8
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
user: [
|
||||||
|
{
|
||||||
|
name: 'dashboard',
|
||||||
|
path: '/dashboard',
|
||||||
|
component: 'basic',
|
||||||
|
children: [
|
||||||
|
{
|
||||||
|
name: 'dashboard_analysis',
|
||||||
|
path: '/dashboard/analysis',
|
||||||
|
component: 'self',
|
||||||
|
meta: {
|
||||||
|
title: '分析页',
|
||||||
|
requiresAuth: true,
|
||||||
|
icon: 'icon-park-outline:analysis'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
meta: {
|
||||||
|
title: '仪表盘',
|
||||||
|
icon: 'carbon:dashboard',
|
||||||
|
order: 1
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'auth-demo',
|
||||||
|
path: '/auth-demo',
|
||||||
|
component: 'basic',
|
||||||
|
children: [
|
||||||
|
{
|
||||||
|
name: 'auth-demo_permission',
|
||||||
|
path: '/auth-demo/permission',
|
||||||
|
component: 'self',
|
||||||
|
meta: {
|
||||||
|
title: '权限切换',
|
||||||
|
requiresAuth: true,
|
||||||
|
icon: 'ic:round-construction'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
meta: {
|
||||||
|
title: '权限示例',
|
||||||
|
icon: 'ic:baseline-security',
|
||||||
|
order: 5
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'multi-menu',
|
||||||
|
path: '/multi-menu',
|
||||||
|
component: 'basic',
|
||||||
|
children: [
|
||||||
|
{
|
||||||
|
name: 'multi-menu_first',
|
||||||
|
path: '/multi-menu/first',
|
||||||
|
component: 'multi',
|
||||||
|
children: [
|
||||||
|
{
|
||||||
|
name: 'multi-menu_first_second',
|
||||||
|
path: '/multi-menu/first/second',
|
||||||
|
component: 'self',
|
||||||
|
meta: {
|
||||||
|
title: '二级菜单',
|
||||||
|
requiresAuth: true,
|
||||||
|
icon: 'ic:outline-menu'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'multi-menu_first_second-new',
|
||||||
|
path: '/multi-menu/first/second-new',
|
||||||
|
component: 'multi',
|
||||||
|
children: [
|
||||||
|
{
|
||||||
|
name: 'multi-menu_first_second-new_third',
|
||||||
|
path: '/multi-menu/first/second-new/third',
|
||||||
|
component: 'self',
|
||||||
|
meta: {
|
||||||
|
title: '三级菜单',
|
||||||
|
requiresAuth: true,
|
||||||
|
icon: 'ic:outline-menu'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
meta: {
|
||||||
|
title: '二级菜单(有子菜单)',
|
||||||
|
icon: 'ic:outline-menu'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
meta: {
|
||||||
|
title: '一级菜单',
|
||||||
|
icon: 'ic:outline-menu'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
meta: {
|
||||||
|
title: '多级菜单',
|
||||||
|
icon: 'carbon:menu',
|
||||||
|
order: 7
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'about',
|
||||||
|
path: '/about',
|
||||||
|
component: 'self',
|
||||||
|
meta: {
|
||||||
|
title: '关于',
|
||||||
|
requiresAuth: true,
|
||||||
|
singleLayout: 'basic',
|
||||||
|
icon: 'fluent:book-information-24-regular',
|
||||||
|
order: 8
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
};
|
||||||
|
|
||||||
|
export default routes;
|
35
mock/model/user.ts
Normal file
35
mock/model/user.ts
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
interface ModelUser {
|
||||||
|
userId: string;
|
||||||
|
userName: string;
|
||||||
|
password: string;
|
||||||
|
role: Auth.RoleType;
|
||||||
|
}
|
||||||
|
|
||||||
|
const users: ModelUser[] = [
|
||||||
|
{
|
||||||
|
userId: '0',
|
||||||
|
userName: 'Soybean',
|
||||||
|
password: 'soybean',
|
||||||
|
role: 'super'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
userId: '1',
|
||||||
|
userName: 'Super',
|
||||||
|
password: 'super',
|
||||||
|
role: 'super'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
userId: '2',
|
||||||
|
userName: 'Admin',
|
||||||
|
password: 'admin',
|
||||||
|
role: 'admin'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
userId: '3',
|
||||||
|
userName: 'User01',
|
||||||
|
password: 'user01',
|
||||||
|
role: 'user'
|
||||||
|
}
|
||||||
|
];
|
||||||
|
|
||||||
|
export default users;
|
@ -1,6 +1,5 @@
|
|||||||
/** 百度地图sdk地址 */
|
/** 百度地图sdk地址 */
|
||||||
export const BAIDU_MAP_SDK_URL =
|
export const BAIDU_MAP_SDK_URL = `https://api.map.baidu.com/getscript?v=3.0&ak=KSezYymXPth1DIGILRX3oYN9PxbOQQmU&services=&t=20210201100830&s=1`;
|
||||||
'https://api.map.baidu.com/getscript?v=3.0&ak=KSezYymXPth1DIGILRX3oYN9PxbOQQmU&services=&t=20210201100830&s=1';
|
|
||||||
|
|
||||||
/** 高德地图sdk地址 */
|
/** 高德地图sdk地址 */
|
||||||
export const GAODE_MAP_SDK_URL = 'https://webapi.amap.com/maps?v=2.0&key=e7bd02bd504062087e6563daf4d6721d';
|
export const GAODE_MAP_SDK_URL = 'https://webapi.amap.com/maps?v=2.0&key=e7bd02bd504062087e6563daf4d6721d';
|
||||||
|
@ -1,3 +1,11 @@
|
|||||||
|
/** 用户角色 */
|
||||||
|
export enum EnumUserRole {
|
||||||
|
super = '超级管理员',
|
||||||
|
admin = '管理员',
|
||||||
|
user = '普通用户'
|
||||||
|
// custom = '自定义角色'
|
||||||
|
}
|
||||||
|
|
||||||
/** 登录模块 */
|
/** 登录模块 */
|
||||||
export enum EnumLoginModule {
|
export enum EnumLoginModule {
|
||||||
'pwd-login' = '账密登录',
|
'pwd-login' = '账密登录',
|
||||||
|
@ -6,7 +6,7 @@ const about: AuthRoute.Route = {
|
|||||||
title: '关于',
|
title: '关于',
|
||||||
requiresAuth: true,
|
requiresAuth: true,
|
||||||
singleLayout: 'basic',
|
singleLayout: 'basic',
|
||||||
permissions: ['super', 'admin', 'test'],
|
permissions: ['super', 'admin', 'user'],
|
||||||
icon: 'fluent:book-information-24-regular',
|
icon: 'fluent:book-information-24-regular',
|
||||||
order: 8
|
order: 8
|
||||||
}
|
}
|
||||||
|
6
src/typings/business.d.ts
vendored
6
src/typings/business.d.ts
vendored
@ -4,10 +4,10 @@ declare namespace Auth {
|
|||||||
* 用户角色类型(前端静态路由用角色类型进行路由权限的控制)
|
* 用户角色类型(前端静态路由用角色类型进行路由权限的控制)
|
||||||
* - super: 超级管理员(该权限具有所有路由数据)
|
* - super: 超级管理员(该权限具有所有路由数据)
|
||||||
* - admin: 管理员
|
* - admin: 管理员
|
||||||
* - test: 测试
|
* - user: 用户
|
||||||
* - normal: 普通用户
|
* - custom: 自定义角色
|
||||||
*/
|
*/
|
||||||
type RoleType = 'super' | 'admin' | 'test' | 'normal';
|
type RoleType = keyof typeof import('@/enum').EnumUserRole;
|
||||||
|
|
||||||
/** 用户信息 */
|
/** 用户信息 */
|
||||||
interface UserInfo {
|
interface UserInfo {
|
||||||
|
@ -37,7 +37,7 @@ export function getUserInfo() {
|
|||||||
userId: '',
|
userId: '',
|
||||||
userName: '',
|
userName: '',
|
||||||
userPhone: '',
|
userPhone: '',
|
||||||
userRole: 'normal'
|
userRole: 'user'
|
||||||
};
|
};
|
||||||
const userInfo: Auth.UserInfo = getLocal<Auth.UserInfo>(EnumStorageKey['user-info']) || emptyInfo;
|
const userInfo: Auth.UserInfo = getLocal<Auth.UserInfo>(EnumStorageKey['user-info']) || emptyInfo;
|
||||||
return userInfo;
|
return userInfo;
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
:value="auth.userInfo.userRole"
|
:value="auth.userInfo.userRole"
|
||||||
class="w-120px"
|
class="w-120px"
|
||||||
size="small"
|
size="small"
|
||||||
:options="roleList"
|
:options="options"
|
||||||
@update:value="auth.updateUserRole"
|
@update:value="auth.updateUserRole"
|
||||||
/>
|
/>
|
||||||
<div class="py-12px">
|
<div class="py-12px">
|
||||||
@ -17,7 +17,7 @@
|
|||||||
<div>
|
<div>
|
||||||
<n-button v-permission="'super'" class="mr-12px">super可见</n-button>
|
<n-button v-permission="'super'" class="mr-12px">super可见</n-button>
|
||||||
<n-button v-permission="'admin'" class="mr-12px">admin可见</n-button>
|
<n-button v-permission="'admin'" class="mr-12px">admin可见</n-button>
|
||||||
<n-button v-permission="['admin', 'test']">admin和test可见</n-button>
|
<n-button v-permission="['admin', 'user']">admin和test可见</n-button>
|
||||||
</div>
|
</div>
|
||||||
<div class="py-12px">
|
<div class="py-12px">
|
||||||
<n-gradient-text type="primary" :size="20">权限函数 hasPermission</n-gradient-text>
|
<n-gradient-text type="primary" :size="20">权限函数 hasPermission</n-gradient-text>
|
||||||
@ -25,7 +25,7 @@
|
|||||||
<n-space>
|
<n-space>
|
||||||
<n-button v-if="hasPermission('super')">super可见</n-button>
|
<n-button v-if="hasPermission('super')">super可见</n-button>
|
||||||
<n-button v-if="hasPermission('admin')">admin可见</n-button>
|
<n-button v-if="hasPermission('admin')">admin可见</n-button>
|
||||||
<n-button v-if="hasPermission(['admin', 'test'])">admin和test可见</n-button>
|
<n-button v-if="hasPermission(['admin', 'user'])">admin和user可见</n-button>
|
||||||
</n-space>
|
</n-space>
|
||||||
</n-card>
|
</n-card>
|
||||||
</div>
|
</div>
|
||||||
@ -33,6 +33,8 @@
|
|||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { watch } from 'vue';
|
import { watch } from 'vue';
|
||||||
|
import type { SelectOption } from 'naive-ui';
|
||||||
|
import { EnumUserRole } from '@/enum';
|
||||||
import { useAppStore, useAuthStore } from '@/store';
|
import { useAppStore, useAuthStore } from '@/store';
|
||||||
import { usePermission } from '@/composables';
|
import { usePermission } from '@/composables';
|
||||||
|
|
||||||
@ -40,12 +42,19 @@ const app = useAppStore();
|
|||||||
const auth = useAuthStore();
|
const auth = useAuthStore();
|
||||||
const { hasPermission } = usePermission();
|
const { hasPermission } = usePermission();
|
||||||
|
|
||||||
const roleList = [
|
interface RoleList {
|
||||||
{ label: '超级管理员', value: 'super' },
|
label: string;
|
||||||
{ label: '管理员', value: 'admin' },
|
value: keyof typeof EnumUserRole;
|
||||||
{ label: '测试', value: 'test' }
|
}
|
||||||
|
|
||||||
|
const roleList: RoleList[] = [
|
||||||
|
{ label: EnumUserRole.super, value: 'super' },
|
||||||
|
{ label: EnumUserRole.admin, value: 'admin' },
|
||||||
|
{ label: EnumUserRole.user, value: 'user' }
|
||||||
];
|
];
|
||||||
|
|
||||||
|
const options: SelectOption[] = roleList as unknown as SelectOption[];
|
||||||
|
|
||||||
watch(
|
watch(
|
||||||
() => auth.userInfo.userRole,
|
() => auth.userInfo.userRole,
|
||||||
async () => {
|
async () => {
|
||||||
|
@ -8,7 +8,6 @@
|
|||||||
"build/**/*.ts",
|
"build/**/*.ts",
|
||||||
"mock/**/*.ts",
|
"mock/**/*.ts",
|
||||||
".env-config.ts",
|
".env-config.ts",
|
||||||
"components.d.ts"
|
|
||||||
],
|
],
|
||||||
"exclude": [
|
"exclude": [
|
||||||
"/dist/**",
|
"/dist/**",
|
||||||
|
Loading…
Reference in New Issue
Block a user