diff --git a/frontend/plugins/axios.ts b/frontend/plugins/axios.ts new file mode 100644 index 0000000..b9d4a67 --- /dev/null +++ b/frontend/plugins/axios.ts @@ -0,0 +1,23 @@ +import axios from "axios"; + +export default defineNuxtPlugin(() => { + + const config = useRuntimeConfig() + + const axiosInstance = axios.create({ + baseURL: config.public.API_BASE_URL, + timeout: 20000, + timeoutErrorMessage: 'خطای سرور', + headers: { + 'Content-Type': 'application/json' + } + }); + + axiosInstance.interceptors.response.use() + + return { + provide: { + axios: axiosInstance, + }, + }; +}); \ No newline at end of file diff --git a/frontend/plugins/gsap.client.ts b/frontend/plugins/gsap.client.ts new file mode 100644 index 0000000..e23323b --- /dev/null +++ b/frontend/plugins/gsap.client.ts @@ -0,0 +1,16 @@ +import { gsap } from 'gsap' +import { ScrollTrigger } from 'gsap/ScrollTrigger' +import { ScrollToPlugin } from 'gsap/ScrollToPlugin' + +export default defineNuxtPlugin(() => { + if (process.client) { + gsap.registerPlugin(ScrollTrigger, ScrollToPlugin) + } + + return { + provide: { + gsap, + ScrollTrigger, + }, + } +}) \ No newline at end of file diff --git a/frontend/plugins/scrollTo.client.ts b/frontend/plugins/scrollTo.client.ts new file mode 100644 index 0000000..a605d72 --- /dev/null +++ b/frontend/plugins/scrollTo.client.ts @@ -0,0 +1,9 @@ +import VueScrollTo from "vue-scrollto"; + +export default defineNuxtPlugin(() => { + return { + provide: { + vScrollTo: VueScrollTo, + }, + }; +}); diff --git a/frontend/plugins/tanstack.ts b/frontend/plugins/tanstack.ts new file mode 100644 index 0000000..231859c --- /dev/null +++ b/frontend/plugins/tanstack.ts @@ -0,0 +1,39 @@ +import type { + DehydratedState, + VueQueryPluginOptions +} from "@tanstack/vue-query"; +import { + VueQueryPlugin, + QueryClient, + hydrate, + dehydrate +} from "@tanstack/vue-query"; + +import { defineNuxtPlugin, useState } from "#imports"; + +export default defineNuxtPlugin((nuxt) => { + const vueQueryState = useState("vue-query"); + + const queryClient = new QueryClient({ + defaultOptions: { queries: { staleTime: 5000 } } + }); + const options: VueQueryPluginOptions = { queryClient }; + + nuxt.vueApp.use(VueQueryPlugin, options); + + if (import.meta.server) { + nuxt.hooks.hook("app:rendered", () => { + vueQueryState.value = dehydrate(queryClient); + }); + } + + if (import.meta.client) { + hydrate(queryClient, vueQueryState.value); + } + + return { + provide: { + queryClient + } + }; +}); diff --git a/frontend/plugins/toast.client.ts b/frontend/plugins/toast.client.ts new file mode 100644 index 0000000..9ddfc86 --- /dev/null +++ b/frontend/plugins/toast.client.ts @@ -0,0 +1,18 @@ +import Toast, { useToast } from "vue-toastification"; + +export default defineNuxtPlugin((nuxtApp) => { + nuxtApp.vueApp.use(Toast, { + position: "top-center", + hideProgressBar: true, + transition: "Vue-Toastification__fade", + maxToasts: 3, + closeButton: false, + timeout: 1800, + }); + + return { + provide: { + toast: useToast(), + }, + }; +});