2020-01-29 20:37:25 +01:00
|
|
|
<template>
|
2022-06-20 10:38:49 +02:00
|
|
|
<MkStickyContainer>
|
2022-07-01 11:55:45 +02:00
|
|
|
<template #header><MkPageHeader v-model:tab="tab" :actions="headerActions" :tabs="headerTabs"/></template>
|
2022-09-14 06:33:03 +02:00
|
|
|
<div v-if="user">
|
|
|
|
<swiper
|
|
|
|
:modules="[Virtual]"
|
|
|
|
:space-between="20"
|
|
|
|
:virtual="true"
|
2022-09-15 22:40:34 +02:00
|
|
|
:allow-touch-move="!(deviceKind === 'desktop' && !defaultStore.state.swipeOnDesktop)"
|
2022-09-14 06:33:03 +02:00
|
|
|
@swiper="setSwiperRef"
|
|
|
|
@slide-change="onSlideChange"
|
|
|
|
>
|
|
|
|
<swiper-slide>
|
|
|
|
<XHome :user="user"/>
|
|
|
|
</swiper-slide>
|
|
|
|
<swiper-slide>
|
|
|
|
<XLikedPosts :user="user"/>
|
|
|
|
</swiper-slide>
|
|
|
|
<swiper-slide>
|
|
|
|
<XReactions :user="user"/>
|
|
|
|
</swiper-slide>
|
|
|
|
<swiper-slide>
|
|
|
|
<XClips :user="user"/>
|
|
|
|
</swiper-slide>
|
|
|
|
<swiper-slide>
|
|
|
|
<XPages :user="user"/>
|
|
|
|
</swiper-slide>
|
|
|
|
<swiper-slide>
|
|
|
|
<XGallery :user="user"/>
|
|
|
|
</swiper-slide>
|
|
|
|
</swiper>
|
|
|
|
</div>
|
|
|
|
<MkError v-else-if="error" @retry="fetchUser()"/>
|
|
|
|
<MkLoading v-else/>
|
2022-06-20 10:38:49 +02:00
|
|
|
</MkStickyContainer>
|
2020-01-29 20:37:25 +01:00
|
|
|
</template>
|
|
|
|
|
2022-06-20 10:38:49 +02:00
|
|
|
<script lang="ts" setup>
|
|
|
|
import { defineAsyncComponent, computed, inject, onMounted, onUnmounted, watch } from 'vue';
|
2022-09-14 06:33:03 +02:00
|
|
|
import { Virtual } from 'swiper';
|
|
|
|
import { Swiper, SwiperSlide } from 'swiper/vue';
|
2022-06-20 10:38:49 +02:00
|
|
|
import * as Acct from 'misskey-js/built/acct';
|
2022-09-14 06:33:03 +02:00
|
|
|
import type * as misskey from 'misskey-js';
|
2021-11-11 18:02:25 +01:00
|
|
|
import { userPage, acct as getAcct } from '@/filters/user';
|
|
|
|
import * as os from '@/os';
|
2022-06-20 10:38:49 +02:00
|
|
|
import { useRouter } from '@/router';
|
|
|
|
import { definePageMetadata } from '@/scripts/page-metadata';
|
2022-09-15 19:43:48 +02:00
|
|
|
import { deviceKind } from '@/scripts/device-kind';
|
2022-06-20 10:38:49 +02:00
|
|
|
import { i18n } from '@/i18n';
|
|
|
|
import { $i } from '@/account';
|
2022-09-15 22:40:34 +02:00
|
|
|
import { defaultStore } from '@/store';
|
2022-09-14 06:33:03 +02:00
|
|
|
import 'swiper/scss';
|
|
|
|
import 'swiper/scss/virtual';
|
2022-06-20 10:38:49 +02:00
|
|
|
|
2022-07-01 11:55:45 +02:00
|
|
|
const XHome = defineAsyncComponent(() => import('./home.vue'));
|
2022-06-20 10:38:49 +02: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 11:55:45 +02:00
|
|
|
page: 'home',
|
2022-06-20 10:38:49 +02:00
|
|
|
});
|
2020-01-29 20:37:25 +01:00
|
|
|
|
2022-06-20 10:38:49 +02:00
|
|
|
const router = useRouter();
|
2020-01-29 20:37:25 +01:00
|
|
|
|
2022-09-14 06:33:03 +02:00
|
|
|
let tabs = ['home'];
|
2022-06-20 10:38:49 +02:00
|
|
|
let user = $ref<null | misskey.entities.UserDetailed>(null);
|
2022-09-14 06:33:03 +02:00
|
|
|
if (($i && ($i.id === user?.id)) || user?.publicReactions) {
|
|
|
|
tabs.push('reactions');
|
|
|
|
}
|
|
|
|
if ((user?.instance != null)) {
|
|
|
|
tabs.push('clips', 'pages', 'gallery');
|
|
|
|
}
|
2022-10-26 04:19:42 +02:00
|
|
|
let tab = $ref(tabs[0]);
|
|
|
|
watch($$(tab), () => (syncSlide(tabs.indexOf(tab))));
|
|
|
|
|
2022-06-20 10:38:49 +02:00
|
|
|
let error = $ref(null);
|
2020-01-29 20:37:25 +01:00
|
|
|
|
2022-06-20 10:38:49 +02: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 18:21:41 +02:00
|
|
|
|
2022-06-20 10:38:49 +02:00
|
|
|
watch(() => props.acct, fetchUser, {
|
|
|
|
immediate: true,
|
|
|
|
});
|
2020-01-29 20:37:25 +01:00
|
|
|
|
2022-06-20 10:38:49 +02:00
|
|
|
const headerActions = $computed(() => []);
|
|
|
|
|
|
|
|
const headerTabs = $computed(() => user ? [{
|
2022-07-01 11:55:45 +02:00
|
|
|
key: 'home',
|
2022-06-20 10:38:49 +02:00
|
|
|
title: i18n.ts.overview,
|
2022-11-07 03:49:47 +01:00
|
|
|
icon: 'ph-house-bold ph-lg',
|
2022-06-20 10:38:49 +02:00
|
|
|
}, ...($i && ($i.id === user.id)) || user.publicReactions ? [{
|
2022-07-01 11:55:45 +02:00
|
|
|
key: 'reactions',
|
2022-06-20 10:38:49 +02:00
|
|
|
title: i18n.ts.reaction,
|
2022-11-07 04:14:55 +01:00
|
|
|
icon: 'ph-smiley-bold ph-lg',
|
2022-06-20 10:38:49 +02:00
|
|
|
}] : [], {
|
2022-07-01 11:55:45 +02:00
|
|
|
key: 'clips',
|
2022-06-20 10:38:49 +02:00
|
|
|
title: i18n.ts.clips,
|
2022-11-07 03:49:47 +01:00
|
|
|
icon: 'ph-paperclip-bold ph-lg',
|
2022-06-20 10:38:49 +02:00
|
|
|
}, {
|
2022-07-01 11:55:45 +02:00
|
|
|
key: 'pages',
|
2022-06-20 10:38:49 +02:00
|
|
|
title: i18n.ts.pages,
|
2022-11-07 03:49:47 +01:00
|
|
|
icon: 'ph-file-text-bold ph-lg',
|
2022-06-20 10:38:49 +02:00
|
|
|
}, {
|
2022-07-01 11:55:45 +02:00
|
|
|
key: 'gallery',
|
2022-06-20 10:38:49 +02:00
|
|
|
title: i18n.ts.gallery,
|
2022-11-07 03:49:47 +01:00
|
|
|
icon: 'ph-image-square-bold ph-lg',
|
2022-06-20 10:38:49 +02:00
|
|
|
}] : null);
|
|
|
|
|
|
|
|
definePageMetadata(computed(() => user ? {
|
2022-11-07 03:49:47 +01:00
|
|
|
icon: 'ph-user-bold ph-lg',
|
2022-06-20 10:38:49 +02: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));
|
2022-09-14 06:33:03 +02:00
|
|
|
|
|
|
|
let swiperRef = null;
|
|
|
|
|
|
|
|
function setSwiperRef(swiper) {
|
|
|
|
swiperRef = swiper;
|
|
|
|
syncSlide(tabs.indexOf(tab));
|
|
|
|
}
|
|
|
|
|
|
|
|
function onSlideChange() {
|
|
|
|
tab = tabs[swiperRef.activeIndex];
|
|
|
|
}
|
|
|
|
|
|
|
|
function syncSlide(index) {
|
|
|
|
swiperRef.slideTo(index);
|
|
|
|
}
|
2020-01-29 20:37:25 +01:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
2021-04-17 04:40:47 +02:00
|
|
|
.fade-enter-active,
|
|
|
|
.fade-leave-active {
|
|
|
|
transition: opacity 0.125s ease;
|
|
|
|
}
|
|
|
|
.fade-enter-from,
|
|
|
|
.fade-leave-to {
|
|
|
|
opacity: 0;
|
|
|
|
}
|
2020-01-29 20:37:25 +01:00
|
|
|
</style>
|