refactor: refactor async routes
This commit is contained in:
23
src/views/dashboard/route.js
Normal file
23
src/views/dashboard/route.js
Normal file
@@ -0,0 +1,23 @@
|
||||
const Layout = () => import('@/layout/index.vue')
|
||||
|
||||
export default {
|
||||
name: 'Dashboard',
|
||||
path: '/',
|
||||
component: Layout,
|
||||
redirect: '/home',
|
||||
meta: {
|
||||
title: 'Dashboard',
|
||||
icon: 'mdi:chart-bar',
|
||||
},
|
||||
children: [
|
||||
{
|
||||
name: 'Home',
|
||||
path: 'home',
|
||||
component: () => import('./index.vue'),
|
||||
meta: {
|
||||
title: '首页',
|
||||
icon: 'mdi:home',
|
||||
},
|
||||
},
|
||||
],
|
||||
}
|
24
src/views/error-page/route.js
Normal file
24
src/views/error-page/route.js
Normal file
@@ -0,0 +1,24 @@
|
||||
const Layout = () => import('@/layout/index.vue')
|
||||
|
||||
export default {
|
||||
name: 'ErrorPage',
|
||||
path: '/error-page',
|
||||
component: Layout,
|
||||
redirect: '/error-page/404',
|
||||
meta: {
|
||||
title: '错误页',
|
||||
icon: 'mdi:alert-circle-outline',
|
||||
index: 4,
|
||||
},
|
||||
children: [
|
||||
{
|
||||
name: 'ERROR-404',
|
||||
path: '404',
|
||||
component: () => import('./404.vue'),
|
||||
meta: {
|
||||
title: '404',
|
||||
icon: 'mdi:alert-circle-outline',
|
||||
},
|
||||
},
|
||||
],
|
||||
}
|
50
src/views/examples/table/route.js
Normal file
50
src/views/examples/table/route.js
Normal file
@@ -0,0 +1,50 @@
|
||||
const Layout = () => import('@/layout/index.vue')
|
||||
|
||||
export default {
|
||||
name: 'Example',
|
||||
path: '/example',
|
||||
component: Layout,
|
||||
redirect: '/example/table',
|
||||
meta: {
|
||||
title: '组件示例',
|
||||
icon: 'mdi:menu',
|
||||
role: ['admin'],
|
||||
requireAuth: true,
|
||||
},
|
||||
children: [
|
||||
{
|
||||
name: 'Table',
|
||||
path: 'table',
|
||||
component: () => import('./index.vue'),
|
||||
redirect: '/example/table/post',
|
||||
meta: {
|
||||
title: '表格',
|
||||
icon: 'mdi:table',
|
||||
role: ['admin'],
|
||||
requireAuth: true,
|
||||
},
|
||||
children: [
|
||||
{
|
||||
name: 'PostList',
|
||||
path: 'post',
|
||||
component: () => import('./post/index.vue'),
|
||||
meta: {
|
||||
title: '文章列表',
|
||||
role: ['admin'],
|
||||
requireAuth: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'PostCreate',
|
||||
path: 'post-create',
|
||||
component: () => import('./post/PostCreate.vue'),
|
||||
meta: {
|
||||
title: '创建文章',
|
||||
role: ['admin'],
|
||||
requireAuth: true,
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
}
|
@@ -1,21 +0,0 @@
|
||||
<template></template>
|
||||
|
||||
<script setup>
|
||||
const { currentRoute, replace } = useRouter()
|
||||
|
||||
const { query } = currentRoute.value
|
||||
let { redirect } = query
|
||||
Reflect.deleteProperty(query, 'redirect')
|
||||
|
||||
if (Array.isArray(redirect)) {
|
||||
redirect = redirect.join('/')
|
||||
}
|
||||
if (redirect.startsWith('/redirect')) {
|
||||
redirect = '/'
|
||||
}
|
||||
|
||||
replace({
|
||||
path: redirect.startsWith('/') ? redirect : '/' + redirect,
|
||||
query,
|
||||
})
|
||||
</script>
|
47
src/views/test-page/route.js
Normal file
47
src/views/test-page/route.js
Normal file
@@ -0,0 +1,47 @@
|
||||
const Layout = () => import('@/layout/index.vue')
|
||||
|
||||
export default {
|
||||
name: 'Test',
|
||||
path: '/test',
|
||||
component: Layout,
|
||||
redirect: '/test/unocss',
|
||||
meta: {
|
||||
title: '基础功能测试',
|
||||
icon: 'mdi:menu',
|
||||
},
|
||||
children: [
|
||||
{
|
||||
name: 'Unocss',
|
||||
path: 'unocss',
|
||||
component: () => import('@/views/test-page/unocss/index.vue'),
|
||||
meta: {
|
||||
title: '测试unocss',
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'Message',
|
||||
path: 'message',
|
||||
component: () => import('@/views/test-page/message/index.vue'),
|
||||
meta: {
|
||||
title: '测试Message',
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'Dialog',
|
||||
path: 'dialog',
|
||||
component: () => import('@/views/test-page/dialog/index.vue'),
|
||||
meta: {
|
||||
title: '测试Dialog',
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'TestKeepAlive',
|
||||
path: 'keep-alive',
|
||||
component: () => import('@/views/test-page/keep-alive/index.vue'),
|
||||
meta: {
|
||||
title: '测试Keep-Alive',
|
||||
keepAlive: true,
|
||||
},
|
||||
},
|
||||
],
|
||||
}
|
Reference in New Issue
Block a user