1
0
Fork 1
mirror of https://github.com/elk-zone/elk.git synced 2024-11-16 05:50:00 +00:00
elk/pages/[[server]]/list/[list]/index.vue

61 lines
1.6 KiB
Vue
Raw Normal View History

2023-01-27 15:15:46 +00:00
<script setup lang="ts">
import type { CommonRouteTabOption } from '~/types'
2023-02-02 21:35:18 +00:00
definePageMeta({
middleware: 'auth',
})
const route = useRoute()
const { t } = useI18n()
const list = computed(() => route.params.list as string)
const server = computed(() => (route.params.server ?? currentServer.value) as string)
2023-01-27 15:15:46 +00:00
const tabs = computed<CommonRouteTabOption[]>(() => [
{
to: {
name: 'list',
params: { server: server.value, list: list.value },
},
display: t('tab.posts'),
icon: 'i-ri:list-unordered',
},
{
to: {
name: 'list-accounts',
params: { server: server.value, list: list.value },
},
display: t('tab.accounts'),
icon: 'i-ri:user-line',
},
],
)
2023-01-27 15:15:46 +00:00
const { client } = useMasto()
const { data: listInfo, refresh } = await useAsyncData(() => client.value.v1.lists.$select(list.value).fetch(), { default: () => shallowRef() })
2023-01-27 15:15:46 +00:00
if (listInfo) {
useHydratedHead({
title: () => `${listInfo.value.title} | ${route.fullPath.endsWith('/accounts') ? t('tab.accounts') : t('tab.posts')} | ${t('nav.lists')}`,
})
}
onReactivated(() => {
// Silently update data when reentering the page
// The user will see the previous content first, and any changes will be updated to the UI when the request is completed
refresh()
})
2023-01-27 15:15:46 +00:00
</script>
<template>
<MainContent back>
<template #title>
<span text-lg font-bold>{{ listInfo ? listInfo.title : t('nav.list') }}</span>
</template>
<template #header>
<CommonRouteTabs replace :options="tabs" />
</template>
<NuxtPage v-if="isHydrated" />
</MainContent>
2023-01-27 15:15:46 +00:00
</template>