58 lines
1.7 KiB
TypeScript
58 lines
1.7 KiB
TypeScript
import { createRouter, createWebHistory } from 'vue-router'
|
|
|
|
export const router = createRouter({
|
|
history: createWebHistory(),
|
|
routes: [
|
|
{
|
|
path: '/',
|
|
component: () => import('./pages/HomePage.vue'),
|
|
meta: { title: '让专注,从容开始' },
|
|
},
|
|
{
|
|
path: '/downloads',
|
|
component: () => import('./pages/DownloadsPage.vue'),
|
|
meta: { title: '软件下载' },
|
|
},
|
|
{
|
|
path: '/marketplace',
|
|
component: () => import('./pages/MarketplacePage.vue'),
|
|
meta: { title: '主题市场' },
|
|
},
|
|
{
|
|
path: '/marketplace/upload',
|
|
component: () => import('./pages/UploadPage.vue'),
|
|
meta: { title: '分享主题' },
|
|
},
|
|
{
|
|
path: '/marketplace/profile',
|
|
component: () => import('./pages/ProfilePage.vue'),
|
|
meta: { title: '个人中心' },
|
|
},
|
|
{
|
|
path: '/marketplace/admin',
|
|
component: () => import('./pages/AdminPage.vue'),
|
|
meta: { title: '主题审核' },
|
|
},
|
|
{ path: '/changelog', redirect: '/downloads' },
|
|
{
|
|
path: '/errors/:code(400|401|403|404|500|502|503)',
|
|
component: () => import('./pages/ErrorPage.vue'),
|
|
meta: { title: '请求错误' },
|
|
},
|
|
{
|
|
path: '/:pathMatch(.*)*',
|
|
component: () => import('./pages/ErrorPage.vue'),
|
|
meta: { title: '页面未找到' },
|
|
},
|
|
],
|
|
scrollBehavior(to, from, saved) {
|
|
if (saved) return saved
|
|
if (to.hash && to.path === '/') return { el: to.hash, top: 100, behavior: 'smooth' }
|
|
if (to.path === from.path) return false
|
|
return { top: 0 }
|
|
},
|
|
})
|
|
router.afterEach((to) => {
|
|
document.title = `AutoLibrary · ${String(to.meta.title || '图书馆自动化')}`
|
|
})
|