xyyd-fatfox/src/user/UserPage.tsx

193 lines
6.4 KiB
TypeScript
Raw Normal View History

2024-09-11 13:46:40 +08:00
import useRouterStore from '@/useRouterStore'
2024-11-19 18:13:43 +08:00
import { Button, Select } from 'ant-design-vue'
import { computed, defineComponent, ref } from 'vue'
2024-09-13 10:15:43 +08:00
import AvatarCircle from './AvatarCircle'
import useUserStore from './useUserStore'
2024-11-19 18:13:43 +08:00
import { LoginOutlined } from '@ant-design/icons-vue'
import { FaRegularEdit } from 'oh-vue-icons/icons'
import clsx from 'clsx'
import useLayoutStore from '@/layout/useLayoutStore'
2024-11-19 18:13:43 +08:00
import { addIcons, OhVueIcon } from 'oh-vue-icons'
import background from '@/layout/background'
addIcons(FaRegularEdit)
2024-09-09 17:53:07 +08:00
2024-09-11 13:46:40 +08:00
export default defineComponent(() => {
const router = useRouterStore()
const layout = useLayoutStore()
2024-09-13 10:15:43 +08:00
const user = useUserStore()
2024-11-19 18:13:43 +08:00
const open = ref(false)
const isGame = computed(() => {
return layout.state.current === 0
})
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">
2024-11-19 18:13:43 +08:00
{user.isLogin ? (
<>
<div class={'flex flex-col'}>
<span
class={clsx(
'text-[14px] font-bold',
useLayoutStore().state.current === 0 ? 'text-white' : ' text-[#333]'
)}
>
</span>
<div
class={clsx(
'w-full h-[1px] bg-black/10 mt-1 mb-2',
useLayoutStore().state.current === 0 ? 'bg-white/10' : ' bg-black/10'
)}
></div>
</div>
<div class="flex pl-4 py-4 w-full gap-x-4">
<div class="w-16 h-16 rounded-full group overflow-hidden relative">
<AvatarCircle />
<div
onClick={() => {
router.go('custom-header')
}}
class={
'absolute hidden left-0 cursor-pointer top-0 opacity-60 rounded-full w-full h-full bg-black z-10 group-hover:flex items-center justify-center'
}
>
<OhVueIcon name={FaRegularEdit.name} fill="#ddd"></OhVueIcon>
</div>
</div>
<div class={'flex flex-col h-full justify-between text-[14px] py-1'}>
<div class={'flex gap-x-1 items-center'}>
<span class={clsx(' w-[50px]', isGame.value ? 'text-[#fff9]' : 'text-[#666]')}>
:
</span>
<input
onBlur={() => {
user.updateProfile()
}}
class={
'text-[#666] w-[150px] bg-transparent focus:bg-black/[0.05] border-none outline-none px-1 py-[2px]'
}
v-model={user.profile.username}
></input>
</div>
<div class={'flex gap-x-1 items-center'}>
<span class={clsx(' w-[50px]', isGame.value ? 'text-[#fff9]' : 'text-[#666]')}>
&ensp;&ensp;:
</span>
<Select
defaultValue={user.profile.gender}
v-model={user.profile.gender}
class={
'w-[150px] bg-transparent appearance-none focus:bg-black/[0.05] overflow-hidden border-none outline-none px-1 py-[2px]'
}
style={{
background: 'transparent !important'
}}
onChange={(e: any) => {
user.profile.gender = e
user.updateProfile()
}}
options={[
{
label: '男',
value: 1
},
{
label: '女',
value: 2
},
{
label: '未知',
value: 0
}
]}
></Select>
</div>
</div>
</div>
<div
onClick={() => {
open.value = true
}}
class={
'w-full h-[32px] mt-5 cursor-pointer hover:opacity-90 flex items-center justify-center text-[13px] rounded bg-[#e5e5e5] text-[#999]'
}
>
退
</div>
</>
) : (
<Button
type="primary"
icon={<LoginOutlined />}
size="large"
onClick={() => {
router.go('global-login')
}}
>
</Button>
)}
{open.value && (
<div
class={clsx(
2024-11-19 18:13:43 +08:00
'w-[300px] h-[210px] absolute top-0 rounded-2xl right-[-310px] z-10 ',
isGame.value ? 'bg-[#2c2e3e]' : 'bg-white'
)}
2024-11-19 18:13:43 +08:00
style={
isGame.value
? {
backgroundImage: `url('/tab/bg/addBorder.png')`,
backgroundSize: '100% 100%',
backgroundColor: '#2c2e3e'
}
: {}
}
>
2024-11-19 18:13:43 +08:00
<div
class={'flex flex-col w-full h-full p-7 border-b-[1px] items-center justify-between'}
>
<span class={isGame.value ? '' : ''}>退</span>
<div
class={clsx('w-full h-[1px]', isGame.value ? ' bg-white/20' : 'bg-black/20')}
></div>
<span
class={clsx(
'text-[14px] leading-[20px] mb-2 text-center',
isGame.value ? 'text-[#fff9]' : 'text-[#666]'
)}
>
退
</span>
<div class={'flex justify-between w-full'}>
<button
onClick={() => {
open.value = false
}}
class={clsx(
'w-[118px] rounded-lg py-1 flex justify-center',
isGame.value ? 'bg-white/20' : 'bg-black/20 text-white'
)}
>
</button>
<button
onClick={() => {
user.logout()
open.value = false
router.replace('')
}}
class={clsx(
'w-[118px] rounded-lg py-1 flex justify-center ',
isGame.value ? 'bg-[#ff7372]' : 'bg-[#ff7372] text-white'
)}
>
退
</button>
2024-09-13 10:15:43 +08:00
</div>
</div>
</div>
2024-11-19 18:13:43 +08:00
)}
</div>
2024-09-11 13:46:40 +08:00
)
})