From cd805632ad874f91590293b1356a93b14bd19254 Mon Sep 17 00:00:00 2001 From: xiaowang Date: Tue, 24 Feb 2026 14:12:27 +0800 Subject: [PATCH] =?UTF-8?q?=E7=99=BB=E5=87=BA=E5=8A=9F=E8=83=BD=E5=AE=9E?= =?UTF-8?q?=E7=8E=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Frontend/src/views/ProfileView.vue | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/Frontend/src/views/ProfileView.vue b/Frontend/src/views/ProfileView.vue index 4a5ad290..b1b5b784 100644 --- a/Frontend/src/views/ProfileView.vue +++ b/Frontend/src/views/ProfileView.vue @@ -95,7 +95,8 @@ import { BellOutlined, QuestionCircleOutlined } from '@ant-design/icons-vue' -import { message } from 'ant-design-vue' +import { message, Modal } from 'ant-design-vue' +import { authApi } from '@/api/auth' const router = useRouter() @@ -169,8 +170,28 @@ const handleMenuClick = (key: string) => { // 处理退出登录 const handleLogout = () => { - console.log('退出登录被点击') - message.success('已退出登录') + Modal.confirm({ + title: '确认退出登录', + content: '确定要退出登录吗?', + okText: '确定', + cancelText: '取消', + onOk: async () => { + try { + await authApi.logout() + } catch (error) { + console.error('登出接口调用失败:', error) + } finally { + // 清除本地存储的token + localStorage.removeItem('accessToken') + localStorage.removeItem('refreshToken') + sessionStorage.removeItem('accessToken') + + message.success('已退出登录') + // 跳转到登录页面 + router.push('/auth') + } + } + }) } // 处理设置图标点击