|
|
@@ -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(() => {})
|
|
|
}
|
|
|
|