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">
|
2023-05-29 22:17:42 +02:00
|
|
|
<MkInfo class="_gap" :warn="true">{{
|
|
|
|
i18n.ts.channelFederationWarn
|
|
|
|
}}</MkInfo>
|
2023-05-26 04:47:10 +02:00
|
|
|
<swiper
|
2023-05-26 23:02:17 +02:00
|
|
|
:round-lengths="true"
|
2023-05-26 04:47:10 +02:00
|
|
|
:touch-angle="25"
|
|
|
|
:threshold="10"
|
2023-09-02 01:27:33 +02:00
|
|
|
:centered-slides="true"
|
2023-04-08 02:01:42 +02:00
|
|
|
:modules="[Virtual]"
|
|
|
|
:space-between="20"
|
|
|
|
:virtual="true"
|
2023-06-26 21:47:05 +02:00
|
|
|
:allow-touch-move="
|
|
|
|
defaultStore.state.swipeOnMobile &&
|
|
|
|
(deviceKind !== 'desktop' ||
|
|
|
|
defaultStore.state.swipeOnDesktop)
|
|
|
|
"
|
2023-04-08 02:01:42 +02:00
|
|
|
@swiper="setSwiperRef"
|
|
|
|
@slide-change="onSlideChange"
|
|
|
|
>
|
2023-04-11 00:42:27 +02:00
|
|
|
<swiper-slide>
|
|
|
|
<div class="_content grwlizim search">
|
2023-05-07 02:46:07 +02:00
|
|
|
<MkInput
|
|
|
|
v-model="searchQuery"
|
|
|
|
:large="true"
|
|
|
|
:autofocus="true"
|
|
|
|
type="search"
|
|
|
|
>
|
|
|
|
<template #prefix
|
2023-10-17 03:57:20 +02:00
|
|
|
><i :class="icon('ph-magnifying-glass')"></i
|
2023-05-07 02:46:07 +02:00
|
|
|
></template>
|
|
|
|
</MkInput>
|
|
|
|
<MkRadios
|
|
|
|
v-model="searchType"
|
|
|
|
class="_gap"
|
2023-09-02 01:27:33 +02:00
|
|
|
@update:model-value="search()"
|
2023-05-07 02:46:07 +02:00
|
|
|
>
|
|
|
|
<option value="nameAndDescription">
|
|
|
|
{{ i18n.ts._channel.nameAndDescription }}
|
|
|
|
</option>
|
|
|
|
<option value="nameOnly">
|
|
|
|
{{ i18n.ts._channel.nameOnly }}
|
|
|
|
</option>
|
|
|
|
</MkRadios>
|
2023-09-02 01:27:33 +02:00
|
|
|
<MkButton large primary class="_gap" @click="search">{{
|
2023-05-08 01:12: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">
|
2023-05-07 21:48:28 +02:00
|
|
|
<!-- <MkPagination
|
2023-04-08 02:01:42 +02:00
|
|
|
v-slot="{ items }"
|
|
|
|
:pagination="featuredPagination"
|
2023-05-07 21:41:08 +02:00
|
|
|
:disable-auto-load="true"
|
2023-04-08 02:01:42 +02:00
|
|
|
>
|
|
|
|
<MkChannelPreview
|
|
|
|
v-for="channel in items"
|
|
|
|
:key="channel.id"
|
|
|
|
class="_gap"
|
|
|
|
:channel="channel"
|
|
|
|
/>
|
2023-05-07 21:48:28 +02:00
|
|
|
</MkPagination> -->
|
|
|
|
<MkChannelList
|
2023-05-08 01:12:18 +02:00
|
|
|
key="featured"
|
|
|
|
:pagination="featuredPagination"
|
|
|
|
/>
|
2023-04-08 02:01:42 +02:00
|
|
|
</div>
|
|
|
|
</swiper-slide>
|
|
|
|
<swiper-slide>
|
|
|
|
<div class="_content grwlizim following">
|
2023-05-07 21:48:28 +02:00
|
|
|
<MkChannelList
|
2023-05-08 01:12:18 +02:00
|
|
|
key="following"
|
|
|
|
:pagination="followingPagination"
|
|
|
|
/>
|
2023-04-08 02:01:42 +02:00
|
|
|
</div>
|
|
|
|
</swiper-slide>
|
|
|
|
<swiper-slide>
|
|
|
|
<div class="_content grwlizim owned">
|
|
|
|
<MkButton class="new" @click="create()"
|
2023-10-17 03:57:20 +02:00
|
|
|
><i :class="icon('ph-plus')"></i
|
2023-04-08 02:01:42 +02:00
|
|
|
></MkButton>
|
2023-05-07 21:48:28 +02:00
|
|
|
<MkChannelList
|
2023-05-08 01:12:18 +02:00
|
|
|
key="owned"
|
|
|
|
:pagination="ownedPagination"
|
|
|
|
/>
|
2023-04-08 02:01:42 +02:00
|
|
|
</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-09-02 01:27:33 +02:00
|
|
|
import { computed, onMounted, ref, watch } from "vue";
|
2023-07-11 06:16:56 +02:00
|
|
|
import { Virtual } from "swiper/modules";
|
2023-04-08 02:01:42 +02:00
|
|
|
import { Swiper, SwiperSlide } from "swiper/vue";
|
2023-05-07 01:05:18 +02:00
|
|
|
import MkChannelList from "@/components/MkChannelList.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-29 02:31:00 +02:00
|
|
|
import MkInfo from "@/components/MkInfo.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";
|
2023-10-17 03:57:20 +02:00
|
|
|
import icon from "@/scripts/icon";
|
2023-04-08 02:01:42 +02:00
|
|
|
import "swiper/scss";
|
|
|
|
import "swiper/scss/virtual";
|
2024-04-10 16:25:11 +02:00
|
|
|
import type { Swiper as SwiperType } from "swiper/types";
|
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"];
|
2023-09-02 01:16:23 +02:00
|
|
|
const tab = ref(tabs[1]);
|
2023-08-12 02:44:46 +02:00
|
|
|
watch(tab, () => syncSlide(tabs.indexOf(tab.value)));
|
2022-10-26 04:19:42 +02:00
|
|
|
|
2023-04-11 00:42:27 +02:00
|
|
|
const props = defineProps<{
|
|
|
|
query: string;
|
|
|
|
type?: string;
|
|
|
|
}>();
|
2023-09-02 01:16:23 +02:00
|
|
|
const key = ref("");
|
|
|
|
const searchQuery = ref("");
|
|
|
|
const searchType = ref("nameAndDescription");
|
|
|
|
const channelPagination = ref();
|
2023-04-11 00:42:27 +02:00
|
|
|
onMounted(() => {
|
2023-08-12 02:44:46 +02:00
|
|
|
searchQuery.value = props.query ?? "";
|
|
|
|
searchType.value = 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() {
|
2023-08-12 02:44:46 +02:00
|
|
|
const query = searchQuery.value.toString().trim();
|
2023-05-07 01:05:18 +02:00
|
|
|
if (query == null || query === "") return;
|
2023-08-12 02:44:46 +02:00
|
|
|
const type = searchType.value.toString().trim();
|
|
|
|
channelPagination.value = {
|
2023-05-07 01:05:18 +02:00
|
|
|
endpoint: "channels/search",
|
2023-04-11 00:42:27 +02:00
|
|
|
limit: 10,
|
|
|
|
params: {
|
2023-08-12 02:44:46 +02:00
|
|
|
query: searchQuery.value,
|
2023-09-02 01:27:33 +02:00
|
|
|
type,
|
2023-04-11 00:42:27 +02:00
|
|
|
},
|
|
|
|
};
|
2023-08-12 02:44:46 +02:00
|
|
|
key.value = query + type;
|
2023-04-11 00:42:27 +02:00
|
|
|
}
|
|
|
|
|
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-08-12 02:44:46 +02:00
|
|
|
const headerActions = computed(() => [
|
2023-04-08 02:01:42 +02:00
|
|
|
{
|
2023-10-17 03:57:20 +02:00
|
|
|
icon: `${icon("ph-plus")}`,
|
2023-04-08 02:01:42 +02:00
|
|
|
text: i18n.ts.create,
|
|
|
|
handler: create,
|
|
|
|
},
|
|
|
|
]);
|
2022-06-20 10:38:49 +02:00
|
|
|
|
2023-08-12 02:44:46 +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-10-17 03:57:20 +02:00
|
|
|
icon: `${icon("ph-magnifying-glass")}`,
|
2023-04-11 00:42:27 +02:00
|
|
|
},
|
2023-04-08 02:01:42 +02:00
|
|
|
{
|
|
|
|
key: "featured",
|
|
|
|
title: i18n.ts._channel.featured,
|
2023-10-17 03:57:20 +02:00
|
|
|
icon: `${icon("ph-fire-simple")}`,
|
2023-04-08 02:01:42 +02:00
|
|
|
},
|
|
|
|
{
|
|
|
|
key: "following",
|
|
|
|
title: i18n.ts._channel.following,
|
2023-10-17 03:57:20 +02:00
|
|
|
icon: `${icon("ph-heart")}`,
|
2023-04-08 02:01:42 +02:00
|
|
|
},
|
|
|
|
{
|
|
|
|
key: "owned",
|
|
|
|
title: i18n.ts._channel.owned,
|
2023-10-17 03:57:20 +02:00
|
|
|
icon: `${icon("ph-crown-simple")}`,
|
2023-04-08 02:01:42 +02:00
|
|
|
},
|
|
|
|
]);
|
2022-06-20 10:38:49 +02:00
|
|
|
|
2023-04-08 02:01:42 +02:00
|
|
|
definePageMetadata(
|
|
|
|
computed(() => ({
|
|
|
|
title: i18n.ts.channel,
|
2023-10-17 03:57:20 +02:00
|
|
|
icon: `${icon("ph-television")}`,
|
2023-07-06 03:28:27 +02:00
|
|
|
})),
|
2023-04-08 02:01:42 +02:00
|
|
|
);
|
2022-09-10 00:32:05 +02:00
|
|
|
|
2024-04-10 16:25:11 +02:00
|
|
|
let swiperRef: SwiperType | null = null;
|
2022-09-10 00:32:05 +02:00
|
|
|
|
2024-04-10 16:25:11 +02:00
|
|
|
function setSwiperRef(swiper: SwiperType) {
|
2022-09-10 00:32:05 +02:00
|
|
|
swiperRef = swiper;
|
2023-08-12 02:44:46 +02:00
|
|
|
syncSlide(tabs.indexOf(tab.value));
|
2022-09-10 00:32:05 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function onSlideChange() {
|
2024-04-10 16:25:11 +02:00
|
|
|
tab.value = tabs[swiperRef!.activeIndex];
|
2022-09-10 00:32:05 +02:00
|
|
|
}
|
|
|
|
|
2024-04-10 16:25:11 +02:00
|
|
|
function syncSlide(index: number) {
|
|
|
|
swiperRef!.slideTo(index);
|
2022-09-10 00:32:05 +02:00
|
|
|
}
|
2020-08-18 15:44:21 +02:00
|
|
|
</script>
|