Compare commits

..

3 Commits

Author SHA1 Message Date
88721dbb1a حذف بوکمارک 2025-04-19 11:24:19 +03:30
6054491d1b remove bookmarks 2025-04-17 18:17:58 +03:30
52760b0150 bookmark 2025-04-17 17:03:46 +03:30
5 changed files with 199 additions and 69 deletions

View File

@ -1,7 +1,7 @@
export default { export default {
search: { search: {
list: "repo/monir/search/@index_key/@search_type/@type_key/@listkey/@field_collapsed/@offset/@limit/@q=none", list: "repo/monir/search/@index_key/@search_type/@type_key/@listkey/@field_collapsed/@offset/@limit/@q=none",
show: "repo/public/get/byid/@index_key/@id", show: "repo/public/get/byid/@index_key/@id/tbookmark",
synonym: "synonym/get/words", synonym: "synonym/get/words",
prevNextHadith: "monir/next/@index_key/@vol_id/@parag_order/@step", prevNextHadith: "monir/next/@index_key/@vol_id/@parag_order/@step",
getDataTree: "@appname/book/tree/@offset/@limit/@vol_id/@q" getDataTree: "@appname/book/tree/@offset/@limit/@vol_id/@q"

View File

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

View File

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

View File

@ -1,4 +1,6 @@
<script setup> <script setup>
import hadithaApi from "@haditha/apis/hadithaApi";
const httpService = useNuxtApp()["$http"];
const props = defineProps({ const props = defineProps({
list: { list: {
default() { default() {
@ -16,6 +18,7 @@ const props = defineProps({
}, },
}); });
const router = useRouter(); const router = useRouter();
const route = useRoute();
// const modal = useModal(); // const modal = useModal();
// const isModalOpen = ref(false); // const isModalOpen = ref(false);
@ -24,17 +27,20 @@ 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('-'); const slug = selectedItem?._source?.content
.split(" ")
.filter((v, i) => i < 4)
.join("-");
router.push({ router.push({
name: "hadithaSearchShow", name: "hadithaSearchShow",
params: { params: {
id: selectedItem._source.id, id: selectedItem?._source?.id,
slug: slug, slug: slug,
}, },
query: { query: {
firstPage: 1, firstPage: 1,
page_count:props.total page_count: props.total,
}, },
}); });
} }
@ -52,6 +58,20 @@ function openModal(selectedItem) {
// const SearchShow = defineAsyncComponent(() => // const SearchShow = defineAsyncComponent(() =>
// import("@haditha/components/haditha/search-page/SearchShow.vue") // import("@haditha/components/haditha/search-page/SearchShow.vue")
// ); // );
const removeFromFavorites = async (item = {}, index = 0) => {
let url = repoUrl() + hadithaApi.favorite.deleteByRefid;
url = url.replace("{{data_type}}", "bookmark");
url = url.replace("{{index_key}}", "dhparag");
url = url.replace("{{ref_id}}", item._id);
const formData = {
ref_id: item._id,
title: item?._source?.title,
};
httpService.postRequest(url, formData).then((res) => {
// this.updateListAnswer(index, "tbookmark", 0);
});
};
</script> </script>
<template> <template>
@ -68,20 +88,43 @@ function openModal(selectedItem) {
v-for="(item, index) in props.list" v-for="(item, index) in props.list"
:key="index" :key="index"
> >
<p @click="openModal(item)" class="from-person"> <div class="flex justify-between mt-4 mb-2">
<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_masoum ??
item?._source?.meta?.hadith_sanad ?? item?._source?.meta?.hadith_sanad
"بدون عنوان"
}} }}
</p> </a>
<p @click="openModal(item)" class="arabic-text"> <UButton
v-if="route.name == 'hadithaFavorites'"
@click="removeFromFavorites(item)"
variant="ghost"
color="error"
class="copy-btn"
label="حذف"
/>
</div>
<a
@click.prevent="openModal(item)"
class="arabic-text block"
:href="`/haditha/search/${item?._source?.id}/${item?._source?.content_ar}`"
>
{{ item?._source?.content_ar }} {{ item?._source?.content_ar }}
</p> </a>
<p <a
class="persian-text" @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" v-html="item?.highlight?.['content.fa'] ?? item?._source?.content"
></p> ></a>
<div class="flex justify-end"> <div class="flex justify-end">
<p class="reference"> <p class="reference">
{{ item?._source?.address?.vol_title }}، صفحه {{ item?._source?.address?.vol_title }}، صفحه
@ -311,4 +354,28 @@ function openModal(selectedItem) {
.modal-overlay { .modal-overlay {
background: #00000033; background: #00000033;
} }
.copy-btn {
padding: 0.2em 1em;
/* width: 44px; */
/* height: 24px; */
gap: 4px;
border-radius: 6px;
border-width: 0.5px;
padding-top: 4px;
padding-right: 12px;
padding-bottom: 4px;
padding-left: 12px;
/* background: #ffffff; */
/* border: 0.5px solid #d9d9d9; */
font-family: IRANSansX;
font-weight: 300;
font-size: 12px;
line-height: 18px;
letter-spacing: 0%;
text-align: right;
/* color: #a71111; */
}
</style> </style>

View File

@ -132,6 +132,7 @@ const route = useRoute();
const router = useRouter(); const router = useRouter();
const loading = ref(false); const loading = ref(false);
const httpService = useNuxtApp()["$http"]; const httpService = useNuxtApp()["$http"];
const toast = useToast();
const state = reactive({ const state = reactive({
selectedItem: {} as HadithResponseShowModel, selectedItem: {} as HadithResponseShowModel,
@ -174,7 +175,13 @@ const goToTheChatbot = () => {
}; };
const handleFavorite = async () => { 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 // // add
// if (!state.selectedItem._source.tbookmark) { // if (!state.selectedItem._source.tbookmark) {
@ -196,6 +203,21 @@ const addToFavorites = async (item = {}) => {
}; };
httpService.postRequest(url, formData).then((res) => { httpService.postRequest(url, formData).then((res) => {
// this.updateListAnswer(index, "tbookmark", 1); // this.updateListAnswer(index, "tbookmark", 1);
try {
toast.add({
title: "انجام شد.",
description: "به نشان شده ها افزوده شد",
color: "success",
});
} catch (err) {
console.log(err.message);
toast.add({
title: "انجام شد.",
description: "خطایی رخ داد.لطفا دوباره امتحان کنید.",
color: "error",
});
}
}); });
}; };
@ -211,6 +233,21 @@ const removeFromFavorites = async (item = {}, index = 0) => {
}; };
httpService.postRequest(url, formData).then((res) => { httpService.postRequest(url, formData).then((res) => {
// this.updateListAnswer(index, "tbookmark", 0); // this.updateListAnswer(index, "tbookmark", 0);
try {
toast.add({
title: "انجام شد.",
description: "از لیست نشان شده ها حذف شد",
color: "success",
});
} catch (err) {
console.log(err.message);
toast.add({
title: "انجام شد.",
description: "خطایی رخ داد.لطفا دوباره امتحان کنید.",
color: "error",
});
}
}); });
}; };
@ -220,8 +257,8 @@ const handlePagination = (prevNextIndicator: string) => {
let url = repoUrl() + hadithaApi.search.prevNextHadith; let url = repoUrl() + hadithaApi.search.prevNextHadith;
url = url.replace("@index_key", "dhparag"); url = url.replace("@index_key", "dhparag");
url = url.replace("@vol_id", state.selectedItem._source.address.vol_id); url = url.replace("@vol_id", state.selectedItem?._source?.address?.vol_id);
url = url.replace("@parag_order", state.selectedItem._source.parag_order); url = url.replace("@parag_order", state.selectedItem?._source?.parag_order);
url = url.replace("@step", prevNextIndicator); url = url.replace("@step", prevNextIndicator);
httpService httpService
@ -305,14 +342,19 @@ const handlePagination = (prevNextIndicator: string) => {
<span class="section-title"> <span class="section-title">
{{ {{
state.selectedItem?._source?.meta?.hadith_masoum ?? state.selectedItem?._source?.meta?.hadith_masoum ??
"بدون عنوان" state.selectedItem?._source?.meta?.hadith_sanad
}} }}
</span> </span>
<UButton <UButton
v-if="
state.selectedItem?._source?.meta?.hadith_masoum
?.length ||
state.selectedItem?._source?.meta?.hadith_sanad
"
@click=" @click="
copyTextToClipboard( copyTextToClipboard(
state.selectedItem?._source?.meta?.hadith_masoum ?? '' state.selectedItem?._source?.content_ar ?? ''
) )
" "
variant="ghost" variant="ghost"
@ -320,8 +362,13 @@ const handlePagination = (prevNextIndicator: string) => {
label="کپی" label="کپی"
/> />
</div> </div>
<div class="arabic-text"> <div
<p>بدون متن عربی</p> v-if="state.selectedItem?._source?.content_ar?.length"
class="arabic-text"
>
<p>
{{ state.selectedItem?._source?.content_ar ?? "" }}
</p>
</div> </div>
</div> </div>
@ -345,7 +392,7 @@ const handlePagination = (prevNextIndicator: string) => {
<p class="from"> <p class="from">
{{ {{
state.selectedItem?._source?.meta?.hadith_masoum ?? state.selectedItem?._source?.meta?.hadith_masoum ??
"بدون عنوان" state.selectedItem?._source?.meta?.hadith_sanad
}}: }}:
</p> </p>
<p <p
@ -356,13 +403,16 @@ const handlePagination = (prevNextIndicator: string) => {
<div class="separator"></div> <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"> <div class="section-header">
<span class="section-title"> شرح </span> <span class="section-title"> شرح </span>
<UButton <UButton
@click=" @click="
copyTextToClipboard( copyTextToClipboard(
state.selectedItem?._source?.content state.selectedItem?._source?.description
) )
" "
variant="ghost" variant="ghost"
@ -372,14 +422,17 @@ const handlePagination = (prevNextIndicator: string) => {
</div> </div>
<p <p
class="description-item" class="description-item"
v-html="state.selectedItem?._source?.content" v-html="state.selectedItem?._source?.description"
></p> ></p>
</div> </div>
<div class="separator"></div> <div class="separator"></div>
<div class="text-description-section"> <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=""> کلیدواژگان: </span>
<span <span
class="me-1 text-gray-400 font-light" class="me-1 text-gray-400 font-light"
@ -392,7 +445,10 @@ const handlePagination = (prevNextIndicator: string) => {
</span> </span>
</div> </div>
<div class="text-sm"> <div
class="text-sm"
v-if="state.selectedItem?._source?.ai_classes?.length"
>
<span class=""> دسته بندی ها: </span> <span class=""> دسته بندی ها: </span>
<span <span
class="me-1 text-gray-400 font-light" class="me-1 text-gray-400 font-light"