From 9a52cebd1d5df8dbde2602264bde605cc54d7580 Mon Sep 17 00:00:00 2001 From: Ryan Wang Date: Thu, 11 May 2023 10:44:20 +0800 Subject: [PATCH] refactor: make tanstack query's network mode option to always (#3928) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit #### What type of PR is this? /kind improvement /area core /milstone 2.6.x #### What this PR does / why we need it: 将 TanStack Query 的 Network Mode 设置为 always,防止在无网络的情况下,开发环境也无法请求数据。 #### Special notes for your reviewer: 测试方式:断网之后使用开发模式访问 Console,观察请求是否正常发送即可。 #### Does this PR introduce a user-facing change? ```release-note None ``` --- console/src/setup/setupVueQuery.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/console/src/setup/setupVueQuery.ts b/console/src/setup/setupVueQuery.ts index 9e5acaa91..439e9284f 100644 --- a/console/src/setup/setupVueQuery.ts +++ b/console/src/setup/setupVueQuery.ts @@ -4,11 +4,17 @@ import { type VueQueryPluginOptions, } from "@tanstack/vue-query"; +const networkMode = import.meta.env.PROD ? "online" : "always"; + const options: VueQueryPluginOptions = { queryClientConfig: { defaultOptions: { queries: { refetchOnWindowFocus: false, + networkMode, + }, + mutations: { + networkMode, }, }, },