xyyd-fatfox/src/user/UserPage.tsx

87 lines
2.6 KiB
TypeScript
Raw Normal View History

2024-09-11 13:46:40 +08:00
import useRouterStore from '@/useRouterStore'
2024-09-18 16:27:43 +08:00
import { Button, Modal, Tag } from 'ant-design-vue'
2024-09-09 17:53:07 +08:00
import { defineComponent } from 'vue'
2024-09-13 10:15:43 +08:00
import AvatarCircle from './AvatarCircle'
import useUserStore from './useUserStore'
import { EditOutlined, LoginOutlined, LogoutOutlined } from '@ant-design/icons-vue'
2024-09-18 16:27:43 +08:00
import { globalToast } from '@/main'
2024-09-13 10:15:43 +08:00
const labelStyle = 'w-16 text-black/60'
2024-09-09 17:53:07 +08:00
2024-09-11 13:46:40 +08:00
export default defineComponent(() => {
const router = useRouterStore()
2024-09-13 10:15:43 +08:00
const user = useUserStore()
2024-09-11 13:46:40 +08:00
return () => (
2024-09-13 10:15:43 +08:00
<div class="absolute left-0 top-0 w-full h-full p-4 flex flex-col">
<div class="flex justify-center py-4">
<div class="w-16 h-16 relative">
<AvatarCircle />
</div>
</div>
{user.isLogin && (
<div class="h-0 flex-grow py-4 px-12">
<div class="flex py-2">
<div class={labelStyle}>:</div>
<div class="w-0 flex-grow overflow-hidden text-ellipsis whitespace-nowrap break-all">
{user.profile.username}
</div>
</div>
<div class="flex py-2">
<div class={labelStyle}>:</div> {user.profile.birthday}
</div>
<div class="flex py-2">
<div class={labelStyle}>:</div>
<Tag color={user.profile.gender === 1 ? 'blue' : 'red'}>
{user.profile.gender === 1 ? '男' : '女'}
</Tag>
</div>
</div>
)}
<div class="flex justify-around items-center my-10">
{user.isLogin ? (
<>
<Button
onClick={() => {
router.path = 'global-login'
}}
icon={<EditOutlined />}
2024-09-13 18:27:39 +08:00
type="primary"
2024-09-13 10:15:43 +08:00
>
</Button>
2024-09-13 18:27:39 +08:00
<Button
type="text"
icon={<LogoutOutlined />}
onClick={() => {
Modal.confirm({
title: '退出登录',
content: '确定要退出登录吗?',
onOk: () => {
router.path = ''
user.logout()
2024-09-18 16:27:43 +08:00
globalToast.success('已退出登录')
2024-09-13 18:27:39 +08:00
}
})
}}
>
退
</Button>
2024-09-13 10:15:43 +08:00
</>
) : (
<Button
type="primary"
icon={<LoginOutlined />}
size="large"
onClick={() => {
router.path = 'global-login'
}}
>
</Button>
)}
</div>
2024-09-11 13:46:40 +08:00
</div>
)
})