Added global search.
This commit is contained in:
@@ -55,7 +55,7 @@
|
||||
<select
|
||||
v-model="order"
|
||||
class="input"
|
||||
@change="search"
|
||||
@change="search({ autoScope: false })"
|
||||
>
|
||||
<option value="name.asc">Name</option>
|
||||
<option value="likes.desc">Likes</option>
|
||||
@@ -139,17 +139,19 @@ const filters = ref({
|
||||
avatarRequired: !!urlParsed.search.avatar,
|
||||
});
|
||||
|
||||
async function search(resetPage = true) {
|
||||
if (resetPage) {
|
||||
async function search(options = {}) {
|
||||
if (options.resetPage !== false) {
|
||||
currentPage.value = 1;
|
||||
}
|
||||
|
||||
if (q.value) {
|
||||
order.value = 'relevance.desc';
|
||||
}
|
||||
if (options.autoScope !== false) {
|
||||
if (q.value) {
|
||||
order.value = 'relevance.desc';
|
||||
}
|
||||
|
||||
if (!q.value && order.value.includes('relevance')) {
|
||||
order.value = 'likes.desc';
|
||||
if (!q.value && order.value.includes('relevance')) {
|
||||
order.value = 'likes.desc';
|
||||
}
|
||||
}
|
||||
|
||||
const query = {
|
||||
@@ -167,6 +169,8 @@ async function search(resetPage = true) {
|
||||
avatar: filters.value.avatarRequired || undefined,
|
||||
};
|
||||
|
||||
navigate(`/actors/${currentPage.value}`, query, { redirect: false });
|
||||
|
||||
const res = await get('/actors', {
|
||||
...query,
|
||||
page: currentPage.value, // client uses param rather than query pagination
|
||||
@@ -178,12 +182,12 @@ async function search(resetPage = true) {
|
||||
countries.value = res.countries;
|
||||
|
||||
events.emit('scrollUp');
|
||||
navigate(`/actors/${currentPage.value}`, query, { redirect: false });
|
||||
}
|
||||
|
||||
function paginate({ page }) {
|
||||
currentPage.value = page;
|
||||
search(false);
|
||||
|
||||
search({ resetPage: false });
|
||||
}
|
||||
|
||||
function updateFilter(prop, value, reload = true) {
|
||||
|
||||
@@ -3,14 +3,20 @@
|
||||
<div class="content">
|
||||
<div class="banner">
|
||||
<div class="poster-container">
|
||||
<img
|
||||
v-if="scene.poster"
|
||||
:src="scene.poster.isS3 ? `https://cdndev.traxxx.me/${scene.poster.thumbnail}` : `/media/${scene.poster.thumbnail}`"
|
||||
:style="{ 'background-image': scene.poster.isS3 ? `url(https://cdndev.traxxx.me/${scene.poster.lazy})` : `url(/media/${scene.poster.lazy})` }"
|
||||
:width="scene.poster.width"
|
||||
:height="scene.poster.height"
|
||||
class="poster"
|
||||
<a
|
||||
:href="scene.poster.isS3 ? `https://cdndev.traxxx.me/${scene.poster.path}` : `/media/${scene.poster.path}`"
|
||||
target="_blank"
|
||||
class="poster-link"
|
||||
>
|
||||
<img
|
||||
v-if="scene.poster"
|
||||
:src="scene.poster.isS3 ? `https://cdndev.traxxx.me/${scene.poster.thumbnail}` : `/media/${scene.poster.thumbnail}`"
|
||||
:style="{ 'background-image': scene.poster.isS3 ? `url(https://cdndev.traxxx.me/${scene.poster.lazy})` : `url(/media/${scene.poster.lazy})` }"
|
||||
:width="scene.poster.width"
|
||||
:height="scene.poster.height"
|
||||
class="poster"
|
||||
>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<div
|
||||
@@ -22,13 +28,19 @@
|
||||
:key="`photo-${photo.id}`"
|
||||
class="photo-container"
|
||||
>
|
||||
<img
|
||||
:src="photo.isS3 ? `https://cdndev.traxxx.me/${photo.thumbnail}` : `/media/${photo.thumbnail}`"
|
||||
:style="{ 'background-image': photo.isS3 ? `url(https://cdndev.traxxx.me/${photo.lazy})` : `url(/media/${photo.lazy})` }"
|
||||
:width="photo.width"
|
||||
:height="photo.height"
|
||||
class="photo"
|
||||
<a
|
||||
:href="photo.isS3 ? `https://cdndev.traxxx.me/${photo.path}` : `/media/${photo.path}`"
|
||||
target="_blank"
|
||||
class="photo-link"
|
||||
>
|
||||
<img
|
||||
:src="photo.isS3 ? `https://cdndev.traxxx.me/${photo.thumbnail}` : `/media/${photo.thumbnail}`"
|
||||
:style="{ 'background-image': photo.isS3 ? `url(https://cdndev.traxxx.me/${photo.lazy})` : `url(/media/${photo.lazy})` }"
|
||||
:width="photo.width"
|
||||
:height="photo.height"
|
||||
class="photo"
|
||||
>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
<template>
|
||||
<div>
|
||||
<Scenes
|
||||
:scenes="scenes"
|
||||
:show-filters="false"
|
||||
:show-meta="false"
|
||||
:show-scope-tabs="true"
|
||||
@@ -10,10 +9,5 @@
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { inject } from 'vue';
|
||||
|
||||
import Scenes from '#/components/scenes/scenes.vue';
|
||||
|
||||
const { pageProps } = inject('pageContext');
|
||||
const { scenes } = pageProps;
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user