feat(用户页面): 添加点击头像退出登录功能
在用户页面中,点击用户头像时会弹出确认对话框,确认后清除用户信息并跳转到登录页面
This commit is contained in:
parent
150487bbfb
commit
c4562333c0
|
@ -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>
|
||||
|
|
Loading…
Reference in New Issue