1
This commit is contained in:
parent
71bdaaeb4c
commit
d709a0208d
@ -120,6 +120,7 @@
|
|||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { ref } from 'vue'
|
import { ref } from 'vue'
|
||||||
import { getCanBookExamListAPI } from '@/service/exam'
|
import { getCanBookExamListAPI } from '@/service/exam'
|
||||||
|
import { logoutAPI } from '@/service/user'
|
||||||
import { onLoad, onShow } from '@dcloudio/uni-app'
|
import { onLoad, onShow } from '@dcloudio/uni-app'
|
||||||
|
|
||||||
defineOptions({
|
defineOptions({
|
||||||
@ -210,20 +211,24 @@ const handleModifyProfile = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 退出登录
|
// 退出登录
|
||||||
const handleLogout = () => {
|
const handleLogout = async () => {
|
||||||
showUserMenu.value = false
|
showUserMenu.value = false
|
||||||
uni.showModal({
|
uni.showModal({
|
||||||
title: '提示',
|
title: '提示',
|
||||||
content: '确定要退出登录吗?',
|
content: '确定要退出登录吗?',
|
||||||
success: (res) => {
|
success: async (res) => {
|
||||||
if (res.confirm) {
|
if (res.confirm) {
|
||||||
// 清除本地存储
|
try {
|
||||||
|
await logoutAPI()
|
||||||
|
} catch (e) {}
|
||||||
uni.removeStorageSync('token')
|
uni.removeStorageSync('token')
|
||||||
|
uni.removeStorageSync('x-token')
|
||||||
uni.removeStorageSync('loginData')
|
uni.removeStorageSync('loginData')
|
||||||
// 跳转到登录页
|
// 清除cookie(H5下)
|
||||||
uni.reLaunch({
|
if (typeof document !== 'undefined') {
|
||||||
url: '/pages/login/index',
|
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 }) =>
|
export const changePasswordAPI = (data: { oldPassword: string; newPassword: string }) =>
|
||||||
request.post<BaseResponse<any>>('/user/updatePassword', data)
|
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