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