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">
|
2023-03-12 06:01:04 +09:00
|
|
|
<MkButton class="new" @click="create()"><i class="ph-plus ph-bold ph-lg"></i></MkButton>
|
2022-09-10 07:32:05 +09:00
|
|
|
<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>
|
2022-10-26 11:48:25 +09:00
|
|
|
import { computed, defineComponent, inject, watch } 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,
|
2022-11-05 07:25:31 +09:00
|
|
|
limit: 10,
|
|
|
|
noPaging: false,
|
2022-06-20 17:38:49 +09:00
|
|
|
};
|
|
|
|
const followingPagination = {
|
|
|
|
endpoint: 'channels/followed' as const,
|
2022-11-05 07:25:31 +09:00
|
|
|
limit: 10,
|
2022-06-20 17:38:49 +09:00
|
|
|
};
|
|
|
|
const ownedPagination = {
|
|
|
|
endpoint: 'channels/owned' as const,
|
2022-11-05 07:25:31 +09:00
|
|
|
limit: 10,
|
2022-06-20 17:38:49 +09:00
|
|
|
};
|
|
|
|
|
|
|
|
function create() {
|
|
|
|
router.push('/channels/new');
|
|
|
|
}
|
|
|
|
|
|
|
|
const headerActions = $computed(() => [{
|
2023-03-12 06:01:04 +09:00
|
|
|
icon: 'ph-plus ph-bold ph-lg',
|
2022-06-20 17:38:49 +09:00
|
|
|
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,
|
2023-03-12 06:01:04 +09:00
|
|
|
icon: 'ph-fire-simple ph-bold ph-lg',
|
2022-06-20 17:38:49 +09:00
|
|
|
}, {
|
2022-06-22 16:29:21 +09:00
|
|
|
key: 'following',
|
2022-06-20 17:38:49 +09:00
|
|
|
title: i18n.ts._channel.following,
|
2023-03-12 06:01:04 +09:00
|
|
|
icon: 'ph-heart ph-bold ph-lg',
|
2022-06-20 17:38:49 +09:00
|
|
|
}, {
|
2022-06-22 16:29:21 +09:00
|
|
|
key: 'owned',
|
2022-06-20 17:38:49 +09:00
|
|
|
title: i18n.ts._channel.owned,
|
2023-03-12 06:01:04 +09:00
|
|
|
icon: 'ph-crown-simple ph-bold ph-lg',
|
2022-06-20 17:38:49 +09:00
|
|
|
}]);
|
|
|
|
|
|
|
|
definePageMetadata(computed(() => ({
|
|
|
|
title: i18n.ts.channel,
|
2023-03-12 06:01:04 +09:00
|
|
|
icon: 'ph-television ph-bold ph-lg',
|
2022-06-20 17:38:49 +09:00
|
|
|
})));
|
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>
|