feat(用户页面): 添加点击头像退出登录功能

在用户页面中,点击用户头像时会弹出确认对话框,确认后清除用户信息并跳转到登录页面
This commit is contained in:
dzq 2025-04-25 09:58:19 +08:00
parent 150487bbfb
commit c4562333c0
1 changed files with 15 additions and 1 deletions

View File

@ -4,6 +4,7 @@ import { useWxStore } from '@/pinia/stores/wx'
import { useAb98UserStore } from '@/pinia/stores/ab98-user'
import { storeToRefs } from 'pinia'
import { publicPath } from "@/common/utils/path"
import { showConfirmDialog } from 'vant';
const router = useRouter()
const wxStore = useWxStore()
@ -16,7 +17,19 @@ const name = computed(() => {
return userName.value || qyName.value || '未知用户'
})
const userAvatar = face_img.value ? face_img.value : `${publicPath}img/1.jpg`
const userAvatar = face_img.value ? face_img.value : `${publicPath}img/1.jpg`;
const handleLogout = () => {
showConfirmDialog({
title: '退出登录',
message: '确定要退出当前账号吗?',
}).then(() => {
ab98UserStore.clearUserInfo();
router.push('/ab98');
}).catch(() => {
//
});
}
</script>
<template>
@ -31,6 +44,7 @@ const userAvatar = face_img.value ? face_img.value : `${publicPath}img/1.jpg`
height="80"
:src="userAvatar"
class="mr-4"
@click="handleLogout"
/>
<div>
<div class="text-lg font-bold mb-2">{{ name }}</div>