2020-08-18 15:44:21 +02:00
|
|
|
<template>
|
2023-04-08 02:01:42 +02:00
|
|
|
<MkStickyContainer>
|
|
|
|
<template #header
|
|
|
|
><MkPageHeader
|
|
|
|
v-model:tab="tab"
|
|
|
|
:actions="headerActions"
|
|
|
|
:tabs="headerTabs"
|
|
|
|
/></template>
|
|
|
|
<MkSpacer :content-max="700">
|
|
|
|
<swiper
|
|
|
|
:modules="[Virtual]"
|
|
|
|
:space-between="20"
|
|
|
|
:virtual="true"
|
|
|
|
:allow-touch-move="
|
|
|
|
!(
|
|
|
|
deviceKind === 'desktop' &&
|
|
|
|
!defaultStore.state.swipeOnDesktop
|
|
|
|
)
|
|
|
|
"
|
|
|
|
@swiper="setSwiperRef"
|
|
|
|
@slide-change="onSlideChange"
|
|
|
|
>
|
2023-04-11 00:42:27 +02:00
|
|
|
<swiper-slide>
|
|
|
|
<div class="_content grwlizim search">
|
2023-05-07 01:05:18 +02:00
|
|
|
<MkInput
|
|
|
|
v-model="searchQuery"
|
|
|
|
:large="true"
|
|
|
|
:autofocus="true"
|
|
|
|
type="search"
|
|
|
|
>
|
|
|
|
<template #prefix
|
2023-05-07 02:13:37 +02:00
|
|
|
><i
|
|
|
|
class="ph-magnifying-glass ph-bold ph-lg"
|
|
|
|
></i
|
2023-05-07 01:05:18 +02:00
|
|
|
></template>
|
2023-04-11 00:42:27 +02:00
|
|
|
</MkInput>
|
2023-05-07 01:05:18 +02:00
|
|
|
<MkRadios
|
|
|
|
v-model="searchType"
|
|
|
|
@update:model-value="search()"
|
2023-05-07 02:13:37 +02:00
|
|
|
class="_gap"
|
2023-05-07 01:05:18 +02:00
|
|
|
>
|
|
|
|
<option value="nameAndDescription">
|
|
|
|
{{ i18n.ts._channel.nameAndDescription }}
|
|
|
|
</option>
|
|
|
|
<option value="nameOnly">
|
|
|
|
{{ i18n.ts._channel.nameOnly }}
|
|
|
|
</option>
|
2023-04-11 00:42:27 +02:00
|
|
|
</MkRadios>
|
2023-05-07 01:05:18 +02:00
|
|
|
<MkButton
|
|
|
|
large
|
|
|
|
primary
|
|
|
|
gradate
|
|
|
|
rounded
|
|
|
|
@click="search"
|
2023-05-07 02:13:37 +02:00
|
|
|
class="_gap"
|
2023-05-07 01:05:18 +02:00
|
|
|
>{{ i18n.ts.search }}</MkButton
|
|
|
|
>
|
2023-04-11 00:42:27 +02:00
|
|
|
<MkFoldableSection v-if="channelPagination">
|
2023-05-07 01:05:18 +02:00
|
|
|
<template #header>{{
|
|
|
|
i18n.ts.searchResult
|
|
|
|
}}</template>
|
|
|
|
<MkChannelList
|
|
|
|
:key="key"
|
|
|
|
:pagination="channelPagination"
|
|
|
|
/>
|
2023-04-11 00:42:27 +02:00
|
|
|
</MkFoldableSection>
|
|
|
|
</div>
|
|
|
|
</swiper-slide>
|
2023-04-08 02:01:42 +02:00
|
|
|
<swiper-slide>
|
|
|
|
<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>
|
|
|
|
</swiper-slide>
|
|
|
|
<swiper-slide>
|
|
|
|
<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>
|
|
|
|
</swiper-slide>
|
|
|
|
<swiper-slide>
|
|
|
|
<div class="_content grwlizim owned">
|
|
|
|
<MkButton class="new" @click="create()"
|
|
|
|
><i class="ph-plus ph-bold ph-lg"></i
|
|
|
|
></MkButton>
|
|
|
|
<MkPagination
|
|
|
|
v-slot="{ items }"
|
|
|
|
:pagination="ownedPagination"
|
|
|
|
>
|
|
|
|
<MkChannelPreview
|
|
|
|
v-for="channel in items"
|
|
|
|
:key="channel.id"
|
|
|
|
class="_gap"
|
|
|
|
:channel="channel"
|
|
|
|
/>
|
|
|
|
</MkPagination>
|
|
|
|
</div>
|
|
|
|
</swiper-slide>
|
|
|
|
</swiper>
|
|
|
|
</MkSpacer>
|
|
|
|
</MkStickyContainer>
|
2020-08-18 15:44:21 +02:00
|
|
|
</template>
|
|
|
|
|
2022-06-20 10:38:49 +02:00
|
|
|
<script lang="ts" setup>
|
2023-04-11 00:42:27 +02:00
|
|
|
import { computed, onMounted, defineComponent, inject, watch } from "vue";
|
2023-04-08 02:01:42 +02:00
|
|
|
import { Virtual } from "swiper";
|
|
|
|
import { Swiper, SwiperSlide } from "swiper/vue";
|
|
|
|
import MkChannelPreview from "@/components/MkChannelPreview.vue";
|
2023-05-07 01:05:18 +02:00
|
|
|
import MkChannelList from "@/components/MkChannelList.vue";
|
2023-04-08 02:01:42 +02:00
|
|
|
import MkPagination from "@/components/MkPagination.vue";
|
2023-05-07 02:13:37 +02:00
|
|
|
import MkInput from "@/components/form/input.vue";
|
|
|
|
import MkRadios from "@/components/form/radios.vue";
|
2023-04-08 02:01:42 +02:00
|
|
|
import MkButton from "@/components/MkButton.vue";
|
2023-05-07 02:13:37 +02:00
|
|
|
import MkFolder from "@/components/MkFolder.vue";
|
2023-04-08 02:01:42 +02:00
|
|
|
import { useRouter } from "@/router";
|
|
|
|
import { definePageMetadata } from "@/scripts/page-metadata";
|
|
|
|
import { deviceKind } from "@/scripts/device-kind";
|
|
|
|
import { i18n } from "@/i18n";
|
|
|
|
import { defaultStore } from "@/store";
|
|
|
|
import "swiper/scss";
|
|
|
|
import "swiper/scss/virtual";
|
2020-08-18 15:44:21 +02:00
|
|
|
|
2022-06-20 10:38:49 +02:00
|
|
|
const router = useRouter();
|
|
|
|
|
2023-04-11 00:42:27 +02:00
|
|
|
const tabs = ["search", "featured", "following", "owned"];
|
|
|
|
let tab = $ref(tabs[1]);
|
2023-04-08 02:01:42 +02:00
|
|
|
watch($$(tab), () => syncSlide(tabs.indexOf(tab)));
|
2022-10-26 04:19:42 +02:00
|
|
|
|
2023-04-11 00:42:27 +02:00
|
|
|
const props = defineProps<{
|
|
|
|
query: string;
|
|
|
|
type?: string;
|
|
|
|
}>();
|
2023-05-07 01:05:18 +02:00
|
|
|
let key = $ref("");
|
|
|
|
let searchQuery = $ref("");
|
|
|
|
let searchType = $ref("nameAndDescription");
|
2023-04-11 00:42:27 +02:00
|
|
|
let channelPagination = $ref();
|
|
|
|
onMounted(() => {
|
2023-05-07 01:05:18 +02:00
|
|
|
searchQuery = props.query ?? "";
|
|
|
|
searchType = props.type ?? "nameAndDescription";
|
2023-04-11 00:42:27 +02:00
|
|
|
});
|
|
|
|
|
2022-06-20 10:38:49 +02:00
|
|
|
const featuredPagination = {
|
2023-04-08 02:01:42 +02:00
|
|
|
endpoint: "channels/featured" as const,
|
2022-11-04 23:25:31 +01:00
|
|
|
limit: 10,
|
|
|
|
noPaging: false,
|
2022-06-20 10:38:49 +02:00
|
|
|
};
|
|
|
|
const followingPagination = {
|
2023-04-08 02:01:42 +02:00
|
|
|
endpoint: "channels/followed" as const,
|
2022-11-04 23:25:31 +01:00
|
|
|
limit: 10,
|
2022-06-20 10:38:49 +02:00
|
|
|
};
|
|
|
|
const ownedPagination = {
|
2023-04-08 02:01:42 +02:00
|
|
|
endpoint: "channels/owned" as const,
|
2022-11-04 23:25:31 +01:00
|
|
|
limit: 10,
|
2022-06-20 10:38:49 +02:00
|
|
|
};
|
|
|
|
|
2023-04-11 00:42:27 +02:00
|
|
|
async function search() {
|
|
|
|
const query = searchQuery.toString().trim();
|
2023-05-07 01:05:18 +02:00
|
|
|
if (query == null || query === "") return;
|
2023-04-11 00:42:27 +02:00
|
|
|
const type = searchType.toString().trim();
|
|
|
|
channelPagination = {
|
2023-05-07 01:05:18 +02:00
|
|
|
endpoint: "channels/search",
|
2023-04-11 00:42:27 +02:00
|
|
|
limit: 10,
|
|
|
|
params: {
|
|
|
|
query: searchQuery,
|
|
|
|
type: type,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
key = query + type;
|
|
|
|
}
|
|
|
|
|
2022-06-20 10:38:49 +02:00
|
|
|
function create() {
|
2023-04-08 02:01:42 +02:00
|
|
|
router.push("/channels/new");
|
2022-06-20 10:38:49 +02:00
|
|
|
}
|
|
|
|
|
2023-04-08 02:01:42 +02:00
|
|
|
const headerActions = $computed(() => [
|
|
|
|
{
|
|
|
|
icon: "ph-plus ph-bold ph-lg",
|
|
|
|
text: i18n.ts.create,
|
|
|
|
handler: create,
|
|
|
|
},
|
|
|
|
]);
|
2022-06-20 10:38:49 +02:00
|
|
|
|
2023-04-08 02:01:42 +02:00
|
|
|
const headerTabs = $computed(() => [
|
2023-04-11 00:42:27 +02:00
|
|
|
{
|
2023-05-07 01:05:18 +02:00
|
|
|
key: "search",
|
2023-04-11 00:42:27 +02:00
|
|
|
title: i18n.ts.search,
|
2023-05-07 02:13:37 +02:00
|
|
|
icon: "ph-magnifying-glass ph-bold ph-lg",
|
2023-04-11 00:42:27 +02:00
|
|
|
},
|
2023-04-08 02:01:42 +02:00
|
|
|
{
|
|
|
|
key: "featured",
|
|
|
|
title: i18n.ts._channel.featured,
|
|
|
|
icon: "ph-fire-simple ph-bold ph-lg",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
key: "following",
|
|
|
|
title: i18n.ts._channel.following,
|
|
|
|
icon: "ph-heart ph-bold ph-lg",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
key: "owned",
|
|
|
|
title: i18n.ts._channel.owned,
|
|
|
|
icon: "ph-crown-simple ph-bold ph-lg",
|
|
|
|
},
|
|
|
|
]);
|
2022-06-20 10:38:49 +02:00
|
|
|
|
2023-04-08 02:01:42 +02:00
|
|
|
definePageMetadata(
|
|
|
|
computed(() => ({
|
|
|
|
title: i18n.ts.channel,
|
|
|
|
icon: "ph-television ph-bold ph-lg",
|
|
|
|
}))
|
|
|
|
);
|
2022-09-10 00:32:05 +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-08-18 15:44:21 +02:00
|
|
|
</script>
|