2020-01-29 12:37:25 -07:00
|
|
|
<template>
|
2022-06-20 02:38:49 -06:00
|
|
|
<MkStickyContainer>
|
2022-11-14 20:05:09 -07:00
|
|
|
<template #header>
|
|
|
|
<MkPageHeader
|
|
|
|
v-model:tab="tab"
|
|
|
|
:actions="headerActions"
|
|
|
|
:tabs="headerTabs"
|
|
|
|
/>
|
|
|
|
</template>
|
|
|
|
<div>
|
|
|
|
<transition name="fade" mode="out-in">
|
|
|
|
<div v-if="user">
|
|
|
|
<XHome v-if="tab === 'home'" :user="user"/>
|
|
|
|
<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>
|
|
|
|
<MkError v-else-if="error" @retry="fetchUser()"/>
|
|
|
|
<MkLoading v-else/>
|
|
|
|
</transition>
|
2022-09-13 22:33:03 -06:00
|
|
|
</div>
|
2022-06-20 02:38:49 -06:00
|
|
|
</MkStickyContainer>
|
2020-01-29 12:37:25 -07:00
|
|
|
</template>
|
|
|
|
|
2022-06-20 02:38:49 -06:00
|
|
|
<script lang="ts" setup>
|
2022-11-14 20:05:09 -07:00
|
|
|
import { defineAsyncComponent, computed, watch } from 'vue';
|
|
|
|
import calcAge from 's-age';
|
2022-12-12 11:19:18 -07:00
|
|
|
import * as Acct from 'calckey-js/built/acct';
|
2022-12-11 20:24:12 -07:00
|
|
|
import type * as misskey from 'calckey-js';
|
2022-11-14 20:05:09 -07:00
|
|
|
import { getScrollPosition } from '@/scripts/scroll';
|
|
|
|
import number from '@/filters/number';
|
2021-11-11 10:02:25 -07:00
|
|
|
import { userPage, acct as getAcct } from '@/filters/user';
|
|
|
|
import * as os from '@/os';
|
2022-06-20 02:38:49 -06:00
|
|
|
import { useRouter } from '@/router';
|
|
|
|
import { definePageMetadata } from '@/scripts/page-metadata';
|
|
|
|
import { i18n } from '@/i18n';
|
|
|
|
import { $i } from '@/account';
|
|
|
|
|
2022-07-01 03:55:45 -06:00
|
|
|
const XHome = defineAsyncComponent(() => import('./home.vue'));
|
2022-06-20 02:38:49 -06: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'));
|
|
|
|
|
2022-11-14 20:05:09 -07:00
|
|
|
const props = withDefaults(
|
|
|
|
defineProps<{
|
|
|
|
acct: string;
|
|
|
|
page?: string;
|
|
|
|
}>(),
|
|
|
|
{
|
|
|
|
page: 'home',
|
|
|
|
},
|
|
|
|
);
|
2020-01-29 12:37:25 -07:00
|
|
|
|
2022-06-20 02:38:49 -06:00
|
|
|
const router = useRouter();
|
2020-01-29 12:37:25 -07:00
|
|
|
|
2022-11-14 20:05:09 -07:00
|
|
|
let tab = $ref(props.page);
|
2022-06-20 02:38:49 -06:00
|
|
|
let user = $ref<null | misskey.entities.UserDetailed>(null);
|
|
|
|
let error = $ref(null);
|
2020-01-29 12:37:25 -07:00
|
|
|
|
2022-06-20 02:38:49 -06:00
|
|
|
function fetchUser(): void {
|
|
|
|
if (props.acct == null) return;
|
|
|
|
user = null;
|
2022-11-14 20:05:09 -07:00
|
|
|
os.api('users/show', Acct.parse(props.acct))
|
|
|
|
.then((u) => {
|
|
|
|
user = u;
|
|
|
|
})
|
|
|
|
.catch((err) => {
|
|
|
|
error = err;
|
|
|
|
});
|
2022-06-20 02:38:49 -06:00
|
|
|
}
|
2020-10-24 10:21:41 -06:00
|
|
|
|
2022-06-20 02:38:49 -06:00
|
|
|
watch(() => props.acct, fetchUser, {
|
|
|
|
immediate: true,
|
|
|
|
});
|
2020-01-29 12:37:25 -07:00
|
|
|
|
2022-06-20 02:38:49 -06:00
|
|
|
const headerActions = $computed(() => []);
|
|
|
|
|
2022-11-14 20:05:09 -07:00
|
|
|
const headerTabs = $computed(() =>
|
|
|
|
user
|
|
|
|
? [
|
|
|
|
{
|
|
|
|
key: 'home',
|
|
|
|
title: i18n.ts.overview,
|
2022-11-16 02:48:19 -07:00
|
|
|
icon: 'ph-user-bold ph-lg',
|
2022-11-14 20:05:09 -07:00
|
|
|
},
|
|
|
|
...(($i && $i.id === user.id) || user.publicReactions
|
2022-11-14 20:13:04 -07:00
|
|
|
? [{
|
|
|
|
key: 'reactions',
|
|
|
|
title: i18n.ts.reaction,
|
2022-11-16 02:48:19 -07:00
|
|
|
icon: 'ph-smiley-bold ph-lg',
|
2022-11-14 20:13:04 -07:00
|
|
|
}] : []),
|
|
|
|
...(user.instance == null ? [{
|
2022-11-14 20:05:09 -07:00
|
|
|
key: 'clips',
|
|
|
|
title: i18n.ts.clips,
|
2022-11-16 02:48:19 -07:00
|
|
|
icon: 'ph-paperclip-bold ph-lg',
|
2022-11-14 20:13:04 -07:00
|
|
|
}, {
|
2022-11-14 20:05:09 -07:00
|
|
|
key: 'pages',
|
|
|
|
title: i18n.ts.pages,
|
2022-11-16 02:48:19 -07:00
|
|
|
icon: 'ph-file-text-bold ph-lg',
|
2022-11-14 20:13:04 -07:00
|
|
|
}, {
|
2022-11-14 20:05:09 -07:00
|
|
|
key: 'gallery',
|
|
|
|
title: i18n.ts.gallery,
|
2022-11-16 02:48:19 -07:00
|
|
|
icon: 'ph-image-square-bold ph-lg',
|
2022-11-14 20:13:04 -07:00
|
|
|
}] : []),
|
2022-11-14 20:05:09 -07:00
|
|
|
]
|
|
|
|
: null,
|
|
|
|
);
|
|
|
|
|
|
|
|
definePageMetadata(
|
|
|
|
computed(() =>
|
|
|
|
user
|
|
|
|
? {
|
2022-12-06 21:12:44 -07:00
|
|
|
icon: 'ph-user-bold ph-lg',
|
2022-11-14 20:05:09 -07: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 12:37:25 -07:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
2021-04-16 20:40:47 -06:00
|
|
|
.fade-enter-active,
|
|
|
|
.fade-leave-active {
|
|
|
|
transition: opacity 0.125s ease;
|
|
|
|
}
|
|
|
|
.fade-enter-from,
|
|
|
|
.fade-leave-to {
|
|
|
|
opacity: 0;
|
|
|
|
}
|
2020-01-29 12:37:25 -07:00
|
|
|
</style>
|