Merge branch 'baghi/hadith/refactor' of https://git2.tavasi.ir/front/hadith_ui into main

This commit is contained in:
mustafa-rezae 2025-04-16 18:52:10 +03:30
commit 05d548399b
5 changed files with 112 additions and 27 deletions

View File

@ -0,0 +1,5 @@
<svg width="32" height="33" viewBox="0 0 32 33" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M0 16.7158C0 7.87926 7.16344 0.71582 16 0.71582C24.8366 0.71582 32 7.87926 32 16.7158C32 25.5524 24.8366 32.7158 16 32.7158C7.16344 32.7158 0 25.5524 0 16.7158Z" fill="#F0F1F4"/>
<path d="M11 21.7158L21 11.7158" stroke="#1B2132" stroke-linecap="round"/>
<path d="M11 11.7158L21 21.7158" stroke="#1B2132" stroke-linecap="round"/>
</svg>

After

Width:  |  Height:  |  Size: 441 B

View File

@ -57,6 +57,7 @@ const search_type = ref("normal");
const type_key = ref("hadith"); const type_key = ref("hadith");
const typeModelValue = ref("normal"); const typeModelValue = ref("normal");
const typeModelValueFa = ref(""); const typeModelValueFa = ref("");
const showclearButton = ref(false);
// If you want to share state across multiple components, // If you want to share state across multiple components,
// you can use the same key in useState. Nuxt will ensure // you can use the same key in useState. Nuxt will ensure
@ -168,17 +169,27 @@ const clearSimilar = () => {
// const onUpdateModel = (newVal: boolean | InputMenuItem | any) => { // const onUpdateModel = (newVal: boolean | InputMenuItem | any) => {
// console.info("onUpdateModel", newVal); // console.info("onUpdateModel", newVal);
// }; // };
const searchButtonIcon = computed(() => {
return showclearButton.value ? "i-lucide-x" : "i-haditha-search";
});
const handleSearchClearButton = ()=>{
showclearButton.value = true;
sendQuery();
}
const onKeyDown = () => { const onKeyDown = () => {
clearTimeout(typingTimer.value); showclearButton.value = false;
}; // clearTimeout(typingTimer.value);
const onKeyUp = () => {
clearTimeout(typingTimer.value);
typingTimer.value = setTimeout(() => {
if (props.autoRedirection) sendQuery();
}, doneTypingInterval.value);
}; };
// const onKeyUp = () => {
// clearTimeout(typingTimer.value);
// typingTimer.value = setTimeout(() => {
// if (props.autoRedirection) sendQuery();
// }, doneTypingInterval.value);
// };
const setType = (type: string) => { const setType = (type: string) => {
search_type.value = type; search_type.value = type;
sendQuery(); sendQuery();
@ -225,11 +236,6 @@ const sendQuery = async (payload = {}) => {
.postRequest(url, payload) .postRequest(url, payload)
.then((res) => { .then((res) => {
// pass res and search query to the parent. // pass res and search query to the parent.
emit("response-ready", {
res: res,
searchQuery: searchTerm.value,
disableAutoRedirect: true,
});
loading.value = false; loading.value = false;
// check if search term is not empty // check if search term is not empty
@ -238,6 +244,32 @@ const sendQuery = async (payload = {}) => {
// close the history dropdown menu // close the history dropdown menu
open.value = false; 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 // store search phrase
useStorage("searchPhrase", searchTerm.value); useStorage("searchPhrase", searchTerm.value);
}) })
@ -405,7 +437,6 @@ onMounted(() => {
@blur="open = false" @blur="open = false"
@change="sendQuery" @change="sendQuery"
@keydown="onKeyDown" @keydown="onKeyDown"
@keyup="onKeyUp"
@keydown.enter="sendQuery" @keydown.enter="sendQuery"
> >
<!-- @update:modelValue="onUpdateModel" --> <!-- @update:modelValue="onUpdateModel" -->
@ -414,8 +445,9 @@ onMounted(() => {
</div> </div>
<UButton <UButton
class="my-trailing-button" class="my-trailing-button"
@click.prevent="sendQuery" :class="{ 'close-mode': showclearButton }"
icon="i-haditha-search" @click.prevent="handleSearchClearButton"
:icon="searchButtonIcon"
> >
<!-- <UIcon name="i-lucide-search" /> --> <!-- <UIcon name="i-lucide-search" /> -->
</UButton> </UButton>
@ -765,6 +797,13 @@ onMounted(() => {
); */ ); */
} }
} }
.close-mode {
background: #f0f1f4;
color: #000; /* رنگ خاکستری */
&:hover {
background: #e0e0e0; /* رنگ خاکستری */
}
}
.haditha-search-input { .haditha-search-input {
z-index: 0; z-index: 0;

View File

@ -23,11 +23,18 @@ const router = useRouter();
function openModal(selectedItem) { function openModal(selectedItem) {
// modal.open(SearchShow, { title: "Welcome" }); // modal.open(SearchShow, { title: "Welcome" });
// isModalOpen.value = true; // isModalOpen.value = true;
const slug = selectedItem._source.content.split(' ').filter((v,i)=>i<4).join('-');
router.push({ router.push({
name: "hadithaSearchShow", name: "hadithaSearchShow",
params: { params: {
id: selectedItem._id, id: selectedItem._source.id,
slug: "no-slug", slug: slug,
},
query: {
firstPage: 1,
page_count:props.total
}, },
}); });
} }

View File

@ -228,10 +228,14 @@ const handlePagination = (prevNextIndicator: string) => {
.getRequest(url) .getRequest(url)
.then((res) => { .then((res) => {
state.selectedItem = res.hits.hits?.[0]; state.selectedItem = res.hits.hits?.[0];
page_num.value = res.hits.hits[0]._source.address.page_num ?? 1;
}) })
.finally(() => (loading.value = false)); .finally(() => (loading.value = false));
}; };
const page_num = ref(1);
const handlePageChange = () => {
handlePagination(1, page_num.value);
};
// const localCopyTextToClipboard = (text: string) => { // const localCopyTextToClipboard = (text: string) => {
// copyTextToClipboard(text); // copyTextToClipboard(text);
// }; // };
@ -413,24 +417,24 @@ const handlePagination = (prevNextIndicator: string) => {
<div class="body-footer"> <div class="body-footer">
<div class="mt-5 z-2"> <div class="mt-5 z-2">
<div class="flex justify-between actions"> <!-- <div class="flex justify-between actions"> -->
<UButton <!-- <UButton
disabled disabled
class="similar-btn" class="similar-btn"
icon="i-haditha-search-3" icon="i-haditha-search-3"
label="مشابه" label="مشابه"
color="neutral" color="neutral"
variant="outline" variant="outline"
/> /> -->
<!-- @click.prevent="goToTheSearch('similar')" --> <!-- @click.prevent="goToTheSearch('similar')" -->
<UButton <!-- <UButton
class="explore-btn" class="explore-btn"
trailing-icon="i-haditha-explore" trailing-icon="i-haditha-explore"
label="کاوش" label="کاوش"
variant="solid" variant="solid"
@click.prevent="goToTheChatbot" @click.prevent="goToTheChatbot"
/> /> -->
</div> <!-- </div> -->
<div class="flex justify-between pagination"> <div class="flex justify-between pagination">
<UButton <UButton
@click="handlePagination('-1')" @click="handlePagination('-1')"
@ -440,6 +444,27 @@ const handlePagination = (prevNextIndicator: string) => {
variant="soft" variant="soft"
icon="i-haditha-chevron-right" icon="i-haditha-chevron-right"
/> />
<div class="flex items-center">
<span class="total-pages">{{ route.query.page_count }}</span>
<span class="mx-2">/</span>
<UInput
:disabled="loading"
color="neutral"
variant="outline"
v-model="page_num"
@change="handlePageChange"
:ui="{
root: 'root ',
base: 'base page-number-input',
leading: 'leading',
leadingIcon: 'leadingIcon',
leadingAvatar: 'leadingAvatar',
leadingAvatarSize: 'leadingAvatarSize',
trailing: 'trailing',
trailingIcon: 'trailingIcon',
}"
/>
</div>
<UButton <UButton
@click="handlePagination('1')" @click="handlePagination('1')"
class="next-haditha" class="next-haditha"
@ -778,6 +803,15 @@ const handlePagination = (prevNextIndicator: string) => {
text-align: right; text-align: right;
color: var(--ui-color-two); color: var(--ui-color-two);
} }
.total-pages {
font-family: IRANSansX;
font-weight: 400;
font-size: 12px;
line-height: 100%;
letter-spacing: 0%;
text-align: right;
color: #8a92a8;
}
} }
} }
} }

View File

@ -90,7 +90,7 @@ const SearchList = defineAsyncComponent(() =>
</div> </div>
<div <div
v-if="searchQuery?.length == 0" v-if="searchQuery?.length == 0"
class="flex justify-center flex-col items-center" class="flex justify-center flex-col items-center mt-10"
> >
<img <img
fit="auto" fit="auto"
@ -100,7 +100,7 @@ const SearchList = defineAsyncComponent(() =>
/> />
<div class="title"> <div class="title">
کاوش با کاوش با
<span class="badge-style"> هوش مصنوعی </span> <span class="badge-style mx-1">هوش مصنوعی</span>
در احادیث اسلامی در احادیث اسلامی
</div> </div>
</div> </div>