fix(frontend): 退出登录增加原生确认兜底,修复点击无响应
This commit is contained in:
@@ -167,16 +167,26 @@ async function go(path) {
|
||||
}
|
||||
|
||||
async function logout() {
|
||||
let confirmed = false
|
||||
try {
|
||||
await ElMessageBox.confirm('确定退出登录吗?', '退出登录', {
|
||||
confirmButtonText: '退出',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning',
|
||||
})
|
||||
} catch {
|
||||
return
|
||||
confirmed = true
|
||||
} catch (error) {
|
||||
const reason = String(error || '').toLowerCase()
|
||||
if (reason === 'cancel' || reason === 'close') return
|
||||
try {
|
||||
confirmed = window.confirm('确定退出登录吗?')
|
||||
} catch {
|
||||
confirmed = false
|
||||
}
|
||||
}
|
||||
|
||||
if (!confirmed) return
|
||||
|
||||
await userStore.logout()
|
||||
window.location.href = '/login'
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user