2023-09-12 10:11:27 +08:00
|
|
|
import { createRouter, createWebHistory, RouteRecordRaw, createWebHashHistory } from 'vue-router'
|
2023-01-06 16:00:15 +08:00
|
|
|
import { defineAsyncComponent } from 'vue'
|
|
|
|
|
const _import = (path : string) => defineAsyncComponent(() => import(`../views/${path}.vue`));
|
|
|
|
|
|
|
|
|
|
const routes: Array<RouteRecordRaw> = [
|
|
|
|
|
{
|
|
|
|
|
path: "/",
|
|
|
|
|
// redirect重定向
|
|
|
|
|
redirect: "/login"
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
path: '/login',
|
|
|
|
|
name: 'login',
|
|
|
|
|
component: _import('LoginPage')
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
path: '/home',
|
|
|
|
|
name: 'home',
|
|
|
|
|
component: _import('HomeView')
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
path: '/demo',
|
|
|
|
|
name: 'demo',
|
|
|
|
|
component: _import('Demo')
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
path: '/history',
|
|
|
|
|
name: 'history',
|
|
|
|
|
component: _import('HistoryPage')
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
path: '/library',
|
|
|
|
|
name: 'library',
|
|
|
|
|
component: _import('LibraryPage')
|
|
|
|
|
},
|
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
const router = createRouter({
|
|
|
|
|
history: createWebHistory(process.env.BASE_URL),
|
2023-09-12 10:11:27 +08:00
|
|
|
// history: createWebHashHistory(),
|
2023-01-06 16:00:15 +08:00
|
|
|
routes
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
export default router
|