58 lines
1.2 KiB
TypeScript
58 lines
1.2 KiB
TypeScript
import type { RouteRecordRaw } from 'vue-router'
|
|
import { createRouter, createWebHistory } from 'vue-router'
|
|
import { useAppStore } from '@/stores/app'
|
|
import Login from '@/pages/common/login.vue'
|
|
import Layout from '@/layouts/Layout.vue'
|
|
|
|
export const asyncRoutes: RouteRecordRaw[] = [
|
|
{
|
|
name: 'classify',
|
|
path: 'classify',
|
|
component: () => import('@/pages/classify/index.vue'),
|
|
meta: {
|
|
title: '分类管理',
|
|
icon: 'system-3'
|
|
}
|
|
},
|
|
{
|
|
name: 'carousal',
|
|
path: 'carousal',
|
|
component: () => import('@/pages/carousal/index.vue'),
|
|
meta: {
|
|
title: '轮播图管理',
|
|
icon: 'system-3'
|
|
}
|
|
},
|
|
]
|
|
|
|
const router = createRouter({
|
|
history: createWebHistory(import.meta.env.BASE_URL),
|
|
routes: [
|
|
{
|
|
name: 'layout',
|
|
component: Layout,
|
|
path: '/',
|
|
redirect: {
|
|
name: 'classify'
|
|
},
|
|
children: asyncRoutes
|
|
},
|
|
{
|
|
name: 'login',
|
|
path: '/login',
|
|
component: Login
|
|
}
|
|
]
|
|
})
|
|
|
|
// router.beforeEach((to, from, next) => {
|
|
// if (to.name !== 'login') {
|
|
// const appStore = useAppStore()
|
|
// appStore.isLogin ? next() : next({ name: 'login' })
|
|
// return
|
|
// }
|
|
// next()
|
|
// })
|
|
|
|
export default router
|