浏览代码

去除所有索索的[]特殊字符

bill 1 年之前
父节点
当前提交
3a667969b0
共有 1 个文件被更改,包括 9 次插入0 次删除
  1. 9 0
      src/request/index.ts

+ 9 - 0
src/request/index.ts

@@ -31,6 +31,15 @@ let getAuth: AuthHook = () => ({ token: "", userId: "0", clear: () => {} });
 axios.defaults.baseURL = baseURL;
 
 axios.interceptors.request.use(async (config) => {
+  if (config.method === "get" && config.params) {
+    for (const key in config.params) {
+      const val = config.params[key];
+      if (typeof val === "string") {
+        config.params[key] = val.replaceAll(/[\[\]]/g, "");
+      }
+    }
+  }
+
   if (!config.url) {
     return config;
   }