Selaa lähdekoodia

fix(web): 修复退出登录遮罩冲突, 添加beforeunload防护

Sisyphus 2 kuukautta sitten
vanhempi
sitoutus
7a3b7ead89
1 muutettua tiedostoa jossa 8 lisäystä ja 5 poistoa
  1. 8 5
      cfc-web/src/views/Layout.vue

+ 8 - 5
cfc-web/src/views/Layout.vue

@@ -315,6 +315,10 @@ export default {
       return this.displayRoles
     }
   },
+  mounted() {
+    // 清除可能的 beforeunload 处理,防止页面刷新弹出"离开网站?"提示
+    window.onbeforeunload = null
+  },
   methods: {
     hasPerm(required) {
       return hasPermission(this.effectivePerms, required)
@@ -426,10 +430,13 @@ export default {
       this.$message.success('已复制邀请码')
     },
     handleLogout() {
+      // 不使用 modal 遮罩(全局 .v-modal { display:none } 会与 $confirm 的遮罩冲突)
       this.$confirm('确定要退出登录吗?', '提示', {
         confirmButtonText: '确定',
         cancelButtonText: '取消',
-        type: 'warning'
+        type: 'warning',
+        modal: false,
+        customClass: 'cfc-logout-confirm'
       }).then(() => {
         localStorage.removeItem('token')
         localStorage.removeItem('role')
@@ -448,10 +455,6 @@ export default {
 .v-modal {
   display: none !important;
 }
-/* 保留 $confirm / MessageBox 的遮罩 */
-.el-message-box .v-modal {
-  display: block !important;
-}
 
 .layout-container {
   height: 100vh;