2023-07-27 05:31:52 +00:00
|
|
|
<!--
|
2024-02-13 15:59:27 +00:00
|
|
|
SPDX-FileCopyrightText: syuilo and misskey-project
|
2023-07-27 05:31:52 +00:00
|
|
|
SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
-->
|
|
|
|
|
2020-08-18 13:44:21 +00:00
|
|
|
<template>
|
2022-06-20 08:38:49 +00:00
|
|
|
<MkStickyContainer>
|
2022-06-22 07:29:21 +00:00
|
|
|
<template #header><MkPageHeader v-model:tab="tab" :actions="headerActions" :tabs="headerTabs"/></template>
|
2023-05-19 07:20:53 +00:00
|
|
|
<MkSpacer :contentMax="700">
|
2024-01-18 09:21:33 +00:00
|
|
|
<MkHorizontalSwipe v-model:tab="tab" :tabs="headerTabs">
|
|
|
|
<div v-if="tab === 'search'" key="search">
|
|
|
|
<div class="_gaps">
|
|
|
|
<MkInput v-model="searchQuery" :large="true" :autofocus="true" type="search" @enter="search">
|
2024-01-21 12:11:23 +00:00
|
|
|
<template #prefix><i class="ph-magnifying-glass ph-bold ph-lg"></i></template>
|
2024-01-18 09:21:33 +00:00
|
|
|
</MkInput>
|
|
|
|
<MkRadios v-model="searchType" @update:modelValue="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>
|
2023-04-10 22:42:27 +00:00
|
|
|
|
2024-01-18 09:21:33 +00:00
|
|
|
<MkFoldableSection v-if="channelPagination">
|
|
|
|
<template #header>{{ i18n.ts.searchResult }}</template>
|
|
|
|
<MkChannelList :key="key" :pagination="channelPagination"/>
|
|
|
|
</MkFoldableSection>
|
|
|
|
</div>
|
|
|
|
<div v-if="tab === 'featured'" key="featured">
|
|
|
|
<MkPagination v-slot="{items}" :pagination="featuredPagination">
|
|
|
|
<MkChannelPreview v-for="channel in items" :key="channel.id" class="_margin" :channel="channel"/>
|
|
|
|
</MkPagination>
|
|
|
|
</div>
|
|
|
|
<div v-else-if="tab === 'favorites'" key="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'" key="following">
|
|
|
|
<MkPagination v-slot="{items}" :pagination="followingPagination">
|
|
|
|
<MkChannelPreview v-for="channel in items" :key="channel.id" class="_margin" :channel="channel"/>
|
|
|
|
</MkPagination>
|
|
|
|
</div>
|
|
|
|
<div v-else-if="tab === 'owned'" key="owned">
|
2024-01-21 12:11:23 +00:00
|
|
|
<MkButton class="new" @click="create()"><i class="ph-plus ph-bold ph-lg"></i></MkButton>
|
2024-01-18 09:21:33 +00:00
|
|
|
<MkPagination v-slot="{items}" :pagination="ownedPagination">
|
|
|
|
<MkChannelPreview v-for="channel in items" :key="channel.id" class="_margin" :channel="channel"/>
|
|
|
|
</MkPagination>
|
|
|
|
</div>
|
|
|
|
</MkHorizontalSwipe>
|
2022-06-20 08:38:49 +00:00
|
|
|
</MkSpacer>
|
|
|
|
</MkStickyContainer>
|
2020-08-18 13:44:21 +00:00
|
|
|
</template>
|
|
|
|
|
2022-06-20 08:38:49 +00:00
|
|
|
<script lang="ts" setup>
|
2023-12-07 05:42:09 +00:00
|
|
|
import { computed, onMounted, ref } from 'vue';
|
2022-08-30 15:24:33 +00:00
|
|
|
import MkChannelPreview from '@/components/MkChannelPreview.vue';
|
2023-04-10 22:42:27 +00:00
|
|
|
import MkChannelList from '@/components/MkChannelList.vue';
|
2023-12-27 06:55:09 +00:00
|
|
|
import MkPagination from '@/components/MkPagination.vue';
|
2023-04-10 22:42:27 +00:00
|
|
|
import MkInput from '@/components/MkInput.vue';
|
|
|
|
import MkRadios from '@/components/MkRadios.vue';
|
2022-09-06 09:21:49 +00:00
|
|
|
import MkButton from '@/components/MkButton.vue';
|
2023-04-10 22:42:27 +00:00
|
|
|
import MkFoldableSection from '@/components/MkFoldableSection.vue';
|
2024-01-18 09:21:33 +00:00
|
|
|
import MkHorizontalSwipe from '@/components/MkHorizontalSwipe.vue';
|
2023-09-19 07:37:43 +00:00
|
|
|
import { definePageMetadata } from '@/scripts/page-metadata.js';
|
|
|
|
import { i18n } from '@/i18n.js';
|
2024-01-30 12:07:34 +00:00
|
|
|
import { useRouter } from '@/router/supplier.js';
|
2020-08-18 13:44:21 +00:00
|
|
|
|
2022-06-20 08:38:49 +00:00
|
|
|
const router = useRouter();
|
|
|
|
|
2023-04-10 22:42:27 +00:00
|
|
|
const props = defineProps<{
|
|
|
|
query: string;
|
|
|
|
type?: string;
|
|
|
|
}>();
|
|
|
|
|
2023-12-07 05:42:09 +00:00
|
|
|
const key = ref('');
|
|
|
|
const tab = ref('featured');
|
|
|
|
const searchQuery = ref('');
|
|
|
|
const searchType = ref('nameAndDescription');
|
|
|
|
const channelPagination = ref();
|
2023-04-10 22:42:27 +00:00
|
|
|
|
|
|
|
onMounted(() => {
|
2023-12-07 05:42:09 +00:00
|
|
|
searchQuery.value = props.query ?? '';
|
|
|
|
searchType.value = props.type ?? 'nameAndDescription';
|
2023-04-10 22:42:27 +00:00
|
|
|
});
|
2022-06-20 08:38:49 +00:00
|
|
|
|
|
|
|
const featuredPagination = {
|
|
|
|
endpoint: 'channels/featured' as const,
|
|
|
|
noPaging: true,
|
2023-12-27 06:55:09 +00:00
|
|
|
};
|
2023-03-31 02:30:27 +00:00
|
|
|
const favoritesPagination = {
|
|
|
|
endpoint: 'channels/my-favorites' as const,
|
|
|
|
limit: 100,
|
2023-04-08 23:09:25 +00:00
|
|
|
noPaging: true,
|
2023-12-27 06:55:09 +00:00
|
|
|
};
|
2022-06-20 08:38:49 +00:00
|
|
|
const followingPagination = {
|
|
|
|
endpoint: 'channels/followed' as const,
|
2023-03-31 02:30:27 +00:00
|
|
|
limit: 10,
|
2023-12-27 06:55:09 +00:00
|
|
|
};
|
2022-06-20 08:38:49 +00:00
|
|
|
const ownedPagination = {
|
|
|
|
endpoint: 'channels/owned' as const,
|
2023-03-31 02:30:27 +00:00
|
|
|
limit: 10,
|
2023-12-27 06:55:09 +00:00
|
|
|
};
|
2022-06-20 08:38:49 +00:00
|
|
|
|
2023-04-10 22:42:27 +00:00
|
|
|
async function search() {
|
2023-12-07 05:42:09 +00:00
|
|
|
const query = searchQuery.value.toString().trim();
|
2023-04-10 22:42:27 +00:00
|
|
|
|
2023-05-04 23:48:14 +00:00
|
|
|
if (query == null) return;
|
2023-04-10 22:42:27 +00:00
|
|
|
|
2023-12-07 05:42:09 +00:00
|
|
|
const type = searchType.value.toString().trim();
|
2023-04-10 22:42:27 +00:00
|
|
|
|
2023-12-07 05:42:09 +00:00
|
|
|
channelPagination.value = {
|
2023-04-10 22:42:27 +00:00
|
|
|
endpoint: 'channels/search',
|
|
|
|
limit: 10,
|
|
|
|
params: {
|
2023-12-07 05:42:09 +00:00
|
|
|
query: searchQuery.value,
|
2023-04-10 22:42:27 +00:00
|
|
|
type: type,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2023-12-07 05:42:09 +00:00
|
|
|
key.value = query + type;
|
2023-04-10 22:42:27 +00:00
|
|
|
}
|
|
|
|
|
2022-06-20 08:38:49 +00:00
|
|
|
function create() {
|
|
|
|
router.push('/channels/new');
|
|
|
|
}
|
|
|
|
|
2023-12-07 05:42:09 +00:00
|
|
|
const headerActions = computed(() => [{
|
2023-09-30 19:53:52 +00:00
|
|
|
icon: 'ph-plus ph-bold ph-lg',
|
2022-06-20 08:38:49 +00:00
|
|
|
text: i18n.ts.create,
|
|
|
|
handler: create,
|
|
|
|
}]);
|
|
|
|
|
2023-12-07 05:42:09 +00:00
|
|
|
const headerTabs = computed(() => [{
|
2023-04-10 22:42:27 +00:00
|
|
|
key: 'search',
|
|
|
|
title: i18n.ts.search,
|
2023-09-30 19:53:52 +00:00
|
|
|
icon: 'ph-magnifying-glass ph-bold ph-lg',
|
2023-04-10 22:42:27 +00:00
|
|
|
}, {
|
2022-06-22 07:29:21 +00:00
|
|
|
key: 'featured',
|
2022-06-20 08:38:49 +00:00
|
|
|
title: i18n.ts._channel.featured,
|
2023-09-30 22:46:42 +00:00
|
|
|
icon: 'ph-shooting-star ph-bold ph-lg',
|
2023-03-31 02:30:27 +00:00
|
|
|
}, {
|
|
|
|
key: 'favorites',
|
|
|
|
title: i18n.ts.favorites,
|
2023-11-03 22:20:53 +00:00
|
|
|
icon: 'ph-star ph-bold ph-lg',
|
2022-06-20 08:38:49 +00:00
|
|
|
}, {
|
2022-06-22 07:29:21 +00:00
|
|
|
key: 'following',
|
2022-06-20 08:38:49 +00:00
|
|
|
title: i18n.ts._channel.following,
|
2023-09-30 19:53:52 +00:00
|
|
|
icon: 'ph-eye ph-bold ph-lg',
|
2022-06-20 08:38:49 +00:00
|
|
|
}, {
|
2022-06-22 07:29:21 +00:00
|
|
|
key: 'owned',
|
2022-06-20 08:38:49 +00:00
|
|
|
title: i18n.ts._channel.owned,
|
2024-02-05 11:39:15 +00:00
|
|
|
icon: 'ph-pencil-simple-line ph-bold ph-lg',
|
2022-06-20 08:38:49 +00:00
|
|
|
}]);
|
|
|
|
|
2024-02-16 07:17:09 +00:00
|
|
|
definePageMetadata(() => ({
|
2022-06-20 08:38:49 +00:00
|
|
|
title: i18n.ts.channel,
|
2023-09-30 19:53:52 +00:00
|
|
|
icon: 'ph-television ph-bold ph-lg',
|
2024-02-16 07:17:09 +00:00
|
|
|
}));
|
2020-08-18 13:44:21 +00:00
|
|
|
</script>
|