You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
OneAuth/oaweb/src/router/routes.ts

72 lines
1.7 KiB
TypeScript

import { Auths } from 'src/models/auth';
import { RouteRecordRaw } from 'vue-router';
declare module 'vue-router' {
interface RouteMeta {
// 是可选的
isAdmin?: boolean
title?: string
// 每个路由都必须声明
requiresAuth: boolean
checkAuth?: (a: Auths, r?: RouteLocationNormalized) => boolean
}
}
2 years ago
function loadcomponents(path: string, name: string, main: string) {
return {
path: path,
name: name,
components: {
default: () => import("../pages/" + main + ".vue"),
}
}
}
const routes: RouteRecordRaw[] = [
{
path: '/',
component: () => import('layouts/MainLayout.vue'),
meta: {
requiresAuth: true,
},
2 years ago
redirect: 'home',
children: [
2 years ago
loadcomponents('home', 'home', 'IndexPage'),
loadcomponents('user', 'user', '404'),
2 years ago
loadcomponents('file', 'file', '404'),
2 years ago
loadcomponents('settings', 'settings', '404'),
{
2 years ago
path: 'app/:id?',
component: () => import("../layouts/AppLayout.vue"),
redirect: { name: 'app.home' },
children: [
2 years ago
loadcomponents('home', 'app.home', 'AppHome'),
loadcomponents('user', 'app.user', 'AppUser'),
loadcomponents('settings', 'app.settings', 'IndexPage'),
2 years ago
]
}
],
},
{
path: '/login/:uuid?',
name: 'login',
2 years ago
component: () => import('../pages/login.vue'),
},
{
path: '/register/:uuid?',
name: 'register',
2 years ago
component: () => import('../pages/register.vue'),
},
// Always leave this as last one,
// but you can also remove it
{
path: '/:catchAll(.*)*',
2 years ago
component: () => import('../pages/404.vue'),
},
];
export default routes;