update: Implement global route guard to redirect root path to /chat

This commit is contained in:
Lexcubia 2025-04-20 20:56:00 +08:00
parent 0d3d30952d
commit 2c70882647
1 changed files with 13 additions and 2 deletions

View File

@ -15,7 +15,6 @@ const routes = [
component: () => import("@/layouts/blank.vue"),
},
],
redirect: "/chat"
},
{
path: "/chat",
@ -36,4 +35,16 @@ const routes = [
export const router = createRouter({
history: createWebHistory(),
routes,
});
});
// 添加全局前置守卫
router.beforeEach((to, from, next) => {
// 如果访问根路径,重定向到/chat
if (to.path === '/') {
next('/chat')
} else {
next()
}
})
export default router;