This commit is contained in:
Quincy_J 2025-07-29 23:15:20 +08:00
parent 71bdaaeb4c
commit d709a0208d
2 changed files with 14 additions and 7 deletions

View File

@ -120,6 +120,7 @@
<script lang="ts" setup>
import { ref } from 'vue'
import { getCanBookExamListAPI } from '@/service/exam'
import { logoutAPI } from '@/service/user'
import { onLoad, onShow } from '@dcloudio/uni-app'
defineOptions({
@ -210,20 +211,24 @@ const handleModifyProfile = () => {
}
// 退
const handleLogout = () => {
const handleLogout = async () => {
showUserMenu.value = false
uni.showModal({
title: '提示',
content: '确定要退出登录吗?',
success: (res) => {
success: async (res) => {
if (res.confirm) {
//
try {
await logoutAPI()
} catch (e) {}
uni.removeStorageSync('token')
uni.removeStorageSync('x-token')
uni.removeStorageSync('loginData')
//
uni.reLaunch({
url: '/pages/login/index',
})
// cookieH5
if (typeof document !== 'undefined') {
document.cookie = 'x-token=;expires=' + new Date(0).toUTCString()
}
uni.reLaunch({ url: '/pages/login/index' })
}
},
})

View File

@ -3,3 +3,5 @@ import type { BaseResponse } from '../login/type'
export const changePasswordAPI = (data: { oldPassword: string; newPassword: string }) =>
request.post<BaseResponse<any>>('/user/updatePassword', data)
export const logoutAPI = () => request.post<BaseResponse<any>>('/jwt/jsonInBlacklist')