Add plugins
This commit is contained in:
@@ -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,
|
||||
},
|
||||
};
|
||||
});
|
||||
@@ -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,
|
||||
},
|
||||
}
|
||||
})
|
||||
@@ -0,0 +1,9 @@
|
||||
import VueScrollTo from "vue-scrollto";
|
||||
|
||||
export default defineNuxtPlugin(() => {
|
||||
return {
|
||||
provide: {
|
||||
vScrollTo: VueScrollTo,
|
||||
},
|
||||
};
|
||||
});
|
||||
@@ -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<DehydratedState | null>("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
|
||||
}
|
||||
};
|
||||
});
|
||||
@@ -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(),
|
||||
},
|
||||
};
|
||||
});
|
||||
Reference in New Issue
Block a user