Add plugins

This commit is contained in:
marzban-dev
2024-12-11 20:15:17 +03:30
parent b52abb3aa7
commit 423784fba5
5 changed files with 105 additions and 0 deletions
+23
View File
@@ -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,
},
};
});
+16
View File
@@ -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,
},
}
})
+9
View File
@@ -0,0 +1,9 @@
import VueScrollTo from "vue-scrollto";
export default defineNuxtPlugin(() => {
return {
provide: {
vScrollTo: VueScrollTo,
},
};
});
+39
View File
@@ -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
}
};
});
+18
View File
@@ -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(),
},
};
});