diff --git a/frontend/src/components/UserMenu.vue b/frontend/src/components/UserMenu.vue index 16207e1..f9da602 100644 --- a/frontend/src/components/UserMenu.vue +++ b/frontend/src/components/UserMenu.vue @@ -136,7 +136,11 @@ function handleLogout() { auth.logout() ui.showToast('已退出登录') emit('close') - window.location.reload() + if (router.currentRoute.value.meta.requiresAuth) { + router.push('/') + } else { + window.location.reload() + } } onMounted(loadNotifications) diff --git a/frontend/src/router/index.js b/frontend/src/router/index.js index 8fcab38..68a69ff 100644 --- a/frontend/src/router/index.js +++ b/frontend/src/router/index.js @@ -10,11 +10,13 @@ const routes = [ path: '/manage', name: 'RecipeManager', component: () => import('../views/RecipeManager.vue'), + meta: { requiresAuth: true }, }, { path: '/inventory', name: 'Inventory', component: () => import('../views/Inventory.vue'), + meta: { requiresAuth: true }, }, { path: '/oils', @@ -25,26 +27,31 @@ const routes = [ path: '/projects', name: 'Projects', component: () => import('../views/Projects.vue'), + meta: { requiresAuth: true }, }, { path: '/mydiary', name: 'MyDiary', component: () => import('../views/MyDiary.vue'), + meta: { requiresAuth: true }, }, { path: '/audit', name: 'AuditLog', component: () => import('../views/AuditLog.vue'), + meta: { requiresAuth: true }, }, { path: '/bugs', name: 'BugTracker', component: () => import('../views/BugTracker.vue'), + meta: { requiresAuth: true }, }, { path: '/users', name: 'UserManagement', component: () => import('../views/UserManagement.vue'), + meta: { requiresAuth: true }, }, ]