This commit is contained in:
Baghi 2025-04-17 17:03:46 +03:30
parent 26f19fb9fc
commit 52760b0150
4 changed files with 110 additions and 64 deletions

View File

@ -57,7 +57,7 @@ const search_type = ref("normal");
const type_key = ref("hadith");
const typeModelValue = ref("normal");
const typeModelValueFa = ref("");
const showclearButton = ref(false);
// const showclearButton = ref(false);
// If you want to share state across multiple components,
// you can use the same key in useState. Nuxt will ensure
@ -169,17 +169,17 @@ 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 searchButtonIcon = computed(() => {
// return showclearButton.value ? "i-lucide-x" : "i-haditha-search";
// });
const handleSearchClearButton = ()=>{
showclearButton.value = true;
sendQuery();
}
// const handleSearchClearButton = ()=>{
// showclearButton.value = true;
// sendQuery();
// }
const onKeyDown = () => {
showclearButton.value = false;
// showclearButton.value = false;
// clearTimeout(typingTimer.value);
};
@ -235,6 +235,12 @@ const sendQuery = async (payload = {}) => {
return await httpService
.postRequest(url, payload)
.then((res) => {
emit("response-ready", {
res: res,
searchQuery: searchTerm.value,
disableAutoRedirect: true,
});
// pass res and search query to the parent.
loading.value = false;
@ -244,31 +250,29 @@ const sendQuery = async (payload = {}) => {
// close the history dropdown menu
open.value = false;
// show clear button
if (showclearButton.value) {
searchTerm.value = "";
// 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,
});
}
// 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;
// showclearButton.value = !showclearButton.value;
// store search phrase
useStorage("searchPhrase", searchTerm.value);
@ -445,10 +449,10 @@ onMounted(() => {
</div>
<UButton
class="my-trailing-button"
:class="{ 'close-mode': showclearButton }"
@click.prevent="handleSearchClearButton"
:icon="searchButtonIcon"
@click.prevent="sendQuery"
icon="i-haditha-search"
>
<!-- // @click.prevent="handleSearchClearButton" // :icon="searchButtonIcon" -->
<!-- <UIcon name="i-lucide-search" /> -->
</UButton>
<!-- </client-only> -->
@ -606,7 +610,7 @@ onMounted(() => {
{{ state.phrase.label }}
<UIcon
v-if="search_type == 'phrase'"
@click.self="search_type = 'normal'"
@click.self="setType('normal')"
name="i-haditha-close-bg-circle"
size="20px"
>

View File

@ -126,7 +126,7 @@ const leftItem = computed(() => [
const isMobile = ref(false);
const rerenderNavigation = ref(1);
const { isAuthenticatedGetter } = useAuthStore();
const { isAuthenticatedGetter, isRealUserGetter } = useAuthStore();
const setMenu = () => {
if (isAuthenticatedGetter) {
@ -152,6 +152,9 @@ const setMenu = () => {
setMenu();
// if(!(isAuthenticatedGetter && isRealUserGetter))
// items.value = items.value.filter((item) => item.to != "/haditha/favorites");
onMounted(() => {
if (window?.outerWidth < 991) {
isMobile.value = true;

View File

@ -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,
},
});
}
@ -68,20 +71,31 @@ function openModal(selectedItem) {
v-for="(item, index) in props.list"
:key="index"
>
<p @click="openModal(item)" class="from-person">
<a
:href="`/haditha/search/${item._source.id}/${
item._source.meta.hadith_masoum ?? item?._source?.meta?.hadith_sanad
}`"
@click.prevent="openModal(item)"
class="from-person block"
>
{{
item?._source?.meta?.hadith_masoum ??
item?._source?.meta?.hadith_sanad ??
"بدون عنوان"
item?._source?.meta?.hadith_sanad
}}
</p>
<p @click="openModal(item)" class="arabic-text">
</a>
<a
@click.prevent="openModal(item)"
class="arabic-text block"
:href="`/haditha/search/${item._source.id}/${item._source.content_ar}`"
>
{{ item?._source?.content_ar }}
</p>
<p
class="persian-text"
</a>
<a
@click.prevent="openModal(item)"
:href="`/haditha/search/${item._source.id}/${item._source.content}`"
class="persian-text block"
v-html="item?.highlight?.['content.fa'] ?? item?._source?.content"
></p>
></a>
<div class="flex justify-end">
<p class="reference">
{{ item?._source?.address?.vol_title }}، صفحه

View File

@ -174,7 +174,13 @@ const goToTheChatbot = () => {
};
const handleFavorite = async () => {
addToFavorites(state.selectedItem);
if (state.selectedItem?._source?.tbookmark) {
await removeFromFavorites(state.selectedItem);
state.selectedItem._source.tbookmark = false;
} else {
await addToFavorites(state.selectedItem);
state.selectedItem._source.tbookmark = true;
}
// // add
// if (!state.selectedItem._source.tbookmark) {
@ -220,8 +226,8 @@ const handlePagination = (prevNextIndicator: string) => {
let url = repoUrl() + hadithaApi.search.prevNextHadith;
url = url.replace("@index_key", "dhparag");
url = url.replace("@vol_id", state.selectedItem._source.address.vol_id);
url = url.replace("@parag_order", state.selectedItem._source.parag_order);
url = url.replace("@vol_id", state.selectedItem?._source?.address?.vol_id);
url = url.replace("@parag_order", state.selectedItem?._source?.parag_order);
url = url.replace("@step", prevNextIndicator);
httpService
@ -305,14 +311,19 @@ const handlePagination = (prevNextIndicator: string) => {
<span class="section-title">
{{
state.selectedItem?._source?.meta?.hadith_masoum ??
"بدون عنوان"
state.selectedItem?._source?.meta?.hadith_sanad
}}
</span>
<UButton
v-if="
state.selectedItem?._source?.meta?.hadith_masoum
?.length ||
state.selectedItem?._source?.meta?.hadith_sanad
"
@click="
copyTextToClipboard(
state.selectedItem?._source?.meta?.hadith_masoum ?? ''
state.selectedItem?._source?.content_ar ?? ''
)
"
variant="ghost"
@ -320,8 +331,13 @@ const handlePagination = (prevNextIndicator: string) => {
label="کپی"
/>
</div>
<div class="arabic-text">
<p>بدون متن عربی</p>
<div
v-if="state.selectedItem?._source?.content_ar?.length"
class="arabic-text"
>
<p>
{{ state.selectedItem?._source?.content_ar ?? "" }}
</p>
</div>
</div>
@ -345,7 +361,7 @@ const handlePagination = (prevNextIndicator: string) => {
<p class="from">
{{
state.selectedItem?._source?.meta?.hadith_masoum ??
"بدون عنوان"
state.selectedItem?._source?.meta?.hadith_sanad
}}:
</p>
<p
@ -356,13 +372,16 @@ const handlePagination = (prevNextIndicator: string) => {
<div class="separator"></div>
<div class="text-description-section">
<div
v-if="state.selectedItem?._source?.description?.length"
class="text-description-section"
>
<div class="section-header">
<span class="section-title"> شرح </span>
<UButton
@click="
copyTextToClipboard(
state.selectedItem?._source?.content
state.selectedItem?._source?.description
)
"
variant="ghost"
@ -372,14 +391,17 @@ const handlePagination = (prevNextIndicator: string) => {
</div>
<p
class="description-item"
v-html="state.selectedItem?._source?.content"
v-html="state.selectedItem?._source?.description"
></p>
</div>
<div class="separator"></div>
<div class="text-description-section">
<div class="text-sm mb-1">
<div
v-if="state.selectedItem?._source?.ai_keywords?.length"
class="text-sm mb-1"
>
<span class=""> کلیدواژگان: </span>
<span
class="me-1 text-gray-400 font-light"
@ -392,7 +414,10 @@ const handlePagination = (prevNextIndicator: string) => {
</span>
</div>
<div class="text-sm">
<div
class="text-sm"
v-if="state.selectedItem?._source?.ai_classes?.length"
>
<span class=""> دسته بندی ها: </span>
<span
class="me-1 text-gray-400 font-light"