hadith_ui/pages/hadith/index.vue

134 lines
3.4 KiB
Vue
Raw Normal View History

2025-02-11 10:17:22 +00:00
<template>
2025-02-11 12:49:27 +00:00
<HadithLayout :menu="sidbarMenu"> hadith page </HadithLayout>
2025-02-11 10:17:22 +00:00
</template>
<script>
import { useStorage } from "@vueuse/core";
import { mapActions, mapState } from "pinia";
2025-02-11 12:49:27 +00:00
import { useHadithStore } from "@hadith/stores/hadithStore";
2025-02-11 10:17:22 +00:00
import { useCommonStore } from "~/stores/commonStore";
2025-02-11 12:49:27 +00:00
import hadithApi from "@hadith/apis/hadithApi.js";
import navbarMenu from "@hadith/json/hadith/menu.json";
2025-02-11 10:17:22 +00:00
export default {
2025-02-11 12:49:27 +00:00
name: "hadith",
2025-02-11 10:17:22 +00:00
setup() {
useHead({
2025-02-11 12:49:27 +00:00
title: import.meta.env.VITE_HADITH_PAGE_TITLE,
meta: [
{ name: "description", content: "کاوش با هوش مصنوعی در احادیث اسلامی" },
],
2025-02-11 10:17:22 +00:00
bodyAttrs: {
2025-02-11 12:49:27 +00:00
class: import.meta.env.VITE_HADITH_SYSTEM,
2025-02-11 10:17:22 +00:00
},
});
definePageMeta({
layout: false,
2025-02-11 12:49:27 +00:00
name: "hadith",
2025-02-11 10:17:22 +00:00
});
},
created() {
this.httpService = useNuxtApp()["$http"];
},
2025-02-11 12:49:27 +00:00
2025-02-11 10:17:22 +00:00
async mounted() {
this.logo = (await logoPhoto()).default;
let schemaExist = this.searchActiveTabGetter && this.searchSchemaGetter;
if (!schemaExist) this.getSchemas();
else this.setSearchDomain(this.searchActiveTabGetter);
if (window.outerWidth < 992) {
this.$store.commit("TOGGLE_SIDEBAR_MENU");
this.showMobileFilterList = true;
}
},
data() {
return {
httpService: {},
logo: "",
2025-02-11 12:49:27 +00:00
sidbarMenuDefault: navbarMenu,
2025-02-11 10:17:22 +00:00
};
},
computed: {
2025-02-11 12:49:27 +00:00
// ...mapState(useHadithStore, [
// "domainActiveGetter",
// "searchActiveTabGetter",
// "searchSchemaGetter",
// "searchSynonymTitleGetter",
// ]),
2025-02-11 10:17:22 +00:00
...mapState(useCommonStore, [
"currentUser",
"organNameGetter",
"isSidebarCollapsed",
"userPermisionGetter",
]),
sidbarMenu() {
2025-02-11 12:49:27 +00:00
return this.sidbarMenuDefault;
2025-02-11 10:17:22 +00:00
},
},
methods: {
...mapActions(useCommonStore, [
"TOGGLE_SIDEBAR_MENU",
"sidebarCollapsedSetter",
]),
2025-02-11 12:49:27 +00:00
// ...mapActions(useHadithStore, [
// "searchActiveTabSetter",
// "searchSchemaSetter",
// "domainActiveSetter",
// "searchSynonymTitleSetter",
// ]),
2025-02-11 10:17:22 +00:00
async getSchemas() {
let localStoageSearchSchema = useStorage("searchSchema", undefined).value;
if (localStoageSearchSchema) {
let searchSchema = JSON.parse(localStoageSearchSchema);
this.searchSchemaSetter(searchSchema);
this.searchActiveTabSetter(searchSchema[0]);
} else {
const payload = {
organ: this.organNameGetter,
system: "search",
build_state: buildState(),
};
2025-02-11 12:49:27 +00:00
const url = repoUrl() + hadithApi.schema.list;
2025-02-11 10:17:22 +00:00
this.httpService
.postRequest(url, payload)
.then((res) => {
this.searchSchemaSetter(res.data.search);
this.searchActiveTabSetter(res.data.search[0]);
this.fetchingData = false;
2025-02-11 12:49:27 +00:00
const toast = useToast();
toast.add({
title: "Success",
description: "Your action was completed successfully.",
color: "success",
});
2025-02-11 10:17:22 +00:00
})
.catch((err) => {
this.fetchingData = false;
});
}
},
},
components: {
AutoComplation: defineAsyncComponent(() =>
2025-02-11 12:49:27 +00:00
import("@hadith/components/hadith/AutoComplation.vue")
2025-02-11 10:17:22 +00:00
),
2025-02-11 12:49:27 +00:00
HadithLayout: defineAsyncComponent(() =>
import("@hadith/layouts/HadithLayout.vue")
2025-02-11 10:17:22 +00:00
),
},
};
</script>