update: Implement global route guard to redirect root path to /chat
This commit is contained in:
parent
0d3d30952d
commit
2c70882647
|
@ -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;
|
Loading…
Reference in New Issue