2020-01-29 13:37:25 -06:00
|
|
|
<template>
|
2022-06-20 03:38:49 -05:00
|
|
|
<MkStickyContainer>
|
2022-07-01 04:55:45 -05:00
|
|
|
<template #header><MkPageHeader v-model:tab="tab" :actions="headerActions" :tabs="headerTabs"/></template>
|
|
|
|
<div>
|
2022-12-29 22:37:14 -06:00
|
|
|
<Transition name="fade" mode="out-in">
|
2022-07-01 04:55:45 -05:00
|
|
|
<div v-if="user">
|
|
|
|
<XHome v-if="tab === 'home'" :user="user"/>
|
2023-01-01 19:18:47 -06:00
|
|
|
<XActivity v-else-if="tab === 'activity'" :user="user"/>
|
2022-07-01 04:55:45 -05:00
|
|
|
<XReactions v-else-if="tab === 'reactions'" :user="user"/>
|
|
|
|
<XClips v-else-if="tab === 'clips'" :user="user"/>
|
|
|
|
<XPages v-else-if="tab === 'pages'" :user="user"/>
|
|
|
|
<XGallery v-else-if="tab === 'gallery'" :user="user"/>
|
|
|
|
</div>
|
2022-07-18 07:43:31 -05:00
|
|
|
<MkError v-else-if="error" @retry="fetchUser()"/>
|
2022-06-20 03:38:49 -05:00
|
|
|
<MkLoading v-else/>
|
2022-12-29 22:37:14 -06:00
|
|
|
</Transition>
|
2022-06-20 03:38:49 -05:00
|
|
|
</div>
|
|
|
|
</MkStickyContainer>
|
2020-01-29 13:37:25 -06:00
|
|
|
</template>
|
|
|
|
|
2022-06-20 03:38:49 -05:00
|
|
|
<script lang="ts" setup>
|
|
|
|
import { defineAsyncComponent, computed, inject, onMounted, onUnmounted, watch } from 'vue';
|
|
|
|
import calcAge from 's-age';
|
|
|
|
import * as Acct from 'misskey-js/built/acct';
|
|
|
|
import * as misskey from 'misskey-js';
|
2021-11-11 11:02:25 -06:00
|
|
|
import { getScrollPosition } from '@/scripts/scroll';
|
|
|
|
import number from '@/filters/number';
|
|
|
|
import { userPage, acct as getAcct } from '@/filters/user';
|
|
|
|
import * as os from '@/os';
|
2022-06-20 03:38:49 -05:00
|
|
|
import { useRouter } from '@/router';
|
|
|
|
import { definePageMetadata } from '@/scripts/page-metadata';
|
|
|
|
import { i18n } from '@/i18n';
|
|
|
|
import { $i } from '@/account';
|
|
|
|
|
2022-07-01 04:55:45 -05:00
|
|
|
const XHome = defineAsyncComponent(() => import('./home.vue'));
|
2023-01-01 19:18:47 -06:00
|
|
|
const XActivity = defineAsyncComponent(() => import('./activity.vue'));
|
2022-06-20 03:38:49 -05:00
|
|
|
const XReactions = defineAsyncComponent(() => import('./reactions.vue'));
|
|
|
|
const XClips = defineAsyncComponent(() => import('./clips.vue'));
|
|
|
|
const XPages = defineAsyncComponent(() => import('./pages.vue'));
|
|
|
|
const XGallery = defineAsyncComponent(() => import('./gallery.vue'));
|
|
|
|
|
|
|
|
const props = withDefaults(defineProps<{
|
|
|
|
acct: string;
|
|
|
|
page?: string;
|
|
|
|
}>(), {
|
2022-07-01 04:55:45 -05:00
|
|
|
page: 'home',
|
2022-06-20 03:38:49 -05:00
|
|
|
});
|
2020-01-29 13:37:25 -06:00
|
|
|
|
2022-06-20 03:38:49 -05:00
|
|
|
const router = useRouter();
|
2020-01-29 13:37:25 -06:00
|
|
|
|
2022-07-01 04:55:45 -05:00
|
|
|
let tab = $ref(props.page);
|
2022-06-20 03:38:49 -05:00
|
|
|
let user = $ref<null | misskey.entities.UserDetailed>(null);
|
|
|
|
let error = $ref(null);
|
2020-01-29 13:37:25 -06:00
|
|
|
|
2022-06-20 03:38:49 -05:00
|
|
|
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;
|
|
|
|
});
|
|
|
|
}
|
2020-10-24 11:21:41 -05:00
|
|
|
|
2022-06-20 03:38:49 -05:00
|
|
|
watch(() => props.acct, fetchUser, {
|
|
|
|
immediate: true,
|
|
|
|
});
|
2020-01-29 13:37:25 -06:00
|
|
|
|
2022-06-20 03:38:49 -05:00
|
|
|
const headerActions = $computed(() => []);
|
|
|
|
|
|
|
|
const headerTabs = $computed(() => user ? [{
|
2022-07-01 04:55:45 -05:00
|
|
|
key: 'home',
|
2022-06-20 03:38:49 -05:00
|
|
|
title: i18n.ts.overview,
|
2022-12-19 04:01:30 -06:00
|
|
|
icon: 'ti ti-home',
|
2023-01-01 19:18:47 -06:00
|
|
|
}, {
|
|
|
|
key: 'activity',
|
|
|
|
title: i18n.ts.activity,
|
|
|
|
icon: 'ti ti-chart-line',
|
2022-06-20 03:38:49 -05:00
|
|
|
}, ...($i && ($i.id === user.id)) || user.publicReactions ? [{
|
2022-07-01 04:55:45 -05:00
|
|
|
key: 'reactions',
|
2022-06-20 03:38:49 -05:00
|
|
|
title: i18n.ts.reaction,
|
2022-12-19 04:01:30 -06:00
|
|
|
icon: 'ti ti-mood-happy',
|
2022-06-20 03:38:49 -05:00
|
|
|
}] : [], {
|
2022-07-01 04:55:45 -05:00
|
|
|
key: 'clips',
|
2022-06-20 03:38:49 -05:00
|
|
|
title: i18n.ts.clips,
|
2022-12-19 04:01:30 -06:00
|
|
|
icon: 'ti ti-paperclip',
|
2022-06-20 03:38:49 -05:00
|
|
|
}, {
|
2022-07-01 04:55:45 -05:00
|
|
|
key: 'pages',
|
2022-06-20 03:38:49 -05:00
|
|
|
title: i18n.ts.pages,
|
2022-12-19 17:35:49 -06:00
|
|
|
icon: 'ti ti-news',
|
2022-06-20 03:38:49 -05:00
|
|
|
}, {
|
2022-07-01 04:55:45 -05:00
|
|
|
key: 'gallery',
|
2022-06-20 03:38:49 -05:00
|
|
|
title: i18n.ts.gallery,
|
2022-12-19 04:01:30 -06:00
|
|
|
icon: 'ti ti-icons',
|
2023-01-02 01:41:05 -06:00
|
|
|
}] : []);
|
2022-06-20 03:38:49 -05:00
|
|
|
|
|
|
|
definePageMetadata(computed(() => user ? {
|
2022-12-19 04:01:30 -06:00
|
|
|
icon: 'ti ti-user',
|
2022-06-20 03:38:49 -05:00
|
|
|
title: user.name ? `${user.name} (@${user.username})` : `@${user.username}`,
|
|
|
|
subtitle: `@${getAcct(user)}`,
|
|
|
|
userName: user,
|
|
|
|
avatar: user,
|
|
|
|
path: `/@${user.username}`,
|
|
|
|
share: {
|
|
|
|
title: user.name,
|
|
|
|
},
|
|
|
|
} : null));
|
2020-01-29 13:37:25 -06:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
2021-04-16 21:40:47 -05:00
|
|
|
.fade-enter-active,
|
|
|
|
.fade-leave-active {
|
|
|
|
transition: opacity 0.125s ease;
|
|
|
|
}
|
|
|
|
.fade-enter-from,
|
|
|
|
.fade-leave-to {
|
|
|
|
opacity: 0;
|
|
|
|
}
|
2020-01-29 13:37:25 -06:00
|
|
|
</style>
|