Spaces:
Running
Running
File size: 1,790 Bytes
6e41657 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 | <template>
<USelectMenu
v-model="selected"
size="md"
color="gray"
searchable
searchable-placeholder="筛选公众号..."
clear-search-on-close
:options="sortedAccountInfos"
option-attribute="nickname"
placeholder="请选择公众号"
>
<template #label>
<UAvatar v-if="selected" :src="selected.round_head_img" size="2xs" />
<span v-if="selected" class="max-w-30 line-clamp-1">{{ selected.nickname }}</span>
<span v-if="selected" class="shrink-0">({{ selected.articles }}篇)</span>
</template>
<template #option="{ option: account }">
<UAvatar :src="account.round_head_img" size="sm" />
<div>
<p class="text-[16px]">{{ account.nickname }}</p>
<p class="text-gray-500 text-sm">已加载文章数: {{ account.articles }}</p>
</div>
</template>
<template #option-empty="{ query }">
未找到匹配「{{ query }}」的公众号<br />请先在「<NuxtLink
to="/dashboard/account"
class="text-blue-500 hover:underline"
>公众号管理</NuxtLink
>」中添加
</template>
<template #empty>
暂无公众号,请先在「<NuxtLink to="/dashboard/account" class="text-blue-500 hover:underline">公众号管理</NuxtLink
>」中添加
</template>
</USelectMenu>
</template>
<script setup lang="ts">
import { getAllInfo, type MpAccount } from '~/store/v2/info';
// 已缓存的公众号信息
const cachedAccountInfos = await getAllInfo();
const sortedAccountInfos = computed(() => {
cachedAccountInfos.sort((a, b) => {
return a.articles > b.articles ? -1 : 1;
});
return cachedAccountInfos;
});
const selected = defineModel<MpAccount | undefined>();
</script>
|