1
0
mirror of https://github.com/elk-zone/elk synced 2024-12-23 11:08:04 +09:00
elk/pages/@[account]/index/index.vue

46 lines
1.4 KiB
Vue
Raw Normal View History

<script setup lang="ts">
const params = useRoute().params
const accountName = $(computedEager(() => params.account as string))
const account = await fetchAccountByName(accountName)
2022-11-29 16:18:28 +09:00
const { t } = useI18n()
const paginatorPosts = useMasto().accounts.getStatusesIterable(account.id, { excludeReplies: true })
const paginatorPostsWithReply = useMasto().accounts.getStatusesIterable(account.id, { excludeReplies: false })
2022-11-27 02:36:23 +09:00
const paginatorMedia = useMasto().accounts.getStatusesIterable(account.id, { onlyMedia: true, excludeReplies: false })
2022-11-29 16:18:28 +09:00
const tabs = $computed(() => [
{
name: 'posts',
display: t('tab.posts'),
icon: 'i-ri:file-list-2-line',
2022-11-29 16:18:28 +09:00
paginator: paginatorPosts,
},
{
name: 'relies',
display: t('tab.posts_with_replies'),
icon: 'i-ri:chat-3-line',
2022-11-29 16:18:28 +09:00
paginator: paginatorPostsWithReply,
},
{
name: 'media',
display: t('tab.media'),
icon: 'i-ri:camera-2-line',
2022-11-29 16:18:28 +09:00
paginator: paginatorMedia,
},
] as const)
2022-11-27 02:36:23 +09:00
2022-11-29 16:18:28 +09:00
// Don't use local storage because it is better to default to Posts every time you visit a user's profile.
const tab = $ref(tabs[0].name)
const paginator = $computed(() => tabs.find(t => t.name === tab)!.paginator)
</script>
<template>
<div>
<CommonTabs v-model="tab" :options="tabs" command />
<KeepAlive>
<TimelinePaginator :key="tab" :paginator="paginator" />
</KeepAlive>
</div>
</template>