From c953d87eecda6a92dfdabc78ff4152ba2c0d8537 Mon Sep 17 00:00:00 2001 From: Baghi Date: Wed, 16 Apr 2025 17:52:36 +0330 Subject: [PATCH 1/7] clear button serach --- assets/haditha/font-icons/close-circle.svg | 5 ++ components/haditha/AutoComplation.vue | 69 +++++++++++++++++----- pages/haditha/search/index.vue | 4 +- 3 files changed, 61 insertions(+), 17 deletions(-) create mode 100644 assets/haditha/font-icons/close-circle.svg diff --git a/assets/haditha/font-icons/close-circle.svg b/assets/haditha/font-icons/close-circle.svg new file mode 100644 index 0000000..a92e4d6 --- /dev/null +++ b/assets/haditha/font-icons/close-circle.svg @@ -0,0 +1,5 @@ + + + + + diff --git a/components/haditha/AutoComplation.vue b/components/haditha/AutoComplation.vue index c184877..f43c75f 100644 --- a/components/haditha/AutoComplation.vue +++ b/components/haditha/AutoComplation.vue @@ -57,6 +57,7 @@ const search_type = ref("normal"); const type_key = ref("hadith"); const typeModelValue = ref("normal"); const typeModelValueFa = ref(""); +const showclearButton = ref(false); // If you want to share state across multiple components, // you can use the same key in useState. Nuxt will ensure @@ -168,17 +169,27 @@ const clearSimilar = () => { // const onUpdateModel = (newVal: boolean | InputMenuItem | any) => { // console.info("onUpdateModel", newVal); // }; +const searchButtonIcon = computed(() => { + return showclearButton.value ? "i-lucide-x" : "i-haditha-search"; +}); + +const handleSearchClearButton = ()=>{ + showclearButton.value = true; + sendQuery(); +} const onKeyDown = () => { - clearTimeout(typingTimer.value); -}; -const onKeyUp = () => { - clearTimeout(typingTimer.value); - typingTimer.value = setTimeout(() => { - if (props.autoRedirection) sendQuery(); - }, doneTypingInterval.value); + showclearButton.value = false; + // clearTimeout(typingTimer.value); }; +// const onKeyUp = () => { +// clearTimeout(typingTimer.value); +// typingTimer.value = setTimeout(() => { +// if (props.autoRedirection) sendQuery(); +// }, doneTypingInterval.value); +// }; + const setType = (type: string) => { search_type.value = type; sendQuery(); @@ -225,11 +236,6 @@ const sendQuery = async (payload = {}) => { .postRequest(url, payload) .then((res) => { // pass res and search query to the parent. - emit("response-ready", { - res: res, - searchQuery: searchTerm.value, - disableAutoRedirect: true, - }); loading.value = false; // check if search term is not empty @@ -238,6 +244,32 @@ const sendQuery = async (payload = {}) => { // close the history dropdown menu open.value = false; + + + // show clear button + if (showclearButton.value) { + searchTerm.value = ""; + + emit("response-ready", { + res: { + hits:{ + total:0, + hits:[] + } + }, + searchQuery: searchTerm.value, + disableAutoRedirect: true, + }); + } else { + emit("response-ready", { + res: res, + searchQuery: searchTerm.value, + disableAutoRedirect: true, + }); + } + + showclearButton.value = !showclearButton.value; + // store search phrase useStorage("searchPhrase", searchTerm.value); }) @@ -405,7 +437,6 @@ onMounted(() => { @blur="open = false" @change="sendQuery" @keydown="onKeyDown" - @keyup="onKeyUp" @keydown.enter="sendQuery" > @@ -414,8 +445,9 @@ onMounted(() => { @@ -765,6 +797,13 @@ onMounted(() => { ); */ } } + .close-mode { + background: #f0f1f4; + color: #000; /* رنگ خاکستری */ + &:hover { + background: #e0e0e0; /* رنگ خاکستری */ + } + } .haditha-search-input { z-index: 0; diff --git a/pages/haditha/search/index.vue b/pages/haditha/search/index.vue index e4b7efa..a25b7a4 100644 --- a/pages/haditha/search/index.vue +++ b/pages/haditha/search/index.vue @@ -90,7 +90,7 @@ const SearchList = defineAsyncComponent(() =>
/>
کاوش با - هوش مصنوعی + هوش مصنوعی در احادیث اسلامی
From 0a29ad5b61c826d07d807fe69aec46084fd4a260 Mon Sep 17 00:00:00 2001 From: Baghi Date: Wed, 16 Apr 2025 18:48:12 +0330 Subject: [PATCH 2/7] pagination --- components/haditha/search-page/SearchList.vue | 11 +++- pages/haditha/search/[id]/[slug]/index.vue | 50 ++++++++++++++++--- 2 files changed, 51 insertions(+), 10 deletions(-) diff --git a/components/haditha/search-page/SearchList.vue b/components/haditha/search-page/SearchList.vue index d909a49..10241d1 100644 --- a/components/haditha/search-page/SearchList.vue +++ b/components/haditha/search-page/SearchList.vue @@ -23,11 +23,18 @@ const router = useRouter(); function openModal(selectedItem) { // modal.open(SearchShow, { title: "Welcome" }); // isModalOpen.value = true; + + const slug = selectedItem._source.content.split(' ').filter((v,i)=>i<4).join('-'); + router.push({ name: "hadithaSearchShow", params: { - id: selectedItem._id, - slug: "no-slug", + id: selectedItem._source.id, + slug: slug, + }, + query: { + firstPage: 1, + page_count:props.total }, }); } diff --git a/pages/haditha/search/[id]/[slug]/index.vue b/pages/haditha/search/[id]/[slug]/index.vue index 952f81d..f0ec899 100644 --- a/pages/haditha/search/[id]/[slug]/index.vue +++ b/pages/haditha/search/[id]/[slug]/index.vue @@ -228,10 +228,14 @@ const handlePagination = (prevNextIndicator: string) => { .getRequest(url) .then((res) => { state.selectedItem = res.hits.hits?.[0]; + page_num.value = res.hits.hits[0]._source.address.page_num ?? 1; }) .finally(() => (loading.value = false)); }; - +const page_num = ref(1); +const handlePageChange = () => { + handlePagination(1, page_num.value); +}; // const localCopyTextToClipboard = (text: string) => { // copyTextToClipboard(text); // }; @@ -413,24 +417,24 @@ const handlePagination = (prevNextIndicator: string) => {