2020-08-18 22:44:21 +09:00
|
|
|
<template>
|
2022-06-20 17:38:49 +09:00
|
|
|
<MkStickyContainer>
|
2022-06-22 16:29:21 +09:00
|
|
|
<template #header><MkPageHeader v-model:tab="tab" :actions="headerActions" :tabs="headerTabs"/></template>
|
2022-09-10 07:42:17 +09:00
|
|
|
<MkSpacer :content-max="700">
|
|
|
|
<swiper
|
|
|
|
:modules="[Virtual]"
|
|
|
|
:space-between="20"
|
|
|
|
:virtual="true"
|
2022-09-16 05:40:34 +09:00
|
|
|
:allow-touch-move="!(deviceKind === 'desktop' && !defaultStore.state.swipeOnDesktop)"
|
2022-09-10 07:42:17 +09:00
|
|
|
@swiper="setSwiperRef"
|
|
|
|
@slide-change="onSlideChange"
|
|
|
|
>
|
|
|
|
<swiper-slide>
|
2022-09-10 07:32:05 +09:00
|
|
|
<div class="_content grwlizim featured">
|
|
|
|
<MkPagination v-slot="{items}" :pagination="featuredPagination">
|
|
|
|
<MkChannelPreview v-for="channel in items" :key="channel.id" class="_gap" :channel="channel"/>
|
|
|
|
</MkPagination>
|
|
|
|
</div>
|
2022-09-10 07:42:17 +09:00
|
|
|
</swiper-slide>
|
|
|
|
<swiper-slide>
|
2022-09-10 07:32:05 +09:00
|
|
|
<div class="_content grwlizim following">
|
|
|
|
<MkPagination v-slot="{items}" :pagination="followingPagination">
|
|
|
|
<MkChannelPreview v-for="channel in items" :key="channel.id" class="_gap" :channel="channel"/>
|
|
|
|
</MkPagination>
|
|
|
|
</div>
|
2022-09-10 07:42:17 +09:00
|
|
|
</swiper-slide>
|
|
|
|
<swiper-slide>
|
2022-09-10 07:32:05 +09:00
|
|
|
<div class="_content grwlizim owned">
|
|
|
|
<MkButton class="new" @click="create()"><i class="fas fa-plus"></i></MkButton>
|
|
|
|
<MkPagination v-slot="{items}" :pagination="ownedPagination">
|
|
|
|
<MkChannelPreview v-for="channel in items" :key="channel.id" class="_gap" :channel="channel"/>
|
|
|
|
</MkPagination>
|
|
|
|
</div>
|
2022-09-10 07:42:17 +09:00
|
|
|
</swiper-slide>
|
|
|
|
</swiper>
|
|
|
|
</MkSpacer>
|
2022-06-20 17:38:49 +09:00
|
|
|
</MkStickyContainer>
|
2020-08-18 22:44:21 +09:00
|
|
|
</template>
|
|
|
|
|
2022-06-20 17:38:49 +09:00
|
|
|
<script lang="ts" setup>
|
|
|
|
import { computed, defineComponent, inject } from 'vue';
|
2022-09-10 07:32:05 +09:00
|
|
|
import { Virtual } from 'swiper';
|
|
|
|
import { Swiper, SwiperSlide } from 'swiper/vue';
|
2022-08-31 00:24:33 +09:00
|
|
|
import MkChannelPreview from '@/components/MkChannelPreview.vue';
|
2022-09-06 18:21:49 +09:00
|
|
|
import MkPagination from '@/components/MkPagination.vue';
|
|
|
|
import MkButton from '@/components/MkButton.vue';
|
2022-06-20 17:38:49 +09:00
|
|
|
import { useRouter } from '@/router';
|
|
|
|
import { definePageMetadata } from '@/scripts/page-metadata';
|
2022-09-16 02:43:48 +09:00
|
|
|
import { deviceKind } from '@/scripts/device-kind';
|
2022-06-20 17:38:49 +09:00
|
|
|
import { i18n } from '@/i18n';
|
2022-09-16 05:40:34 +09:00
|
|
|
import { defaultStore } from '@/store';
|
2022-09-10 07:32:05 +09:00
|
|
|
import 'swiper/scss';
|
|
|
|
import 'swiper/scss/virtual';
|
2020-08-18 22:44:21 +09:00
|
|
|
|
2022-06-20 17:38:49 +09:00
|
|
|
const router = useRouter();
|
|
|
|
|
2022-09-10 07:32:05 +09:00
|
|
|
const tabs = ['featured', 'following', 'owned'];
|
2022-10-26 11:19:42 +09:00
|
|
|
let tab = $ref(tabs[0]);
|
|
|
|
watch($$(tab), () => (syncSlide(tabs.indexOf(tab))));
|
|
|
|
|
2022-06-20 17:38:49 +09:00
|
|
|
|
|
|
|
const featuredPagination = {
|
|
|
|
endpoint: 'channels/featured' as const,
|
|
|
|
noPaging: true,
|
|
|
|
};
|
|
|
|
const followingPagination = {
|
|
|
|
endpoint: 'channels/followed' as const,
|
|
|
|
limit: 5,
|
|
|
|
};
|
|
|
|
const ownedPagination = {
|
|
|
|
endpoint: 'channels/owned' as const,
|
|
|
|
limit: 5,
|
|
|
|
};
|
|
|
|
|
|
|
|
function create() {
|
|
|
|
router.push('/channels/new');
|
|
|
|
}
|
|
|
|
|
|
|
|
const headerActions = $computed(() => [{
|
|
|
|
icon: 'fas fa-plus',
|
|
|
|
text: i18n.ts.create,
|
|
|
|
handler: create,
|
|
|
|
}]);
|
|
|
|
|
|
|
|
const headerTabs = $computed(() => [{
|
2022-06-22 16:29:21 +09:00
|
|
|
key: 'featured',
|
2022-06-20 17:38:49 +09:00
|
|
|
title: i18n.ts._channel.featured,
|
|
|
|
icon: 'fas fa-fire-alt',
|
|
|
|
}, {
|
2022-06-22 16:29:21 +09:00
|
|
|
key: 'following',
|
2022-06-20 17:38:49 +09:00
|
|
|
title: i18n.ts._channel.following,
|
|
|
|
icon: 'fas fa-heart',
|
|
|
|
}, {
|
2022-06-22 16:29:21 +09:00
|
|
|
key: 'owned',
|
2022-06-20 17:38:49 +09:00
|
|
|
title: i18n.ts._channel.owned,
|
|
|
|
icon: 'fas fa-edit',
|
|
|
|
}]);
|
|
|
|
|
|
|
|
definePageMetadata(computed(() => ({
|
|
|
|
title: i18n.ts.channel,
|
|
|
|
icon: 'fas fa-satellite-dish',
|
|
|
|
})));
|
2022-09-10 07:32:05 +09: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-08-18 22:44:21 +09:00
|
|
|
</script>
|