2020-01-29 12:37:25 -07:00
|
|
|
<template>
|
2022-06-20 02:38:49 -06:00
|
|
|
<MkStickyContainer>
|
2023-04-01 12:28:34 -06:00
|
|
|
<template #header><MkPageHeader v-model:tab="tab" :actions="headerActions" :tabs="headerTabs"/></template>
|
2022-06-20 02:38:49 -06:00
|
|
|
<MkSpacer :content-max="800">
|
2023-04-01 12:28:34 -06:00
|
|
|
<swiper
|
|
|
|
:modules="[Virtual]"
|
|
|
|
:space-between="20"
|
|
|
|
:virtual="true"
|
|
|
|
:allow-touch-move="!(deviceKind === 'desktop' && !defaultStore.state.swipeOnDesktop)"
|
|
|
|
@swiper="setSwiperRef"
|
|
|
|
@slide-change="onSlideChange"
|
|
|
|
>
|
|
|
|
<swiper-slide>
|
|
|
|
<XNotes ref="notes" :pagination="notesPagination"/>
|
|
|
|
</swiper-slide>
|
|
|
|
<swiper-slide>
|
2023-04-01 12:39:27 -06:00
|
|
|
<XUserList ref="users" class="_gap" :pagination="usersPagination"/>
|
2023-04-01 12:28:34 -06:00
|
|
|
</swiper-slide>
|
|
|
|
</swiper>
|
2022-06-20 02:38:49 -06:00
|
|
|
</MkSpacer>
|
|
|
|
</MkStickyContainer>
|
2020-01-29 12:37:25 -07:00
|
|
|
</template>
|
|
|
|
|
2022-01-12 10:21:43 -07:00
|
|
|
<script lang="ts" setup>
|
2023-04-01 12:28:34 -06:00
|
|
|
import { computed, watch, onMounted } from 'vue';
|
|
|
|
import { Virtual } from 'swiper';
|
|
|
|
import { Swiper, SwiperSlide } from 'swiper/vue';
|
2022-08-30 09:24:33 -06:00
|
|
|
import XNotes from '@/components/MkNotes.vue';
|
2023-04-01 12:39:27 -06:00
|
|
|
import XUserList from '@/components/MkUserList.vue';
|
2022-01-12 10:21:43 -07:00
|
|
|
import { i18n } from '@/i18n';
|
2022-06-20 02:38:49 -06:00
|
|
|
import { definePageMetadata } from '@/scripts/page-metadata';
|
2023-04-01 12:28:34 -06:00
|
|
|
import { defaultStore } from '@/store';
|
|
|
|
import 'swiper/scss';
|
|
|
|
import 'swiper/scss/virtual';
|
2020-01-29 12:37:25 -07:00
|
|
|
|
2022-01-12 10:21:43 -07:00
|
|
|
const props = defineProps<{
|
|
|
|
query: string;
|
|
|
|
channel?: string;
|
|
|
|
}>();
|
2020-01-29 12:37:25 -07:00
|
|
|
|
2023-04-01 12:28:34 -06:00
|
|
|
const notesPagination = {
|
2022-01-12 10:26:10 -07:00
|
|
|
endpoint: 'notes/search' as const,
|
2022-01-12 10:21:43 -07:00
|
|
|
limit: 10,
|
|
|
|
params: computed(() => ({
|
|
|
|
query: props.query,
|
|
|
|
channelId: props.channel,
|
2022-06-20 02:38:49 -06:00
|
|
|
})),
|
2022-01-12 10:21:43 -07:00
|
|
|
};
|
|
|
|
|
2023-04-01 12:28:34 -06:00
|
|
|
const usersPagination = {
|
|
|
|
endpoint: 'users/search' as const,
|
|
|
|
limit: 10,
|
|
|
|
params: computed(() => ({
|
|
|
|
query: props.query,
|
|
|
|
origin: 'combined',
|
|
|
|
})),
|
|
|
|
};
|
|
|
|
|
2023-04-01 12:39:27 -06:00
|
|
|
const tabs = ['notes', 'users'];
|
2023-04-01 12:28:34 -06:00
|
|
|
let tab = $ref(tabs[0]);
|
|
|
|
watch($$(tab), () => (syncSlide(tabs.indexOf(tab))));
|
|
|
|
|
2022-06-20 02:38:49 -06:00
|
|
|
const headerActions = $computed(() => []);
|
|
|
|
|
2023-04-01 12:28:34 -06:00
|
|
|
const headerTabs = $computed(() => [ {
|
2023-04-01 12:39:27 -06:00
|
|
|
key: 'notes',
|
2023-04-01 12:28:34 -06:00
|
|
|
icon: 'ph-magnifying-glass ph-bold ph-lg',
|
2023-04-01 12:39:27 -06:00
|
|
|
title: i18n.ts.notes,
|
2023-04-01 12:28:34 -06:00
|
|
|
}, {
|
|
|
|
key: 'users',
|
|
|
|
icon: 'ph-users ph-bold ph-lg',
|
|
|
|
title: i18n.ts.users,
|
|
|
|
}]);
|
|
|
|
|
|
|
|
let swiperRef = null;
|
|
|
|
|
|
|
|
function setSwiperRef(swiper) {
|
|
|
|
swiperRef = swiper;
|
|
|
|
syncSlide(tabs.indexOf(tab));
|
|
|
|
}
|
|
|
|
|
|
|
|
function onSlideChange() {
|
|
|
|
tab = tabs[swiperRef.activeIndex];
|
|
|
|
}
|
|
|
|
|
|
|
|
function syncSlide(index) {
|
|
|
|
swiperRef.slideTo(index);
|
|
|
|
}
|
|
|
|
|
|
|
|
onMounted(() => {
|
|
|
|
syncSlide(tabs.indexOf(swiperRef.activeIndex));
|
|
|
|
});
|
2022-06-20 02:38:49 -06:00
|
|
|
|
|
|
|
definePageMetadata(computed(() => ({
|
|
|
|
title: i18n.t('searchWith', { q: props.query }),
|
2023-03-11 14:01:04 -07:00
|
|
|
icon: 'ph-magnifying-glass ph-bold ph-lg',
|
2022-06-20 02:38:49 -06:00
|
|
|
})));
|
2020-01-29 12:37:25 -07:00
|
|
|
</script>
|