mirror of
https://git.joinsharkey.org/Sharkey/Sharkey.git
synced 2024-11-15 13:53:09 +02:00
406b4bdbe7
* refactor(frontend): 非推奨となったReactivity Transformを使わないように * refactor: 不要な括弧を除去 * fix: 不要なアノテーションを除去 * fix: Refの配列をrefしている部分の対応 * refactor: 不要な括弧を除去 * fix: lint * refactor: Ref、ShallowRef、ComputedRefの変数の宣言をletからconstに置換 * fix: type error * chore: drop reactivity transform from eslint configuration * refactor: remove unnecessary import * fix: 対応漏れ
156 lines
4.4 KiB
Vue
156 lines
4.4 KiB
Vue
<!--
|
|
SPDX-FileCopyrightText: syuilo and other misskey contributors
|
|
SPDX-License-Identifier: AGPL-3.0-only
|
|
-->
|
|
|
|
<template>
|
|
<MkStickyContainer>
|
|
<template #header><MkPageHeader v-model:tab="tab" :actions="headerActions" :tabs="headerTabs"/></template>
|
|
<MkSpacer :contentMax="700">
|
|
<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: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>
|
|
|
|
<MkFoldableSection v-if="channelPagination">
|
|
<template #header>{{ i18n.ts.searchResult }}</template>
|
|
<MkChannelList :key="key" :pagination="channelPagination"/>
|
|
</MkFoldableSection>
|
|
</div>
|
|
<div v-if="tab === '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'">
|
|
<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'">
|
|
<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'">
|
|
<MkButton class="new" @click="create()"><i class="ti ti-plus"></i></MkButton>
|
|
<MkPagination v-slot="{items}" :pagination="ownedPagination">
|
|
<MkChannelPreview v-for="channel in items" :key="channel.id" class="_margin" :channel="channel"/>
|
|
</MkPagination>
|
|
</div>
|
|
</MkSpacer>
|
|
</MkStickyContainer>
|
|
</template>
|
|
|
|
<script lang="ts" setup>
|
|
import { computed, onMounted, ref } from 'vue';
|
|
import MkChannelPreview from '@/components/MkChannelPreview.vue';
|
|
import MkChannelList from '@/components/MkChannelList.vue';
|
|
import MkPagination from '@/components/MkPagination.vue';
|
|
import MkInput from '@/components/MkInput.vue';
|
|
import MkRadios from '@/components/MkRadios.vue';
|
|
import MkButton from '@/components/MkButton.vue';
|
|
import MkFoldableSection from '@/components/MkFoldableSection.vue';
|
|
import { useRouter } from '@/router.js';
|
|
import { definePageMetadata } from '@/scripts/page-metadata.js';
|
|
import { i18n } from '@/i18n.js';
|
|
|
|
const router = useRouter();
|
|
|
|
const props = defineProps<{
|
|
query: string;
|
|
type?: string;
|
|
}>();
|
|
|
|
const key = ref('');
|
|
const tab = ref('featured');
|
|
const searchQuery = ref('');
|
|
const searchType = ref('nameAndDescription');
|
|
const channelPagination = ref();
|
|
|
|
onMounted(() => {
|
|
searchQuery.value = props.query ?? '';
|
|
searchType.value = props.type ?? 'nameAndDescription';
|
|
});
|
|
|
|
const featuredPagination = {
|
|
endpoint: 'channels/featured' as const,
|
|
noPaging: true,
|
|
};
|
|
const favoritesPagination = {
|
|
endpoint: 'channels/my-favorites' as const,
|
|
limit: 100,
|
|
noPaging: true,
|
|
};
|
|
const followingPagination = {
|
|
endpoint: 'channels/followed' as const,
|
|
limit: 10,
|
|
};
|
|
const ownedPagination = {
|
|
endpoint: 'channels/owned' as const,
|
|
limit: 10,
|
|
};
|
|
|
|
async function search() {
|
|
const query = searchQuery.value.toString().trim();
|
|
|
|
if (query == null) return;
|
|
|
|
const type = searchType.value.toString().trim();
|
|
|
|
channelPagination.value = {
|
|
endpoint: 'channels/search',
|
|
limit: 10,
|
|
params: {
|
|
query: searchQuery.value,
|
|
type: type,
|
|
},
|
|
};
|
|
|
|
key.value = query + type;
|
|
}
|
|
|
|
function create() {
|
|
router.push('/channels/new');
|
|
}
|
|
|
|
const headerActions = computed(() => [{
|
|
icon: 'ti ti-plus',
|
|
text: i18n.ts.create,
|
|
handler: create,
|
|
}]);
|
|
|
|
const headerTabs = computed(() => [{
|
|
key: 'search',
|
|
title: i18n.ts.search,
|
|
icon: 'ti ti-search',
|
|
}, {
|
|
key: 'featured',
|
|
title: i18n.ts._channel.featured,
|
|
icon: 'ti ti-comet',
|
|
}, {
|
|
key: 'favorites',
|
|
title: i18n.ts.favorites,
|
|
icon: 'ti ti-star',
|
|
}, {
|
|
key: 'following',
|
|
title: i18n.ts._channel.following,
|
|
icon: 'ti ti-eye',
|
|
}, {
|
|
key: 'owned',
|
|
title: i18n.ts._channel.owned,
|
|
icon: 'ti ti-edit',
|
|
}]);
|
|
|
|
definePageMetadata(computed(() => ({
|
|
title: i18n.ts.channel,
|
|
icon: 'ti ti-device-tv',
|
|
})));
|
|
</script>
|