From 52760b015078c1f8ffa81a40bd7b66923832f662 Mon Sep 17 00:00:00 2001 From: Baghi Date: Thu, 17 Apr 2025 17:03:46 +0330 Subject: [PATCH] bookmark --- components/haditha/AutoComplation.vue | 76 ++++++++++--------- components/haditha/NavigationMenu.vue | 5 +- components/haditha/search-page/SearchList.vue | 42 ++++++---- pages/haditha/search/[id]/[slug]/index.vue | 51 +++++++++---- 4 files changed, 110 insertions(+), 64 deletions(-) diff --git a/components/haditha/AutoComplation.vue b/components/haditha/AutoComplation.vue index f43c75f..3089975 100644 --- a/components/haditha/AutoComplation.vue +++ b/components/haditha/AutoComplation.vue @@ -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, - }); - } - - showclearButton.value = !showclearButton.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); @@ -445,10 +449,10 @@ onMounted(() => { + @@ -606,7 +610,7 @@ onMounted(() => { {{ state.phrase.label }} diff --git a/components/haditha/NavigationMenu.vue b/components/haditha/NavigationMenu.vue index 230a43f..6bc9c1d 100644 --- a/components/haditha/NavigationMenu.vue +++ b/components/haditha/NavigationMenu.vue @@ -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; diff --git a/components/haditha/search-page/SearchList.vue b/components/haditha/search-page/SearchList.vue index 10241d1..7869e59 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, }, }); } @@ -68,20 +71,31 @@ function openModal(selectedItem) { v-for="(item, index) in props.list" :key="index" > -

+ {{ item?._source?.meta?.hadith_masoum ?? - item?._source?.meta?.hadith_sanad ?? - "بدون عنوان" + item?._source?.meta?.hadith_sanad }} -

-

+ + {{ item?._source?.content_ar }} -

-

+

+ >

{{ item?._source?.address?.vol_title }}، صفحه @@ -202,7 +216,7 @@ function openModal(selectedItem) { .reference { height: 24px; gap: 4px; - padding-top: 0.25em; /*4px*/ + padding-top: 0.25em; /*4px*/ padding-right: 0.5em; /*8px*/ padding-bottom: 0.25em; /*4px*/ padding-left: 0.5em; /*8px*/ @@ -231,7 +245,7 @@ function openModal(selectedItem) { font-family: IRANSansX; font-weight: 300; font-size: 1rem; - line-height: 1.5rem; /*24px*/ + line-height: 1.5rem; /*24px*/ letter-spacing: 0%; text-align: center; } @@ -248,7 +262,7 @@ function openModal(selectedItem) { box-shadow: 0px 8px 20px 0px #0000001a; background: #ffffff; width: 100%; - max-width: 720px; /*18px*/ + max-width: 720px; /*18px*/ border-radius: 16px; /*18px*/ gap: 8px; border-width: 0.3px; diff --git a/pages/haditha/search/[id]/[slug]/index.vue b/pages/haditha/search/[id]/[slug]/index.vue index 8a57b9a..f3c943b 100644 --- a/pages/haditha/search/[id]/[slug]/index.vue +++ b/pages/haditha/search/[id]/[slug]/index.vue @@ -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) => { {{ state.selectedItem?._source?.meta?.hadith_masoum ?? - "بدون عنوان" + state.selectedItem?._source?.meta?.hadith_sanad }} { label="کپی" />

-
-

بدون متن عربی

+
+

+ {{ state.selectedItem?._source?.content_ar ?? "" }} +

@@ -345,7 +361,7 @@ const handlePagination = (prevNextIndicator: string) => {

{{ state.selectedItem?._source?.meta?.hadith_masoum ?? - "بدون عنوان" + state.selectedItem?._source?.meta?.hadith_sanad }}:

{

-
+
شرح {

-
+
کلیدواژگان: {
-
+
دسته بندی ها: