2020-01-29 12:37:25 -07:00
|
|
|
<template>
|
2022-06-20 02:38:49 -06:00
|
|
|
<MkStickyContainer>
|
2022-06-22 01:29:21 -06:00
|
|
|
<template #header><MkPageHeader v-model:tab="tab" :actions="headerActions" :tabs="headerTabs"/></template>
|
2022-07-01 08:33:47 -06:00
|
|
|
<div class="lznhrdub">
|
2022-09-09 13:09:12 -06:00
|
|
|
<swiper
|
|
|
|
:modules="[Virtual]"
|
|
|
|
:space-between="20"
|
|
|
|
:virtual="true"
|
|
|
|
@swiper="setSwiperRef"
|
|
|
|
@slide-change="onSlideChange"
|
|
|
|
>
|
|
|
|
<swiper-slide>
|
|
|
|
<XFeatured/>
|
|
|
|
</swiper-slide>
|
|
|
|
<swiper-slide>
|
|
|
|
<XUsers/>
|
|
|
|
</swiper-slide>
|
|
|
|
<swiper-slide>
|
|
|
|
<MkSpacer :content-max="1200">
|
|
|
|
<div>
|
|
|
|
<MkInput v-model="searchQuery" :debounce="true" type="search" class="_formBlock">
|
|
|
|
<template #prefix><i class="fas fa-search"></i></template>
|
|
|
|
<template #label>{{ i18n.ts.searchUser }}</template>
|
|
|
|
</MkInput>
|
|
|
|
<MkRadios v-model="searchOrigin" class="_formBlock">
|
|
|
|
<option value="combined">{{ i18n.ts.all }}</option>
|
|
|
|
<option value="local">{{ i18n.ts.local }}</option>
|
|
|
|
<option value="remote">{{ i18n.ts.remote }}</option>
|
|
|
|
</MkRadios>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<XUserList v-if="searchQuery" ref="searchEl" class="_gap" :pagination="searchPagination"/>
|
|
|
|
</MkSpacer>
|
|
|
|
</swiper-slide>
|
|
|
|
</swiper>
|
2022-07-01 08:33:47 -06:00
|
|
|
</div>
|
2022-06-20 02:38:49 -06:00
|
|
|
</MkStickyContainer>
|
2020-01-29 12:37:25 -07:00
|
|
|
</template>
|
|
|
|
|
2022-06-20 02:38:49 -06:00
|
|
|
<script lang="ts" setup>
|
2022-07-01 08:33:47 -06:00
|
|
|
import { computed, watch } from 'vue';
|
2022-09-09 13:09:12 -06:00
|
|
|
import { Virtual } from 'swiper';
|
|
|
|
import { Swiper, SwiperSlide } from 'swiper/vue';
|
2022-07-01 08:33:47 -06:00
|
|
|
import XFeatured from './explore.featured.vue';
|
|
|
|
import XUsers from './explore.users.vue';
|
2022-09-06 03:21:49 -06:00
|
|
|
import MkFolder from '@/components/MkFolder.vue';
|
2021-11-11 10:02:25 -07:00
|
|
|
import MkInput from '@/components/form/input.vue';
|
|
|
|
import MkRadios from '@/components/form/radios.vue';
|
|
|
|
import number from '@/filters/number';
|
|
|
|
import * as os from '@/os';
|
2022-06-20 02:38:49 -06:00
|
|
|
import { definePageMetadata } from '@/scripts/page-metadata';
|
|
|
|
import { i18n } from '@/i18n';
|
|
|
|
import { instance } from '@/instance';
|
2022-08-30 09:24:33 -06:00
|
|
|
import XUserList from '@/components/MkUserList.vue';
|
2022-09-09 13:09:12 -06:00
|
|
|
import 'swiper/scss';
|
|
|
|
import 'swiper/scss/virtual';
|
2022-06-20 02:38:49 -06:00
|
|
|
|
|
|
|
const props = defineProps<{
|
|
|
|
tag?: string;
|
|
|
|
}>();
|
|
|
|
|
2022-09-09 14:32:52 -06:00
|
|
|
let featured = $ref('featured');
|
2022-09-09 14:56:42 -06:00
|
|
|
const tabs = ['featured', 'users', 'search'];
|
2022-09-09 13:09:12 -06:00
|
|
|
|
2022-09-09 14:56:42 -06:00
|
|
|
let tab = $computed({
|
2022-09-09 14:32:52 -06:00
|
|
|
get: () => featured,
|
2022-09-09 13:09:12 -06:00
|
|
|
set: (x) => {
|
2022-09-09 14:56:42 -06:00
|
|
|
syncSlide(tabs.indexOf(x));
|
2022-09-09 13:09:12 -06:00
|
|
|
},
|
|
|
|
});
|
|
|
|
|
2022-06-20 02:38:49 -06:00
|
|
|
let tagsEl = $ref<InstanceType<typeof MkFolder>>();
|
|
|
|
let searchQuery = $ref(null);
|
|
|
|
let searchOrigin = $ref('combined');
|
|
|
|
|
|
|
|
watch(() => props.tag, () => {
|
|
|
|
if (tagsEl) tagsEl.toggleContent(props.tag == null);
|
|
|
|
});
|
2020-01-29 12:37:25 -07:00
|
|
|
|
2022-06-20 02:38:49 -06:00
|
|
|
const searchPagination = {
|
|
|
|
endpoint: 'users/search' as const,
|
|
|
|
limit: 10,
|
|
|
|
params: computed(() => (searchQuery && searchQuery !== '') ? {
|
|
|
|
query: searchQuery,
|
|
|
|
origin: searchOrigin,
|
|
|
|
} : null),
|
|
|
|
};
|
|
|
|
|
|
|
|
const headerActions = $computed(() => []);
|
|
|
|
|
|
|
|
const headerTabs = $computed(() => [{
|
2022-07-01 08:33:47 -06:00
|
|
|
key: 'featured',
|
|
|
|
icon: 'fas fa-bolt',
|
|
|
|
title: i18n.ts.featured,
|
2022-06-20 02:38:49 -06:00
|
|
|
}, {
|
2022-07-13 03:09:41 -06:00
|
|
|
key: 'users',
|
2022-07-01 08:33:47 -06:00
|
|
|
icon: 'fas fa-users',
|
|
|
|
title: i18n.ts.users,
|
2022-06-20 02:38:49 -06:00
|
|
|
}, {
|
2022-06-22 01:29:21 -06:00
|
|
|
key: 'search',
|
2022-09-07 16:09:23 -06:00
|
|
|
icon: 'fas fa-magnifying-glass',
|
2022-06-20 02:38:49 -06:00
|
|
|
title: i18n.ts.search,
|
|
|
|
}]);
|
|
|
|
|
|
|
|
definePageMetadata(computed(() => ({
|
|
|
|
title: i18n.ts.explore,
|
|
|
|
icon: 'fas fa-hashtag',
|
|
|
|
})));
|
2022-09-09 13:09:12 -06:00
|
|
|
|
|
|
|
let swiperRef = null;
|
|
|
|
|
|
|
|
function setSwiperRef(swiper) {
|
|
|
|
swiperRef = swiper;
|
2022-09-09 14:59:15 -06:00
|
|
|
syncSlide(tabs.indexOf(tab));
|
2022-09-09 13:09:12 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
function onSlideChange() {
|
2022-09-09 14:56:42 -06:00
|
|
|
tab = tabs[swiperRef.activeIndex];
|
2022-09-09 13:09:12 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
function syncSlide(index) {
|
|
|
|
swiperRef.slideTo(index);
|
|
|
|
}
|
|
|
|
|
2020-01-29 12:37:25 -07:00
|
|
|
</script>
|