diff --git a/components/haditha/AutoComplation.vue b/components/haditha/AutoComplation.vue index f43c75f..2eebabb 100644 --- a/components/haditha/AutoComplation.vue +++ b/components/haditha/AutoComplation.vue @@ -3,7 +3,6 @@ import type { InputMenuItem } from "@nuxt/ui"; import hadithaApi from "../../apis/hadithaApi"; import { useStorage } from "@vueuse/core"; import * as z from "zod"; -import routeGlobal from "~/middleware/route.global"; // import type { FormSubmitEvent } from "@nuxt/ui"; export type Synonym = { @@ -970,6 +969,6 @@ onMounted(() => { } } -@media scrren and (min-width: 720px) and (max-width: 991.99px) { -} +/* @media scrren and (min-width: 720px) and (max-width: 991.99px) { +} */ diff --git a/components/haditha/search-page/SearchList.vue b/components/haditha/search-page/SearchList.vue index 10241d1..0b047e8 100644 --- a/components/haditha/search-page/SearchList.vue +++ b/components/haditha/search-page/SearchList.vue @@ -24,7 +24,10 @@ function openModal(selectedItem) { // modal.open(SearchShow, { title: "Welcome" }); // isModalOpen.value = true; - const slug = selectedItem._source.content.split(' ').filter((v,i)=>i<4).join('-'); + const slug = selectedItem._source.content + .split(" ") + .filter((v, i) => i < 4) + .join("-"); router.push({ name: "hadithaSearchShow", @@ -34,7 +37,7 @@ function openModal(selectedItem) { }, query: { firstPage: 1, - page_count:props.total + page_count: props.total, }, }); } @@ -55,51 +58,43 @@ function openModal(selectedItem) { - + diff --git a/pages/haditha/library/index.vue b/pages/haditha/library/index.vue index 7e8e15b..9fbd86d 100644 --- a/pages/haditha/library/index.vue +++ b/pages/haditha/library/index.vue @@ -24,14 +24,13 @@ useHead({ // #region refs const el = useTemplateRef("el"); const httpService = useNuxtApp()["$http"]; -const route = useRoute(); -const page = ref(Number(route.query.page) || 1); +const total = ref(0); +const currentPage = useState("currentPage", () => 0); // #endregion refs // #region reactive const state = reactive({ pagination: { - offset: 0, limit: 10, page: 1, pages: 1, @@ -43,15 +42,20 @@ const state = reactive({ const getLibraryList = async (dataType = "bookmark") => { let url = repoUrl() + hadithaApi.library.list; url = url.replace("@field_collapsed", "normal"); - url = url.replace("@offset", state.pagination.offset); + url = url.replace("@offset", currentPage.value); url = url.replace("@limit", state.pagination.limit); url = url.replace("@q", "none"); - return await httpService.postRequest(url); + return await httpService.postRequest(url).then((res) => { + total.value = res.hits.total.value ?? 0; + currentPage.value += state.pagination.limit; + + return res; + }); }; // Server-side initial load -const { data: initialItems } = await useAsyncData( +const { data: loadedItems } = await useAsyncData( "libraryList", () => getLibraryList(), { @@ -59,16 +63,12 @@ const { data: initialItems } = await useAsyncData( getCachedData: (key) => { return useNuxtApp().payload.data[key] || useNuxtApp().static.data[key]; }, - watch: [page], } ); // Client-side state -const loadedItems = ref([]); const loading = ref(false); const hasMore = ref(true); -const loader = ref(null); -const totalPages = ref(10); // Set based on your API response // Client-side infinite scroll useInfiniteScroll( @@ -84,7 +84,6 @@ useInfiniteScroll( if (hits.length) { loadedItems.value.push(...hits); - state.pagination.offset += state.pagination.limit; } else { hasMore.value = false; } @@ -128,14 +127,6 @@ const CardList = defineAsyncComponent( no-data-icon="/img/haditha/no-data.png" :list="loadedItems" > - - - diff --git a/pages/haditha/search/index.vue b/pages/haditha/search/index.vue index a25b7a4..3dd52da 100644 --- a/pages/haditha/search/index.vue +++ b/pages/haditha/search/index.vue @@ -1,11 +1,23 @@ -