1
0
mirror of https://github.com/MisskeyIO/misskey synced 2024-12-23 19:18:44 +09:00
MisskeyIO/packages/frontend/src/pages/user/index.vue

132 lines
3.5 KiB
Vue
Raw Normal View History

<template>
<MkStickyContainer>
2022-07-01 18:55:45 +09:00
<template #header><MkPageHeader v-model:tab="tab" :actions="headerActions" :tabs="headerTabs"/></template>
<div>
2022-12-30 13:37:14 +09:00
<Transition name="fade" mode="out-in">
2022-07-01 18:55:45 +09:00
<div v-if="user">
<XHome v-if="tab === 'home'" :user="user"/>
2023-05-19 20:52:15 +09:00
<XTimeline v-else-if="tab === 'notes'" :user="user"/>
<XActivity v-else-if="tab === 'activity'" :user="user"/>
<XAchievements v-else-if="tab === 'achievements'" :user="user"/>
2022-07-01 18:55:45 +09:00
<XReactions v-else-if="tab === 'reactions'" :user="user"/>
<XClips v-else-if="tab === 'clips'" :user="user"/>
<XLists v-else-if="tab === 'lists'" :user="user"/>
2022-07-01 18:55:45 +09:00
<XPages v-else-if="tab === 'pages'" :user="user"/>
<XGallery v-else-if="tab === 'gallery'" :user="user"/>
</div>
<MkError v-else-if="error" @retry="fetchUser()"/>
<MkLoading v-else/>
2022-12-30 13:37:14 +09:00
</Transition>
</div>
</MkStickyContainer>
</template>
<script lang="ts" setup>
import { defineAsyncComponent, computed, watch } from 'vue';
import * as Acct from 'misskey-js/built/acct';
import * as misskey from 'misskey-js';
import { acct as getAcct } from '@/filters/user';
2021-11-12 02:02:25 +09:00
import * as os from '@/os';
import { definePageMetadata } from '@/scripts/page-metadata';
import { i18n } from '@/i18n';
import { $i } from '@/account';
2022-07-01 18:55:45 +09:00
const XHome = defineAsyncComponent(() => import('./home.vue'));
const XTimeline = defineAsyncComponent(() => import('./index.timeline.vue'));
2023-01-02 10:18:47 +09:00
const XActivity = defineAsyncComponent(() => import('./activity.vue'));
const XAchievements = defineAsyncComponent(() => import('./achievements.vue'));
const XReactions = defineAsyncComponent(() => import('./reactions.vue'));
const XClips = defineAsyncComponent(() => import('./clips.vue'));
const XLists = defineAsyncComponent(() => import('./lists.vue'));
const XPages = defineAsyncComponent(() => import('./pages.vue'));
const XGallery = defineAsyncComponent(() => import('./gallery.vue'));
const props = withDefaults(defineProps<{
acct: string;
page?: string;
}>(), {
2022-07-01 18:55:45 +09:00
page: 'home',
});
2022-07-01 18:55:45 +09:00
let tab = $ref(props.page);
let user = $ref<null | misskey.entities.UserDetailed>(null);
let error = $ref(null);
function fetchUser(): void {
if (props.acct == null) return;
user = null;
os.api('users/show', Acct.parse(props.acct)).then(u => {
user = u;
}).catch(err => {
error = err;
});
}
watch(() => props.acct, fetchUser, {
immediate: true,
});
const headerActions = $computed(() => []);
const headerTabs = $computed(() => user ? [{
2022-07-01 18:55:45 +09:00
key: 'home',
title: i18n.ts.overview,
icon: 'ti ti-home',
}, {
key: 'notes',
title: i18n.ts.notes,
icon: 'ti ti-pencil',
2023-01-02 10:18:47 +09:00
}, {
key: 'activity',
title: i18n.ts.activity,
icon: 'ti ti-chart-line',
}, ...(user.host == null ? [{
key: 'achievements',
title: i18n.ts.achievements,
2023-01-24 14:10:26 +09:00
icon: 'ti ti-medal',
}] : []), ...($i && ($i.id === user.id)) || user.publicReactions ? [{
2022-07-01 18:55:45 +09:00
key: 'reactions',
title: i18n.ts.reaction,
icon: 'ti ti-mood-happy',
}] : [], {
2022-07-01 18:55:45 +09:00
key: 'clips',
title: i18n.ts.clips,
icon: 'ti ti-paperclip',
}, {
key: 'lists',
title: i18n.ts.lists,
icon: 'ti ti-list',
}, {
2022-07-01 18:55:45 +09:00
key: 'pages',
title: i18n.ts.pages,
2022-12-20 08:35:49 +09:00
icon: 'ti ti-news',
}, {
2022-07-01 18:55:45 +09:00
key: 'gallery',
title: i18n.ts.gallery,
icon: 'ti ti-icons',
2023-01-02 16:41:05 +09:00
}] : []);
definePageMetadata(computed(() => user ? {
icon: 'ti ti-user',
title: user.name ? `${user.name} (@${user.username})` : `@${user.username}`,
subtitle: `@${getAcct(user)}`,
userName: user,
avatar: user,
path: `/@${user.username}`,
share: {
title: user.name,
},
} : null));
</script>
<style lang="scss" scoped>
2021-04-17 11:40:47 +09:00
.fade-enter-active,
.fade-leave-active {
transition: opacity 0.125s ease;
}
.fade-enter-from,
.fade-leave-to {
opacity: 0;
}
</style>