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={() => {
|
2024-09-29 16:16:13 +08:00
|
|
|
router.go('global-login')
|
2024-09-13 10:15:43 +08:00
|
|
|
}}
|
|
|
|
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: () => {
|
2024-09-29 16:16:13 +08:00
|
|
|
router.go('')
|
2024-09-13 18:27:39 +08:00
|
|
|
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={() => {
|
2024-09-29 16:16:13 +08:00
|
|
|
router.go('global-login')
|
2024-09-13 10:15:43 +08:00
|
|
|
}}
|
|
|
|
>
|
|
|
|
登录
|
|
|
|
</Button>
|
|
|
|
)}
|
|
|
|
</div>
|
2024-09-11 13:46:40 +08:00
|
|
|
</div>
|
|
|
|
)
|
|
|
|
})
|