2020-01-29 20:37:25 +01:00
|
|
|
<template>
|
2023-04-08 02:01:42 +02:00
|
|
|
<MkStickyContainer>
|
|
|
|
<template #header
|
|
|
|
><MkPageHeader
|
|
|
|
v-model:tab="tab"
|
|
|
|
:actions="headerActions"
|
|
|
|
:tabs="headerTabs"
|
|
|
|
:display-back-button="true"
|
|
|
|
/></template>
|
|
|
|
<MkSpacer :content-max="800">
|
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"
|
|
|
|
:centeredSlides="true"
|
2023-04-01 20:28:34 +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-01 20:28:34 +02:00
|
|
|
@swiper="setSwiperRef"
|
|
|
|
@slide-change="onSlideChange"
|
|
|
|
>
|
|
|
|
<swiper-slide>
|
2023-04-08 02:01:42 +02:00
|
|
|
<XNotes ref="notes" :pagination="notesPagination" />
|
2023-04-01 20:28:34 +02:00
|
|
|
</swiper-slide>
|
|
|
|
<swiper-slide>
|
2023-04-08 02:01:42 +02:00
|
|
|
<XUserList
|
|
|
|
ref="users"
|
|
|
|
class="_gap"
|
|
|
|
:pagination="usersPagination"
|
|
|
|
/>
|
2023-04-01 20:28:34 +02:00
|
|
|
</swiper-slide>
|
|
|
|
</swiper>
|
2023-04-08 02:01:42 +02:00
|
|
|
</MkSpacer>
|
|
|
|
</MkStickyContainer>
|
2020-01-29 20:37:25 +01:00
|
|
|
</template>
|
|
|
|
|
2022-01-12 18:21:43 +01:00
|
|
|
<script lang="ts" setup>
|
2023-04-08 02:01:42 +02:00
|
|
|
import { computed, watch, onMounted } from "vue";
|
|
|
|
import { Virtual } from "swiper";
|
|
|
|
import { Swiper, SwiperSlide } from "swiper/vue";
|
|
|
|
import XNotes from "@/components/MkNotes.vue";
|
|
|
|
import XUserList from "@/components/MkUserList.vue";
|
|
|
|
import { i18n } from "@/i18n";
|
|
|
|
import { definePageMetadata } from "@/scripts/page-metadata";
|
|
|
|
import { defaultStore } from "@/store";
|
2023-06-21 23:13:46 +02:00
|
|
|
import { deviceKind } from "@/scripts/device-kind";
|
2023-04-08 02:01:42 +02:00
|
|
|
import "swiper/scss";
|
|
|
|
import "swiper/scss/virtual";
|
2020-01-29 20:37:25 +01:00
|
|
|
|
2022-01-12 18:21:43 +01:00
|
|
|
const props = defineProps<{
|
|
|
|
query: string;
|
|
|
|
channel?: string;
|
|
|
|
}>();
|
2020-01-29 20:37:25 +01:00
|
|
|
|
2023-04-01 20:28:34 +02:00
|
|
|
const notesPagination = {
|
2023-04-08 02:01:42 +02:00
|
|
|
endpoint: "notes/search" as const,
|
2022-01-12 18:21:43 +01:00
|
|
|
limit: 10,
|
|
|
|
params: computed(() => ({
|
|
|
|
query: props.query,
|
|
|
|
channelId: props.channel,
|
2022-06-20 10:38:49 +02:00
|
|
|
})),
|
2022-01-12 18:21:43 +01:00
|
|
|
};
|
|
|
|
|
2023-04-01 20:28:34 +02:00
|
|
|
const usersPagination = {
|
2023-04-08 02:01:42 +02:00
|
|
|
endpoint: "users/search" as const,
|
2023-04-01 20:28:34 +02:00
|
|
|
limit: 10,
|
|
|
|
params: computed(() => ({
|
|
|
|
query: props.query,
|
2023-04-08 02:01:42 +02:00
|
|
|
origin: "combined",
|
2023-04-01 20:28:34 +02:00
|
|
|
})),
|
|
|
|
};
|
|
|
|
|
2023-04-08 02:01:42 +02:00
|
|
|
const tabs = ["notes", "users"];
|
2023-04-01 20:28:34 +02:00
|
|
|
let tab = $ref(tabs[0]);
|
2023-04-08 02:01:42 +02:00
|
|
|
watch($$(tab), () => syncSlide(tabs.indexOf(tab)));
|
2023-04-01 20:28:34 +02:00
|
|
|
|
2022-06-20 10:38:49 +02:00
|
|
|
const headerActions = $computed(() => []);
|
|
|
|
|
2023-04-08 02:01:42 +02:00
|
|
|
const headerTabs = $computed(() => [
|
|
|
|
{
|
|
|
|
key: "notes",
|
|
|
|
icon: "ph-magnifying-glass ph-bold ph-lg",
|
|
|
|
title: i18n.ts.notes,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
key: "users",
|
|
|
|
icon: "ph-users ph-bold ph-lg",
|
|
|
|
title: i18n.ts.users,
|
|
|
|
},
|
|
|
|
]);
|
2023-04-01 20:28:34 +02:00
|
|
|
|
|
|
|
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 10:38:49 +02:00
|
|
|
|
2023-04-08 02:01:42 +02:00
|
|
|
definePageMetadata(
|
|
|
|
computed(() => ({
|
|
|
|
title: i18n.t("searchWith", { q: props.query }),
|
|
|
|
icon: "ph-magnifying-glass ph-bold ph-lg",
|
2023-07-06 03:28:27 +02:00
|
|
|
})),
|
2023-04-08 02:01:42 +02:00
|
|
|
);
|
2020-01-29 20:37:25 +01:00
|
|
|
</script>
|