diff --git a/src/router/index.js b/src/router/index.js index e9699c8..c8350cf 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -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, -}); \ No newline at end of file +}); + +// 添加全局前置守卫 +router.beforeEach((to, from, next) => { + // 如果访问根路径,重定向到/chat + if (to.path === '/') { + next('/chat') + } else { + next() + } +}) + +export default router; \ No newline at end of file