update router/index.js

This commit is contained in:
不做码农 2022-04-26 08:46:26 +08:00
parent 62cdedb9df
commit 3cdcf5303f

View File

@ -23,64 +23,80 @@ import Layout from '@/layout'
// 公共路由 // 公共路由
export const constantRoutes = [ export const constantRoutes = [
{
path: '/redirect',
component: Layout,
hidden: true,
children: [
{ {
path: '/redirect/:path(.*)', path: '/redirect',
component: () => import('@/views/redirect/index.vue') component: Layout,
}] hidden: true,
}, children: [
{ {
path: '/login', path: '/redirect/:path(.*)',
component: () => import('@/views/login'), component: () => import('@/views/redirect/index.vue')
hidden: true }]
}, },
// {
// path: '/register',
// component: () => import('@/views/register'),
// hidden: true
// },
{
path: "/:pathMatch(.*)*",
component: () => import('@/views/error/404'),
hidden: true
},
{
path: '/401',
component: () => import('@/views/error/401'),
hidden: true
},
{
path: '',
component: Layout,
redirect: '/index',
children: [
{ {
path: '/index', path: '/login',
component: () => import('@/views/index'), component: () => import('@/views/login'),
name: 'Index', hidden: true
meta: { title: '首页', icon: 'dashboard', affix: true } },
}] // {
}, // path: '/register',
{ // component: () => import('@/views/register'),
path: '/user', // hidden: true
component: Layout, // },
hidden: true,
redirect: 'noredirect',
children: [
{ {
path: 'profile', path: "/:pathMatch(.*)*",
component: () => import('@/views/system/user/profile/index'), component: () => import('@/views/error/404'),
name: 'Profile', hidden: true
meta: { title: '个人中心', icon: 'user' } },
}] {
}]; path: '/401',
component: () => import('@/views/error/401'),
hidden: true
},
{
path: '',
component: Layout,
redirect: '/index',
children: [
{
path: '/index',
component: () => import('@/views/index'),
name: 'Index',
meta: { title: '首页', icon: 'dashboard', affix: true }
}]
},
{
path: '/user',
component: Layout,
hidden: true,
redirect: 'noredirect',
children: [
{
path: 'profile',
component: () => import('@/views/system/user/profile/index'),
name: 'Profile',
meta: { title: '个人中心', icon: 'user' }
}]
},
// 不用可删掉
{
path: '',
component: Layout,
hidden: false,
meta: { title: '组件示例', icon: 'icon', noCache: 'fasle' },
children: [
{
path: 'icon',
component: () => import('@/views/components/icons/index'),
name: 'icon',
meta: { title: '图标icon', icon: 'icon1', noCache: 'fasle' }
}]
},
];
const router = createRouter({ const router = createRouter({
history: createWebHistory(import.meta.env.VITE_APP_ROUTER_PREFIX), history: createWebHistory(
import.meta.env.VITE_APP_ROUTER_PREFIX),
routes: constantRoutes, routes: constantRoutes,
// scrollBehavior(to, from, savedPosition) { // scrollBehavior(to, from, savedPosition) {
// if (savedPosition) { // if (savedPosition) {