فهرست منبع

完善门户页的退出登录功能

zengy 2 روز پیش
والد
کامیت
7cb8d6d55d
2فایلهای تغییر یافته به همراه9 افزوده شده و 7 حذف شده
  1. 1 1
      memory/index.md
  2. 8 6
      src/views/portal/index.vue

+ 1 - 1
memory/index.md

@@ -35,7 +35,7 @@ npm run dev       # 默认 http://localhost:80
 ## 当前已知风险
 
 - 业务菜单主要由后端 `/getRouters` 动态下发,前端常量路由不包含完整业务树。
-- 门户页调用 `userStore.logout()`,用户 Store 当前定义的方法名为 `logOut()`,需要后续确认是否修复
+- 门户页退出曾误调 `userStore.logout()`(Store 实际方法名为 `logOut()`),已修正为与 `Navbar` 一致的 `logOut()` + `location.href = '/login'` 整页跳转
 - 供水 19 个页面已按 5.3.2 文档命名补齐并接入后端接口,包含设施 CRUD、设备、监测、报警、统计和轻量 GIS;部署菜单仍依赖后端 `sys_menu` 与角色授权。
 - 排水报警详情 API 请求 `/api/alarm/{id}`,后端实际路径为 `/api/alarm/getById/{id}`。
 - 若干排水请求设置 `X-Silent-Error`,但 Axios 拦截器未处理该标志。

+ 8 - 6
src/views/portal/index.vue

@@ -47,7 +47,7 @@ import { useRouter } from 'vue-router'
 import { DEFAULT_BACKEND_HOME } from '@/router'
 import useUserStore from '@/store/modules/user'
 import usePermissionStore from '@/store/modules/permission'
-import { ElMessageBox, ElMessage } from 'element-plus'
+import { ElMessageBox } from 'element-plus'
 
 const router = useRouter()
 const userStore = useUserStore()
@@ -240,17 +240,19 @@ const enterBackend = () => {
 }
 
 // ==============================================
-// 退出系统(文件1逻辑
+// 退出系统(与 Navbar 保持一致
 // ==============================================
 const logout = () => {
   ElMessageBox.confirm('确定要退出登录吗?', '提示', {
     confirmButtonText: '确定',
     cancelButtonText: '取消',
     type: 'warning'
-  }).then(async () => {
-    await userStore.logout()
-    ElMessage.success('退出成功')
-    router.push('/login')
+  }).then(() => {
+    // Store 中的方法名是 logOut,logout() 不存在,调用会静默失败导致没有真正退出
+    userStore.logOut().then(() => {
+      // 整页跳转回登录页,刷新路由实例以清除已动态注册的路由
+      location.href = '/login'
+    })
   }).catch(() => {})
 }