Bläddra i källkod

feat: 新增 useQuery请求库

hotchicken1996 1 år sedan
förälder
incheckning
56cf0fa15e
2 ändrade filer med 21 tillägg och 1 borttagningar
  1. 6 1
      client/src/main.ts
  2. 15 0
      client/src/plugins/vueQuery/index.ts

+ 6 - 1
client/src/main.ts

@@ -22,6 +22,9 @@ import { setupElementPlus } from '@/plugins/elementPlus'
 // 引入 form-create
 import { setupFormCreate } from '@/plugins/formCreate'
 
+// 引入 vue-query
+import { setupVueQuery } from '@/plugins/vueQuery'
+
 // 引入全局样式
 import '@/styles/index.scss'
 
@@ -67,10 +70,12 @@ const setupAll = async () => {
 
   setupAuth(app)
 
+  setupVueQuery(app)
+
   await router.isReady()
 
   app.use(VueDOMPurifyHTML)
-  
+
   app.mount('#app')
 }
 

+ 15 - 0
client/src/plugins/vueQuery/index.ts

@@ -0,0 +1,15 @@
+import { VueQueryPlugin } from '@tanstack/vue-query'
+import { App } from 'vue'
+
+// vue-query配置
+const vueQueryPluginOptions = {
+  queryClientConfig: {
+    defaultOptions: {
+      queries: { refetchOnWindowFocus: false }
+    }
+  }
+}
+
+export const setupVueQuery = (app: App<Element>) => {
+  app.use(VueQueryPlugin, vueQueryPluginOptions)
+}