码桶
发现社区成员的开源项目
index.ts885 B
import { createRouter, createWebHistory } from 'vue-router'
import type { RouteRecordRaw } from 'vue-router'
import HomeView from '@/views/HomeView.vue'
const routes: RouteRecordRaw[] = [
{
path: '/',
name: 'Home',
component: HomeView,
},
{
path: '/about',
name: 'About',
component: () => import('@/views/AboutView.vue'),
},
{
path: '/:pathMatch(.*)*',
name: 'NotFound',
component: () => import('@/views/NotFoundView.vue'),
},
]
const router = createRouter({
history: createWebHistory(import.meta.env.BASE_URL),
routes,
scrollBehavior() {
return { top: 0 }
},
})
router.afterEach((to) => {
if (to.path === '/') {
document.title = 'FlowLoss'
return
}
if (to.path === '/about') {
document.title = '关于 - FlowLoss'
return
}
document.title = '页面未找到 - FlowLoss'
})
export default router