Files
admin-govern/src/router/static.ts

85 lines
2.1 KiB
TypeScript
Raw Normal View History

2023-12-21 16:42:39 +08:00
import type { RouteRecordRaw } from 'vue-router'
const pageTitle = (name: string): string => {
return `pagesTitle.${name}`
}
/**
*
*/
export const adminBaseRoutePath = '/admin'
export const adminBaseRoute = {
path: adminBaseRoutePath,
name: 'admin',
component: () => import('@/layouts/admin/index.vue'),
// 直接重定向到 loading 路由
redirect: adminBaseRoutePath + '/loading',
meta: {
title: `pagesTitle.admin`
},
children: [
{
path: 'loading/:to?',
name: 'adminMainLoading',
component: () => import('@/layouts/common/components/loading.vue'),
meta: {
title: `pagesTitle.loading`
}
}
]
}
/*
*
* ./static push
*/
const staticRoutes: Array<RouteRecordRaw> = [
adminBaseRoute,
2023-12-22 10:22:22 +08:00
{
path: '/',
redirect: (to) => {
return {
name: 'adminMainLoading'
}
}
},
2023-12-21 16:42:39 +08:00
{
// 管理员登录页 - 不放在 adminBaseRoute.children 因为登录页不需要使用后台的布局
path: '/login',
name: 'login',
component: () => import('@/views/user/login.vue'),
meta: {
title: pageTitle('login')
}
},
{
path: '/:path(.*)*',
redirect: '/404'
},
{
// 404
path: '/404',
name: 'notFound',
component: () => import('@/views/common/error/404.vue'),
meta: {
title: pageTitle('notFound') // 页面不存在
}
2023-12-22 10:22:22 +08:00
},
{
// 后台找不到页面了-可能是路由未加载上
path: adminBaseRoutePath + ':path(.*)*',
redirect: (to) => {
return {
name: 'adminMainLoading',
params: {
to: JSON.stringify({
path: to.path,
query: to.query
})
}
}
}
2023-12-21 16:42:39 +08:00
}
]
export default staticRoutes