feat: add layout of chat and login

This commit is contained in:
Quicy
2026-01-29 14:57:14 +08:00
parent 041f1afde0
commit e7500e5a12
18 changed files with 507 additions and 153 deletions
+28 -1
View File
@@ -1,8 +1,35 @@
import { createRouter, createWebHistory } from 'vue-router'
const routes = [
{
path: '/',
redirect: '/login'
},
{
name: 'Login',
path: '/login',
component: () => import('@/pages/login/index.vue')
}, {
name: 'Chat',
path: '/chat',
component: () => import('@/pages/chat/index.vue'),
}
]
const router = createRouter({
history: createWebHistory(),
routes: [],
routes,
})
router.beforeEach((to) => {
const token = localStorage.getItem('token')
if (to.fullPath !== '/login') {
return token ? true : { name: 'Login' }
} else {
return token ? { name: 'Chat' } : true
}
})
export default router