refactor: 个人中心 账号绑定 样式/逻辑重构

master
dap 7 months ago
parent e10ddb421c
commit ce6867994a

@ -5,15 +5,7 @@ import type { SocialInfo } from '#/api/system/social/model';
import { onMounted, ref } from 'vue'; import { onMounted, ref } from 'vue';
import { import { Alert, Avatar, Card, Empty, Modal, Tooltip } from 'ant-design-vue';
Alert,
Avatar,
Card,
List,
ListItem,
Modal,
Tooltip,
} from 'ant-design-vue';
import { authUnbinding } from '#/api'; import { authUnbinding } from '#/api';
import { socialList } from '#/api/system/social'; import { socialList } from '#/api/system/social';
@ -68,78 +60,83 @@ function handleUnbind(record: BindItemWithInfo) {
type: 'warning', type: 'warning',
}); });
} }
const simpleImage = Empty.PRESENTED_IMAGE_SIMPLE;
</script> </script>
<template> <template>
<div class="flex flex-col gap-[16px]"> <div class="flex flex-col gap-4 pb-4">
<div class="pb-3"> <div
<List v-if="bindList.length > 0"
:data-source="bindList" class="grid grid-cols-1 gap-4 lg:grid-cols-2 2xl:grid-cols-3"
:grid="{ gutter: 8, xs: 1, sm: 1, md: 1, lg: 2, xl: 2, xxl: 3 }" >
<Card
class="transition-shadow duration-300 hover:shadow-md"
v-for="item in bindList"
:key="item.source"
> >
<template #renderItem="{ item }"> <div class="flex w-full items-center gap-4">
<ListItem> <component
<Card> :is="item.avatar"
<div class="flex w-full items-center gap-4"> v-if="item.avatar"
<Tooltip> :style="item?.style ?? {}"
<template #title> class="size-[40px]"
<template v-if="!item.bound"> />
绑定 {{ item.source }} 账号 <div class="flex flex-1 items-center justify-between">
</template> <div class="flex flex-col">
<template v-if="item.bound && item.info"> <h4 class="mb-[4px] text-[14px] text-black/85 dark:text-white/85">
{{ item.title }}
</h4>
<span class="text-black/45 dark:text-white/45">
<template v-if="!item.bound">
{{ item.description }}
</template>
<template v-if="item.bound && item.info">
<Tooltip>
<template #title>
<div class="flex flex-col items-center gap-2 p-2"> <div class="flex flex-col items-center gap-2 p-2">
<Avatar :size="30" :src="item.info.avatar" /> <Avatar :size="36" :src="item.info.avatar" />
<div>{{ item.info.nickName }}</div> <div>绑定时间: {{ item.info.createTime }}</div>
</div> </div>
</template> </template>
</template> <div class="cursor-pointer">
<component 已绑定: {{ item.info.nickName }}
:is="item.avatar" </div>
v-if="item.avatar" </Tooltip>
:style="item?.style ?? {}" </template>
class="size-[40px] cursor-help" </span>
/> </div>
</Tooltip> <!-- TODO: 这里有优化空间? -->
<div class="flex flex-1 items-center justify-between"> <a-button
<div class="flex flex-col"> size="small"
<h4 :type="item.bound ? 'default' : 'link'"
class="mb-[4px] text-[14px] text-black/85 dark:text-white/85" @click="
> item.bound ? handleUnbind(item) : handleAuthBinding(item.source)
{{ item.title }} "
</h4> >
<span class="text-black/45 dark:text-white/45"> {{ item.bound ? '取消绑定' : '绑定' }}
{{ item.description }} </a-button>
</span> </div>
</div> </div>
<a-button </Card>
size="small" </div>
:type="item.bound ? 'default' : 'link'" <div
@click=" v-if="bindList.length === 0"
item.bound class="flex items-center justify-center rounded-lg border py-4"
? handleUnbind(item) >
: handleAuthBinding(item.source) <Empty :image="simpleImage" description="暂无可绑定的第三方账户" />
"
>
{{ item.bound ? '取消绑定' : '绑定' }}
</a-button>
</div>
</div>
</Card>
</ListItem>
</template>
</List>
<Alert message="说明" type="info">
<template #description>
<p>
需要添加第三方账号在
<span class="font-bold">
apps\web-antd\src\views\_core\oauth-common.ts
</span>
中accountBindList按模板添加
</p>
</template>
</Alert>
</div> </div>
<Alert message="说明" type="info">
<template #description>
<p>
需要添加第三方账号在
<span class="font-bold">
apps\web-antd\src\views\_core\oauth-common.ts
</span>
中accountBindList按模板添加
</p>
</template>
</Alert>
</div> </div>
</template> </template>

Loading…
Cancel
Save