1
This commit is contained in:
parent
71bdaaeb4c
commit
d709a0208d
@ -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',
|
||||
})
|
||||
// 清除cookie(H5下)
|
||||
if (typeof document !== 'undefined') {
|
||||
document.cookie = 'x-token=;expires=' + new Date(0).toUTCString()
|
||||
}
|
||||
uni.reLaunch({ url: '/pages/login/index' })
|
||||
}
|
||||
},
|
||||
})
|
||||
|
||||
@ -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')
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user