All checks were successful
site-dist-deploy / build-and-deploy (push) Successful in 1m27s
53 lines
1.2 KiB
TypeScript
53 lines
1.2 KiB
TypeScript
import { createRouter, createWebHistory } from 'vue-router'
|
|
|
|
const router = createRouter({
|
|
history: createWebHistory(import.meta.env.BASE_URL),
|
|
routes: [
|
|
{
|
|
path: '/',
|
|
name: 'home',
|
|
component: () => import('../pages/Home/index.vue'),
|
|
},
|
|
{
|
|
path: '/help',
|
|
name: 'help',
|
|
component: () => import('../pages/Help/index.vue'),
|
|
},
|
|
{
|
|
path: '/user-center',
|
|
name: 'user-center',
|
|
component: () => import('../pages/UserCenter/index.vue'),
|
|
},
|
|
{
|
|
path: '/terms',
|
|
name: 'terms-of-service',
|
|
component: () => import('../pages/TermsOfService/index.vue'),
|
|
},
|
|
{
|
|
path: '/privacy',
|
|
name: 'privacy-policy',
|
|
component: () => import('../pages/PrivacyPolicy/index.vue'),
|
|
},
|
|
{
|
|
path: '/login/:token',
|
|
name: 'login-redirect',
|
|
component: () => import('../pages/LoginRedirect/index.vue'),
|
|
},
|
|
{
|
|
path: '/:pathMatch(.*)*',
|
|
name: 'not-found',
|
|
redirect: '/',
|
|
},
|
|
],
|
|
})
|
|
|
|
router.beforeEach((to, _from, next) => {
|
|
if (to.path === '/user-center' && !localStorage.getItem('Authorization')) {
|
|
next({ path: '/', query: { login: 'true' } })
|
|
} else {
|
|
next()
|
|
}
|
|
})
|
|
|
|
export default router
|