2020-08-18 08:44:21 -05:00
|
|
|
<template>
|
2022-06-20 03:38:49 -05:00
|
|
|
<MkStickyContainer>
|
2022-06-22 02:29:21 -05:00
|
|
|
<template #header><MkPageHeader v-model:tab="tab" :actions="headerActions" :tabs="headerTabs"/></template>
|
2022-06-20 03:38:49 -05:00
|
|
|
<MkSpacer :content-max="700">
|
2023-04-10 17:42:27 -05:00
|
|
|
<div v-if="tab === 'search'">
|
|
|
|
<div class="_gaps">
|
|
|
|
<MkInput v-model="searchQuery" :large="true" :autofocus="true" type="search">
|
|
|
|
<template #prefix><i class="ti ti-search"></i></template>
|
|
|
|
</MkInput>
|
|
|
|
<MkRadios v-model="searchType" @update:model-value="search()">
|
|
|
|
<option value="nameAndDescription">{{ i18n.ts._channel.nameAndDescription }}</option>
|
|
|
|
<option value="nameOnly">{{ i18n.ts._channel.nameOnly }}</option>
|
|
|
|
</MkRadios>
|
|
|
|
<MkButton large primary gradate rounded @click="search">{{ i18n.ts.search }}</MkButton>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<MkFoldableSection v-if="channelPagination">
|
|
|
|
<template #header>{{ i18n.ts.searchResult }}</template>
|
|
|
|
<MkChannelList :key="key" :pagination="channelPagination"/>
|
|
|
|
</MkFoldableSection>
|
|
|
|
</div>
|
2023-03-30 21:30:27 -05:00
|
|
|
<div v-if="tab === 'featured'">
|
2022-06-20 03:38:49 -05:00
|
|
|
<MkPagination v-slot="{items}" :pagination="featuredPagination">
|
2023-01-05 06:04:56 -06:00
|
|
|
<MkChannelPreview v-for="channel in items" :key="channel.id" class="_margin" :channel="channel"/>
|
2022-06-20 03:38:49 -05:00
|
|
|
</MkPagination>
|
|
|
|
</div>
|
2023-03-30 21:30:27 -05:00
|
|
|
<div v-else-if="tab === 'favorites'">
|
|
|
|
<MkPagination v-slot="{items}" :pagination="favoritesPagination">
|
|
|
|
<MkChannelPreview v-for="channel in items" :key="channel.id" class="_margin" :channel="channel"/>
|
|
|
|
</MkPagination>
|
|
|
|
</div>
|
|
|
|
<div v-else-if="tab === 'following'">
|
2022-06-20 03:38:49 -05:00
|
|
|
<MkPagination v-slot="{items}" :pagination="followingPagination">
|
2023-01-05 06:04:56 -06:00
|
|
|
<MkChannelPreview v-for="channel in items" :key="channel.id" class="_margin" :channel="channel"/>
|
2022-06-20 03:38:49 -05:00
|
|
|
</MkPagination>
|
|
|
|
</div>
|
2023-03-30 21:30:27 -05:00
|
|
|
<div v-else-if="tab === 'owned'">
|
2022-12-19 04:01:30 -06:00
|
|
|
<MkButton class="new" @click="create()"><i class="ti ti-plus"></i></MkButton>
|
2022-06-20 03:38:49 -05:00
|
|
|
<MkPagination v-slot="{items}" :pagination="ownedPagination">
|
2023-01-05 06:04:56 -06:00
|
|
|
<MkChannelPreview v-for="channel in items" :key="channel.id" class="_margin" :channel="channel"/>
|
2022-06-20 03:38:49 -05:00
|
|
|
</MkPagination>
|
|
|
|
</div>
|
|
|
|
</MkSpacer>
|
|
|
|
</MkStickyContainer>
|
2020-08-18 08:44:21 -05:00
|
|
|
</template>
|
|
|
|
|
2022-06-20 03:38:49 -05:00
|
|
|
<script lang="ts" setup>
|
2023-04-10 17:42:27 -05:00
|
|
|
import { computed, onMounted } from 'vue';
|
2022-08-30 10:24:33 -05:00
|
|
|
import MkChannelPreview from '@/components/MkChannelPreview.vue';
|
2023-04-10 17:42:27 -05:00
|
|
|
import MkChannelList from '@/components/MkChannelList.vue';
|
2022-09-06 04:21:49 -05:00
|
|
|
import MkPagination from '@/components/MkPagination.vue';
|
2023-04-10 17:42:27 -05:00
|
|
|
import MkInput from '@/components/MkInput.vue';
|
|
|
|
import MkRadios from '@/components/MkRadios.vue';
|
2022-09-06 04:21:49 -05:00
|
|
|
import MkButton from '@/components/MkButton.vue';
|
2023-04-10 17:42:27 -05:00
|
|
|
import MkFoldableSection from '@/components/MkFoldableSection.vue';
|
2022-06-20 03:38:49 -05:00
|
|
|
import { useRouter } from '@/router';
|
|
|
|
import { definePageMetadata } from '@/scripts/page-metadata';
|
|
|
|
import { i18n } from '@/i18n';
|
2020-08-18 08:44:21 -05:00
|
|
|
|
2022-06-20 03:38:49 -05:00
|
|
|
const router = useRouter();
|
|
|
|
|
2023-04-10 17:42:27 -05:00
|
|
|
const props = defineProps<{
|
|
|
|
query: string;
|
|
|
|
type?: string;
|
|
|
|
}>();
|
|
|
|
|
|
|
|
let key = $ref('');
|
|
|
|
let tab = $ref('search');
|
|
|
|
let searchQuery = $ref('');
|
|
|
|
let searchType = $ref('nameAndDescription');
|
|
|
|
let channelPagination = $ref();
|
|
|
|
|
|
|
|
onMounted(() => {
|
|
|
|
searchQuery = props.query ?? '';
|
|
|
|
searchType = props.type ?? 'nameAndDescription';
|
|
|
|
});
|
2022-06-20 03:38:49 -05:00
|
|
|
|
|
|
|
const featuredPagination = {
|
|
|
|
endpoint: 'channels/featured' as const,
|
|
|
|
noPaging: true,
|
|
|
|
};
|
2023-03-30 21:30:27 -05:00
|
|
|
const favoritesPagination = {
|
|
|
|
endpoint: 'channels/my-favorites' as const,
|
|
|
|
limit: 100,
|
2023-04-08 18:09:25 -05:00
|
|
|
noPaging: true,
|
2023-03-30 21:30:27 -05:00
|
|
|
};
|
2022-06-20 03:38:49 -05:00
|
|
|
const followingPagination = {
|
|
|
|
endpoint: 'channels/followed' as const,
|
2023-03-30 21:30:27 -05:00
|
|
|
limit: 10,
|
2022-06-20 03:38:49 -05:00
|
|
|
};
|
|
|
|
const ownedPagination = {
|
|
|
|
endpoint: 'channels/owned' as const,
|
2023-03-30 21:30:27 -05:00
|
|
|
limit: 10,
|
2022-06-20 03:38:49 -05:00
|
|
|
};
|
|
|
|
|
2023-04-10 17:42:27 -05:00
|
|
|
async function search() {
|
|
|
|
const query = searchQuery.toString().trim();
|
|
|
|
|
|
|
|
if (query == null || query === '') return;
|
|
|
|
|
|
|
|
const type = searchType.toString().trim();
|
|
|
|
|
|
|
|
channelPagination = {
|
|
|
|
endpoint: 'channels/search',
|
|
|
|
limit: 10,
|
|
|
|
params: {
|
|
|
|
query: searchQuery,
|
|
|
|
type: type,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
key = query + type;
|
|
|
|
}
|
|
|
|
|
2022-06-20 03:38:49 -05:00
|
|
|
function create() {
|
|
|
|
router.push('/channels/new');
|
|
|
|
}
|
|
|
|
|
|
|
|
const headerActions = $computed(() => [{
|
2022-12-19 04:01:30 -06:00
|
|
|
icon: 'ti ti-plus',
|
2022-06-20 03:38:49 -05:00
|
|
|
text: i18n.ts.create,
|
|
|
|
handler: create,
|
|
|
|
}]);
|
|
|
|
|
|
|
|
const headerTabs = $computed(() => [{
|
2023-04-10 17:42:27 -05:00
|
|
|
key: 'search',
|
|
|
|
title: i18n.ts.search,
|
|
|
|
icon: 'ti ti-search',
|
|
|
|
}, {
|
2022-06-22 02:29:21 -05:00
|
|
|
key: 'featured',
|
2022-06-20 03:38:49 -05:00
|
|
|
title: i18n.ts._channel.featured,
|
2022-12-19 17:35:49 -06:00
|
|
|
icon: 'ti ti-comet',
|
2023-03-30 21:30:27 -05:00
|
|
|
}, {
|
|
|
|
key: 'favorites',
|
|
|
|
title: i18n.ts.favorites,
|
|
|
|
icon: 'ti ti-star',
|
2022-06-20 03:38:49 -05:00
|
|
|
}, {
|
2022-06-22 02:29:21 -05:00
|
|
|
key: 'following',
|
2022-06-20 03:38:49 -05:00
|
|
|
title: i18n.ts._channel.following,
|
2023-03-30 21:30:27 -05:00
|
|
|
icon: 'ti ti-eye',
|
2022-06-20 03:38:49 -05:00
|
|
|
}, {
|
2022-06-22 02:29:21 -05:00
|
|
|
key: 'owned',
|
2022-06-20 03:38:49 -05:00
|
|
|
title: i18n.ts._channel.owned,
|
2022-12-19 04:01:30 -06:00
|
|
|
icon: 'ti ti-edit',
|
2022-06-20 03:38:49 -05:00
|
|
|
}]);
|
|
|
|
|
|
|
|
definePageMetadata(computed(() => ({
|
|
|
|
title: i18n.ts.channel,
|
2022-12-19 04:01:30 -06:00
|
|
|
icon: 'ti ti-device-tv',
|
2022-06-20 03:38:49 -05:00
|
|
|
})));
|
2020-08-18 08:44:21 -05:00
|
|
|
</script>
|