Compare commits
1 Commits
main
...
rezae/feat
Author | SHA1 | Date | |
---|---|---|---|
![]() |
c3eabf2cf2 |
|
@ -67,7 +67,13 @@
|
|||
|
||||
<script>
|
||||
import { mapActions, mapState } from "pinia";
|
||||
import { useResearchStore } from "~/stores/researchStore";
|
||||
|
||||
import { useAuthStore } from "@stores/authStore";
|
||||
import { useCommonStore } from "@stores/commonStore";
|
||||
import { useEntityStore } from "@entity/entityStore";
|
||||
import { useSearchStore } from "@search/stores/searchStore";
|
||||
import { useResearchStore } from "@research/stores/researchStore";
|
||||
|
||||
|
||||
export default {
|
||||
mounted() {
|
||||
|
@ -102,13 +108,18 @@ export default {
|
|||
},
|
||||
|
||||
methods: {
|
||||
...mapActions("common", ["systemsSetter", "activeSystemSetter"]),
|
||||
...mapActions(useCommonStore, [
|
||||
"systemsSetter",
|
||||
"activeSystemSetter",
|
||||
"searchActiveTabSetter",
|
||||
]),
|
||||
|
||||
...mapActions("aiTools", [
|
||||
"aiToolsActiveActionSetter",
|
||||
"aiToolsSchemaSetter",
|
||||
"aiToolsActiveDomainSetter",
|
||||
]),
|
||||
...mapActions("entity", [
|
||||
...mapActions(useEntityStore, [
|
||||
"activeTabSetter",
|
||||
"entityViewSchemaSetter",
|
||||
"activeEntityViewSchemaSetter",
|
||||
|
@ -119,10 +130,9 @@ export default {
|
|||
"domainActiveSetter",
|
||||
"selectionFilterItemsSetter",
|
||||
]),
|
||||
...mapActions("search", [
|
||||
...mapActions(useSearchStore, [
|
||||
"domainActiveSetter", //3
|
||||
"activeTabSetter", //2
|
||||
"searchActiveTabSetter",
|
||||
"searchSchemaSetter",
|
||||
"helpSchemaSetter",
|
||||
"helpActiveSchemaSetter",
|
||||
|
@ -134,7 +144,7 @@ export default {
|
|||
]),
|
||||
|
||||
reloadPage() {
|
||||
let appVersion = useStorage("app-version", '0.0.0');
|
||||
let appVersion = useStorage("app-version", "0.0.0");
|
||||
appVersion.vlaue = this.envVersion;
|
||||
|
||||
this.clearStorage();
|
||||
|
|
|
@ -1,58 +1,18 @@
|
|||
// composables/useInfiniteScroll.ts
|
||||
import { ref, onMounted, onBeforeUnmount } from "vue";
|
||||
|
||||
export default function useInfiniteScroll(
|
||||
callback: () => Promise<void>,
|
||||
elementId?: string
|
||||
callback: () => void,
|
||||
elementId: string
|
||||
) {
|
||||
const route = useRoute();
|
||||
const isFetching = ref(false);
|
||||
const infiniteScroll = ref<HTMLElement | Window | null>(null);
|
||||
const infiniteScroll = ref<HTMLElement | null>(null);
|
||||
|
||||
// Throttle function to limit scroll event frequency
|
||||
const throttle = (func: (...args: any[]) => void, limit: number) => {
|
||||
let lastFunc: ReturnType<typeof setTimeout>;
|
||||
let lastRan: number;
|
||||
return function (this: any, ...args: any[]) {
|
||||
const context = this;
|
||||
if (!lastRan) {
|
||||
func.apply(context, args);
|
||||
lastRan = Date.now();
|
||||
} else {
|
||||
clearTimeout(lastFunc);
|
||||
lastFunc = setTimeout(() => {
|
||||
if (Date.now() - lastRan >= limit) {
|
||||
func.apply(context, args);
|
||||
lastRan = Date.now();
|
||||
}
|
||||
}, limit - (Date.now() - lastRan));
|
||||
}
|
||||
};
|
||||
};
|
||||
const handleScroll = () => {
|
||||
if (isFetching.value) return;
|
||||
const scrollPosition =
|
||||
infiniteScroll.value.scrollTop + infiniteScroll.value.clientHeight;
|
||||
const threshold = infiniteScroll.value.scrollHeight - 100;
|
||||
|
||||
const checkScrollPosition = () => {
|
||||
if (isFetching.value || !infiniteScroll.value) return;
|
||||
|
||||
let scrollPosition: number;
|
||||
let threshold: number;
|
||||
let clientHeight: number;
|
||||
let scrollHeight: number;
|
||||
|
||||
if (infiniteScroll.value === window) {
|
||||
scrollPosition = window.scrollY || window.pageYOffset;
|
||||
clientHeight = document.documentElement.clientHeight;
|
||||
scrollHeight = document.documentElement.scrollHeight;
|
||||
} else {
|
||||
const el = infiniteScroll.value as HTMLElement;
|
||||
scrollPosition = el.scrollTop;
|
||||
clientHeight = el.clientHeight;
|
||||
scrollHeight = el.scrollHeight;
|
||||
}
|
||||
|
||||
threshold = scrollHeight - 100;
|
||||
const currentPosition = scrollPosition + clientHeight;
|
||||
|
||||
if (currentPosition >= threshold) {
|
||||
if (scrollPosition >= threshold) {
|
||||
isFetching.value = true;
|
||||
callback().finally(() => {
|
||||
isFetching.value = false;
|
||||
|
@ -60,57 +20,28 @@ export default function useInfiniteScroll(
|
|||
}
|
||||
};
|
||||
|
||||
// Throttled version of scroll handler
|
||||
const throttledScrollHandler = throttle(checkScrollPosition, 200);
|
||||
|
||||
const handleTouchEnd = () => {
|
||||
setTimeout(throttledScrollHandler, 100);
|
||||
// Add a slight delay to ensure scroll position is updated
|
||||
setTimeout(handleScroll, 100);
|
||||
};
|
||||
|
||||
onMounted(() => {
|
||||
console.info(route.name)
|
||||
|
||||
if (route.name == "hadithaSearch" || route.name == "hadithaLibrary") {
|
||||
const targetElement = elementId
|
||||
? document.getElementById(elementId)
|
||||
: window;
|
||||
|
||||
if (!targetElement) {
|
||||
console.warn(
|
||||
`Element ${elementId || "window"} not found for infinite scroll`
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
const targetElement = document.getElementById(elementId);
|
||||
infiniteScroll.value = targetElement;
|
||||
|
||||
if (targetElement === window) {
|
||||
window.addEventListener("scroll", throttledScrollHandler);
|
||||
window.addEventListener("touchend", handleTouchEnd);
|
||||
} else {
|
||||
targetElement.addEventListener("scroll", throttledScrollHandler);
|
||||
if (targetElement) {
|
||||
targetElement.addEventListener("scroll", handleScroll);
|
||||
targetElement.addEventListener("touchend", handleTouchEnd);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
onBeforeUnmount(() => {
|
||||
if (route.name == "hadithaSearch" || route.name == "hadithaLibrary") {
|
||||
if (!infiniteScroll.value) return;
|
||||
const targetElement = document.getElementById(elementId);
|
||||
infiniteScroll.value = targetElement;
|
||||
|
||||
if (infiniteScroll.value === window) {
|
||||
window.removeEventListener("scroll", throttledScrollHandler);
|
||||
window.removeEventListener("touchend", handleTouchEnd);
|
||||
} else {
|
||||
(infiniteScroll.value as HTMLElement).removeEventListener(
|
||||
"scroll",
|
||||
throttledScrollHandler
|
||||
);
|
||||
(infiniteScroll.value as HTMLElement).removeEventListener(
|
||||
"touchend",
|
||||
handleTouchEnd
|
||||
);
|
||||
}
|
||||
if (targetElement) {
|
||||
targetElement.removeEventListener("scroll", handleScroll);
|
||||
targetElement.removeEventListener("touchend", handleTouchEnd);
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -131,7 +131,7 @@ export default {
|
|||
};
|
||||
},
|
||||
computed: {
|
||||
...mapState(useSearchStore, ["searchSchemaGetter"]),
|
||||
...mapState(useCommonStore, ["searchSchemaGetter"]),
|
||||
},
|
||||
methods: {
|
||||
...mapActions(["checkPermissions"]),
|
||||
|
|
BIN
public/img/haditha/search-show-header.png
Normal file
BIN
public/img/haditha/search-show-header.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 73 KiB |
|
@ -20,9 +20,15 @@ import type {
|
|||
Pagination,
|
||||
} from "~/types/commonTypes";
|
||||
|
||||
import type { researchTerms } from "~/types/researchTypes";
|
||||
import type { researchTerms, searchActiveTab } from "~/types/researchTypes";
|
||||
import type { ActiveEntityViewSchema, ActiveTab } from "~/types/entityType";
|
||||
import type { Domain, helpActiveSchema, helpSchema } from "~/types/searchTypes";
|
||||
import type {
|
||||
Domain,
|
||||
helpActiveSchema,
|
||||
helpSchema,
|
||||
searchSchema,
|
||||
searchSynonymTitle,
|
||||
} from "~/types/searchTypes";
|
||||
|
||||
export const useCommonStore = defineStore("commonStore", {
|
||||
persist: {
|
||||
|
@ -85,6 +91,11 @@ export const useCommonStore = defineStore("commonStore", {
|
|||
appVersion: "" as string,
|
||||
isShowHilight: true as boolean,
|
||||
sidebarMenu: {},
|
||||
|
||||
// search
|
||||
searchSynonymTitle: undefined as searchSynonymTitle | undefined,
|
||||
searchActiveTab: undefined as searchActiveTab | undefined,
|
||||
searchSchema: undefined as searchSchema | undefined,
|
||||
}),
|
||||
getters: {
|
||||
// admin
|
||||
|
@ -95,10 +106,18 @@ export const useCommonStore = defineStore("commonStore", {
|
|||
return state.helpActiveSchema;
|
||||
},
|
||||
// from search
|
||||
searchSynonymTitleGetter(state) {
|
||||
return state.searchSynonymTitle;
|
||||
},
|
||||
searchActiveTabGetter(state) {
|
||||
return state.searchActiveTab;
|
||||
},
|
||||
searchSchemaGetter(state) {
|
||||
return state.searchSchema;
|
||||
},
|
||||
domainActiveGetter(state) {
|
||||
return state.domainActive;
|
||||
},
|
||||
|
||||
diffTypeGetter(diffType) {
|
||||
return diffType;
|
||||
},
|
||||
|
@ -108,7 +127,6 @@ export const useCommonStore = defineStore("commonStore", {
|
|||
activeEntityViewSchemaGetter(state) {
|
||||
return state.activeEntityViewSchema;
|
||||
},
|
||||
|
||||
researchTermsGetter(state) {
|
||||
return state.researchTerms;
|
||||
},
|
||||
|
@ -159,6 +177,17 @@ export const useCommonStore = defineStore("commonStore", {
|
|||
this.helpActiveSchema = helpActiveSchema;
|
||||
},
|
||||
// from search
|
||||
searchSynonymTitleSetter(searchSynonymTitle = undefined) {
|
||||
this.searchSynonymTitle = searchSynonymTitle;
|
||||
},
|
||||
|
||||
searchActiveTabSetter(searchActiveTab: searchActiveTab) {
|
||||
this.searchActiveTab = searchActiveTab;
|
||||
},
|
||||
searchSchemaSetter(searchSchema = undefined) {
|
||||
this.searchSchema = searchSchema;
|
||||
},
|
||||
|
||||
domainActiveSetter(domain = undefined) {
|
||||
this.domainActive = domain;
|
||||
},
|
||||
|
@ -185,7 +214,6 @@ export const useCommonStore = defineStore("commonStore", {
|
|||
this.collapsed = isCollapsed;
|
||||
},
|
||||
|
||||
|
||||
SET_SECTIONS(jahatSection: JahatSection) {
|
||||
this.jahatSection = jahatSection;
|
||||
},
|
||||
|
@ -255,7 +283,6 @@ export const useCommonStore = defineStore("commonStore", {
|
|||
this.$reset();
|
||||
},
|
||||
|
||||
|
||||
async getState() {
|
||||
const settingsApi = (await import("~/apis/adminApi")).default;
|
||||
const url = settingsApi.user.get;
|
||||
|
|
Loading…
Reference in New Issue
Block a user