2023-07-27 05:31:52 +00:00
|
|
|
<!--
|
2024-02-12 02:37:45 +00:00
|
|
|
SPDX-FileCopyrightText: syuilo and misskey-project
|
2023-07-27 05:31:52 +00:00
|
|
|
SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
-->
|
|
|
|
|
2020-01-29 19:37:25 +00:00
|
|
|
<template>
|
2022-06-20 08:38:49 +00:00
|
|
|
<MkStickyContainer>
|
2022-07-01 09:55:45 +00:00
|
|
|
<template #header><MkPageHeader v-model:tab="tab" :actions="headerActions" :tabs="headerTabs"/></template>
|
|
|
|
<div>
|
2023-05-24 08:50:15 +00:00
|
|
|
<div v-if="user">
|
2024-01-18 09:21:33 +00:00
|
|
|
<MkHorizontalSwipe v-model:tab="tab" :tabs="headerTabs">
|
|
|
|
<XHome v-if="tab === 'home'" key="home" :user="user"/>
|
|
|
|
<MkSpacer v-else-if="tab === 'notes'" key="notes" :contentMax="800" style="padding-top: 0">
|
|
|
|
<XTimeline :user="user"/>
|
|
|
|
</MkSpacer>
|
|
|
|
<XActivity v-else-if="tab === 'activity'" key="activity" :user="user"/>
|
|
|
|
<XAchievements v-else-if="tab === 'achievements'" key="achievements" :user="user"/>
|
|
|
|
<XReactions v-else-if="tab === 'reactions'" key="reactions" :user="user"/>
|
|
|
|
<XClips v-else-if="tab === 'clips'" key="clips" :user="user"/>
|
|
|
|
<XLists v-else-if="tab === 'lists'" key="lists" :user="user"/>
|
|
|
|
<XPages v-else-if="tab === 'pages'" key="pages" :user="user"/>
|
|
|
|
<XFlashs v-else-if="tab === 'flashs'" key="flashs" :user="user"/>
|
|
|
|
<XGallery v-else-if="tab === 'gallery'" key="gallery" :user="user"/>
|
|
|
|
<XRaw v-else-if="tab === 'raw'" key="raw" :user="user"/>
|
|
|
|
</MkHorizontalSwipe>
|
2023-05-24 08:50:15 +00:00
|
|
|
</div>
|
|
|
|
<MkError v-else-if="error" @retry="fetchUser()"/>
|
|
|
|
<MkLoading v-else/>
|
2022-06-20 08:38:49 +00:00
|
|
|
</div>
|
|
|
|
</MkStickyContainer>
|
2020-01-29 19:37:25 +00:00
|
|
|
</template>
|
|
|
|
|
2022-06-20 08:38:49 +00:00
|
|
|
<script lang="ts" setup>
|
2023-12-07 05:42:09 +00:00
|
|
|
import { defineAsyncComponent, computed, watch, ref } from 'vue';
|
2023-09-04 04:33:38 +00:00
|
|
|
import * as Misskey from 'misskey-js';
|
2023-09-19 07:37:43 +00:00
|
|
|
import { acct as getAcct } from '@/filters/user.js';
|
2024-01-04 09:32:46 +00:00
|
|
|
import { misskeyApi } from '@/scripts/misskey-api.js';
|
2023-09-19 07:37:43 +00:00
|
|
|
import { definePageMetadata } from '@/scripts/page-metadata.js';
|
|
|
|
import { i18n } from '@/i18n.js';
|
|
|
|
import { $i } from '@/account.js';
|
2024-01-18 09:21:33 +00:00
|
|
|
import MkHorizontalSwipe from '@/components/MkHorizontalSwipe.vue';
|
2022-06-20 08:38:49 +00:00
|
|
|
|
2022-07-01 09:55:45 +00:00
|
|
|
const XHome = defineAsyncComponent(() => import('./home.vue'));
|
2023-02-11 04:08:18 +00:00
|
|
|
const XTimeline = defineAsyncComponent(() => import('./index.timeline.vue'));
|
2023-01-02 01:18:47 +00:00
|
|
|
const XActivity = defineAsyncComponent(() => import('./activity.vue'));
|
2023-01-21 07:57:23 +00:00
|
|
|
const XAchievements = defineAsyncComponent(() => import('./achievements.vue'));
|
2022-06-20 08:38:49 +00:00
|
|
|
const XReactions = defineAsyncComponent(() => import('./reactions.vue'));
|
|
|
|
const XClips = defineAsyncComponent(() => import('./clips.vue'));
|
2023-05-19 01:06:12 +00:00
|
|
|
const XLists = defineAsyncComponent(() => import('./lists.vue'));
|
2022-06-20 08:38:49 +00:00
|
|
|
const XPages = defineAsyncComponent(() => import('./pages.vue'));
|
2023-08-21 11:23:09 +00:00
|
|
|
const XFlashs = defineAsyncComponent(() => import('./flashs.vue'));
|
2022-06-20 08:38:49 +00:00
|
|
|
const XGallery = defineAsyncComponent(() => import('./gallery.vue'));
|
2023-11-24 12:11:18 +00:00
|
|
|
const XRaw = defineAsyncComponent(() => import('./raw.vue'));
|
2022-06-20 08:38:49 +00:00
|
|
|
|
|
|
|
const props = withDefaults(defineProps<{
|
|
|
|
acct: string;
|
|
|
|
page?: string;
|
|
|
|
}>(), {
|
2022-07-01 09:55:45 +00:00
|
|
|
page: 'home',
|
2022-06-20 08:38:49 +00:00
|
|
|
});
|
2020-01-29 19:37:25 +00:00
|
|
|
|
2023-12-07 05:42:09 +00:00
|
|
|
const tab = ref(props.page);
|
2024-01-18 09:21:33 +00:00
|
|
|
|
2023-12-07 05:42:09 +00:00
|
|
|
const user = ref<null | Misskey.entities.UserDetailed>(null);
|
2023-12-26 05:19:35 +00:00
|
|
|
const error = ref<any>(null);
|
2020-01-29 19:37:25 +00:00
|
|
|
|
2022-06-20 08:38:49 +00:00
|
|
|
function fetchUser(): void {
|
|
|
|
if (props.acct == null) return;
|
2023-12-07 05:42:09 +00:00
|
|
|
user.value = null;
|
2024-01-04 09:32:46 +00:00
|
|
|
misskeyApi('users/show', Misskey.acct.parse(props.acct)).then(u => {
|
2023-12-07 05:42:09 +00:00
|
|
|
user.value = u;
|
2022-06-20 08:38:49 +00:00
|
|
|
}).catch(err => {
|
2023-12-07 05:42:09 +00:00
|
|
|
error.value = err;
|
2022-06-20 08:38:49 +00:00
|
|
|
});
|
|
|
|
}
|
2020-10-24 16:21:41 +00:00
|
|
|
|
2022-06-20 08:38:49 +00:00
|
|
|
watch(() => props.acct, fetchUser, {
|
|
|
|
immediate: true,
|
|
|
|
});
|
2020-01-29 19:37:25 +00:00
|
|
|
|
2023-12-07 05:42:09 +00:00
|
|
|
const headerActions = computed(() => []);
|
2022-06-20 08:38:49 +00:00
|
|
|
|
2023-12-07 05:42:09 +00:00
|
|
|
const headerTabs = computed(() => user.value ? [{
|
2022-07-01 09:55:45 +00:00
|
|
|
key: 'home',
|
2022-06-20 08:38:49 +00:00
|
|
|
title: i18n.ts.overview,
|
2022-12-19 10:01:30 +00:00
|
|
|
icon: 'ti ti-home',
|
2023-02-11 04:08:18 +00:00
|
|
|
}, {
|
|
|
|
key: 'notes',
|
|
|
|
title: i18n.ts.notes,
|
|
|
|
icon: 'ti ti-pencil',
|
2023-01-02 01:18:47 +00:00
|
|
|
}, {
|
|
|
|
key: 'activity',
|
|
|
|
title: i18n.ts.activity,
|
|
|
|
icon: 'ti ti-chart-line',
|
2023-12-07 05:42:09 +00:00
|
|
|
}, ...(user.value.host == null ? [{
|
2023-01-21 07:57:23 +00:00
|
|
|
key: 'achievements',
|
|
|
|
title: i18n.ts.achievements,
|
2023-01-24 05:10:26 +00:00
|
|
|
icon: 'ti ti-medal',
|
2024-02-01 11:05:45 +00:00
|
|
|
}] : []), ...($i && ($i.id === user.value.id || $i.isAdmin || $i.isModerator)) || user.value.publicReactions ? [{
|
2022-07-01 09:55:45 +00:00
|
|
|
key: 'reactions',
|
2022-06-20 08:38:49 +00:00
|
|
|
title: i18n.ts.reaction,
|
2022-12-19 10:01:30 +00:00
|
|
|
icon: 'ti ti-mood-happy',
|
2022-06-20 08:38:49 +00:00
|
|
|
}] : [], {
|
2022-07-01 09:55:45 +00:00
|
|
|
key: 'clips',
|
2022-06-20 08:38:49 +00:00
|
|
|
title: i18n.ts.clips,
|
2022-12-19 10:01:30 +00:00
|
|
|
icon: 'ti ti-paperclip',
|
2023-05-19 01:06:12 +00:00
|
|
|
}, {
|
|
|
|
key: 'lists',
|
|
|
|
title: i18n.ts.lists,
|
|
|
|
icon: 'ti ti-list',
|
2022-06-20 08:38:49 +00:00
|
|
|
}, {
|
2022-07-01 09:55:45 +00:00
|
|
|
key: 'pages',
|
2022-06-20 08:38:49 +00:00
|
|
|
title: i18n.ts.pages,
|
2022-12-19 23:35:49 +00:00
|
|
|
icon: 'ti ti-news',
|
2023-08-21 11:23:09 +00:00
|
|
|
}, {
|
|
|
|
key: 'flashs',
|
|
|
|
title: 'Play',
|
|
|
|
icon: 'ti ti-player-play',
|
2022-06-20 08:38:49 +00:00
|
|
|
}, {
|
2022-07-01 09:55:45 +00:00
|
|
|
key: 'gallery',
|
2022-06-20 08:38:49 +00:00
|
|
|
title: i18n.ts.gallery,
|
2022-12-19 10:01:30 +00:00
|
|
|
icon: 'ti ti-icons',
|
2023-11-24 12:11:18 +00:00
|
|
|
}, {
|
|
|
|
key: 'raw',
|
|
|
|
title: 'Raw',
|
|
|
|
icon: 'ti ti-code',
|
2023-01-02 07:41:05 +00:00
|
|
|
}] : []);
|
2022-06-20 08:38:49 +00:00
|
|
|
|
2023-12-07 05:42:09 +00:00
|
|
|
definePageMetadata(computed(() => user.value ? {
|
2022-12-19 10:01:30 +00:00
|
|
|
icon: 'ti ti-user',
|
2023-12-07 05:42:09 +00:00
|
|
|
title: user.value.name ? `${user.value.name} (@${user.value.username})` : `@${user.value.username}`,
|
|
|
|
subtitle: `@${getAcct(user.value)}`,
|
|
|
|
userName: user.value,
|
|
|
|
avatar: user.value,
|
|
|
|
path: `/@${user.value.username}`,
|
2022-06-20 08:38:49 +00:00
|
|
|
share: {
|
2023-12-07 05:42:09 +00:00
|
|
|
title: user.value.name,
|
2022-06-20 08:38:49 +00:00
|
|
|
},
|
|
|
|
} : null));
|
2020-01-29 19:37:25 +00:00
|
|
|
</script>
|