major change fixing bugs when running SSR in the project
This commit is contained in:
@@ -59,7 +59,7 @@ export default {
|
||||
},
|
||||
props: {
|
||||
blocks: {
|
||||
type: Array,
|
||||
type: Object,
|
||||
required: true,
|
||||
},
|
||||
},
|
||||
|
||||
@@ -53,7 +53,7 @@ export default {
|
||||
},
|
||||
props: {
|
||||
block: {
|
||||
type: Array,
|
||||
type: Object,
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
|
||||
+1
-1
@@ -25,7 +25,7 @@ export default {
|
||||
required: true,
|
||||
},
|
||||
items: {
|
||||
type: Array,
|
||||
type: Object,
|
||||
required: true,
|
||||
},
|
||||
},
|
||||
|
||||
@@ -25,7 +25,7 @@ export default {
|
||||
required: true,
|
||||
},
|
||||
items: {
|
||||
type: Array,
|
||||
type: Object,
|
||||
required: true,
|
||||
},
|
||||
},
|
||||
|
||||
@@ -40,89 +40,88 @@
|
||||
import {Link} from "@inertiajs/vue3";
|
||||
import BasicIcon from "@/componentss/ui/icons/BasicIcon.vue";
|
||||
import {debounce} from "lodash";
|
||||
|
||||
export default {
|
||||
name: "CategoryFilter",
|
||||
components: {
|
||||
BasicIcon,
|
||||
Link
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
category_slug: this.category_filter.value || [],
|
||||
searchTerm: '',
|
||||
filteredItems: this.categories.data, // Изначально все элементы
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
filter: debounce(function () {
|
||||
let url = new URL(window.location.href);
|
||||
// Создаем массив для хранения всех ключей, которые нужно удалить
|
||||
const keysToDelete = [];
|
||||
name: "CategoryFilter",
|
||||
components: {
|
||||
BasicIcon,
|
||||
Link
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
category_slug: this.category_filter.value || [],
|
||||
searchTerm: '',
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
filter: debounce(function () {
|
||||
let url = new URL(window.location.href);
|
||||
const keysToDelete = [];
|
||||
|
||||
// Перебираем все параметры и добавляем ключи, начинающиеся с 'category', в массив
|
||||
for (const [key] of url.searchParams) {
|
||||
if (key.startsWith('category')) {
|
||||
keysToDelete.push(key);
|
||||
}
|
||||
}
|
||||
// Удаляем все ключи из массива
|
||||
keysToDelete.forEach(key => url.searchParams.delete(key));
|
||||
url.searchParams.delete('page');
|
||||
let newUrl = url.toString();
|
||||
this.$inertia.visit(newUrl, {
|
||||
method: 'get',
|
||||
preserveState: true,
|
||||
data: {
|
||||
category: this.category_slug,
|
||||
},
|
||||
});
|
||||
}, 500),
|
||||
clearFilter() {
|
||||
let url = new URL(window.location.href);
|
||||
// Создаем массив для хранения всех ключей, которые нужно удалить
|
||||
const keysToDelete = [];
|
||||
for (const [key] of url.searchParams) {
|
||||
if (key.startsWith('category')) {
|
||||
keysToDelete.push(key);
|
||||
}
|
||||
}
|
||||
|
||||
// Перебираем все параметры и добавляем ключи, начинающиеся с 'category', в массив
|
||||
for (const [key] of url.searchParams) {
|
||||
if (key.startsWith('category')) {
|
||||
keysToDelete.push(key);
|
||||
}
|
||||
}
|
||||
// Удаляем все ключи из массива
|
||||
keysToDelete.forEach(key => url.searchParams.delete(key));
|
||||
this.category_slug = [];
|
||||
this.searchTerm = ''; // Сбросить поле поиска
|
||||
let newUrl = url.toString();
|
||||
this.$inertia.visit(newUrl, {
|
||||
method: 'get',
|
||||
preserveState: true,
|
||||
});
|
||||
},
|
||||
},
|
||||
computed: {
|
||||
filteredItems() {
|
||||
if (!this.searchTerm) {
|
||||
return this.categories.data; // Возвращаем все элементы, если ничего не введено
|
||||
}
|
||||
const term = this.searchTerm.toLowerCase(); // Приводим к нижнему регистру для нечувствительности к регистру
|
||||
return this.categories.data.filter(item =>
|
||||
item.title.toLowerCase().includes(term) // Фильтруем по заголовку
|
||||
);
|
||||
}
|
||||
},
|
||||
props: {
|
||||
categories: {
|
||||
type: Object,
|
||||
},
|
||||
category_filter: {
|
||||
type: Object,
|
||||
},
|
||||
},
|
||||
keysToDelete.forEach(key => url.searchParams.delete(key));
|
||||
url.searchParams.delete('page');
|
||||
let newUrl = url.toString();
|
||||
|
||||
this.$inertia.visit(newUrl, {
|
||||
method: 'get',
|
||||
preserveState: true,
|
||||
data: {
|
||||
category: this.category_slug,
|
||||
},
|
||||
});
|
||||
}, 500),
|
||||
|
||||
clearFilter() {
|
||||
let url = new URL(window.location.href);
|
||||
const keysToDelete = [];
|
||||
|
||||
for (const [key] of url.searchParams) {
|
||||
if (key.startsWith('category')) {
|
||||
keysToDelete.push(key);
|
||||
}
|
||||
}
|
||||
|
||||
keysToDelete.forEach(key => url.searchParams.delete(key));
|
||||
this.category_slug = [];
|
||||
this.searchTerm = '';
|
||||
let newUrl = url.toString();
|
||||
|
||||
this.$inertia.visit(newUrl, {
|
||||
method: 'get',
|
||||
preserveState: true,
|
||||
});
|
||||
},
|
||||
},
|
||||
computed: {
|
||||
filteredItems() {
|
||||
if (!this.searchTerm) {
|
||||
return this.categories.data;
|
||||
}
|
||||
const term = this.searchTerm.toLowerCase();
|
||||
return this.categories.data.filter(item =>
|
||||
item.title.toLowerCase().includes(term)
|
||||
);
|
||||
}
|
||||
},
|
||||
props: {
|
||||
categories: {
|
||||
type: Object,
|
||||
required: true // Добавляем required для ясности
|
||||
},
|
||||
category_filter: {
|
||||
type: Object,
|
||||
default: () => ({ value: [] }) // Добавляем значение по умолчанию
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
|
||||
<style scoped>
|
||||
|
||||
</style>
|
||||
@@ -51,7 +51,6 @@ export default {
|
||||
return {
|
||||
tag_slug: this.tag_filter.value || [],
|
||||
searchTerm: '',
|
||||
filteredItems: this.tags, // Изначально все элементы
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
|
||||
@@ -26,7 +26,8 @@ import {defineAsyncComponent} from "vue";
|
||||
|
||||
|
||||
export default {
|
||||
name: 'SearchModal',
|
||||
inheritAttrs: false,
|
||||
name: 'SearchModal',
|
||||
props: {
|
||||
open_id: {
|
||||
type: String,
|
||||
|
||||
@@ -95,7 +95,7 @@ export default {
|
||||
},
|
||||
props: {
|
||||
headerNavs: {
|
||||
type: Array,
|
||||
type: Object,
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
@@ -1,23 +1,23 @@
|
||||
<template>
|
||||
<div class="mt-10 flex items-center justify-center">
|
||||
<nav class="flex items-center gap-x-1" aria-label="Pagination">
|
||||
<Link :href="links.links[0].url" as="button" class="min-h-9.5 min-w-9.5 py-2 px-2.5 inline-flex justify-center items-center gap-x-2 text-sm rounded-lg border border-transparent text-gray-800 hover:bg-gray-100 focus:outline-hidden focus:bg-gray-100 disabled:opacity-50 disabled:pointer-events-none" aria-label="Previous">
|
||||
<a :href="links.links[0].url" class="min-h-9.5 min-w-9.5 py-2 px-2.5 inline-flex justify-center items-center gap-x-2 text-sm rounded-lg border border-transparent text-gray-800 hover:bg-gray-100 focus:outline-hidden focus:bg-gray-100 disabled:opacity-50 disabled:pointer-events-none" aria-label="Previous">
|
||||
<svg class="shrink-0 size-3.5" xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
||||
<path d="m15 18-6-6 6-6"></path>
|
||||
</svg>
|
||||
<span class="sr-only">Previous</span>
|
||||
</Link>
|
||||
</a>
|
||||
<div class="flex items-center gap-x-1">
|
||||
<Link v-for="link in getPageLinks(links)" as="button" :href="link.url"
|
||||
<a v-for="link in getPageLinks(links)" :href="link.url"
|
||||
:class="link.active ? 'border-gray-200 text-gray-800' : 'border-transparent hover:bg-gray-100'"
|
||||
class="min-h-9.5 min-w-9.5 flex justify-center items-center border py-2 px-3 text-sm rounded-lg focus:outline-hidden focus:bg-gray-100 disabled:opacity-50 disabled:pointer-events-none">{{ link.label }}</Link>
|
||||
class="min-h-9.5 min-w-9.5 flex justify-center items-center border py-2 px-3 text-sm rounded-lg focus:outline-hidden focus:bg-gray-100 disabled:opacity-50 disabled:pointer-events-none">{{ link.label }}</a>
|
||||
</div>
|
||||
<Link :href="links.links.slice(-1).pop().url" as="button" class="min-h-9.5 min-w-9.5 py-2 px-2.5 inline-flex justify-center items-center gap-x-2 text-sm rounded-lg border border-transparent text-gray-800 hover:bg-gray-100 focus:outline-hidden focus:bg-gray-100 disabled:opacity-50 disabled:pointer-events-none" aria-label="Next">
|
||||
<a :href="links.links.slice(-1).pop().url" class="min-h-9.5 min-w-9.5 py-2 px-2.5 inline-flex justify-center items-center gap-x-2 text-sm rounded-lg border border-transparent text-gray-800 hover:bg-gray-100 focus:outline-hidden focus:bg-gray-100 disabled:opacity-50 disabled:pointer-events-none" aria-label="Next">
|
||||
<span class="sr-only">Next</span>
|
||||
<svg class="shrink-0 size-3.5" xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
||||
<path d="m9 18 6-6-6-6"></path>
|
||||
</svg>
|
||||
</Link>
|
||||
</a>
|
||||
</nav>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
Reference in New Issue
Block a user