fix: 🐛 引入 qs 插件对 URL 参数编码

This commit is contained in:
ray
2024-08-03 11:06:49 +08:00
parent 69584a12b8
commit 4e61afb13e
2 changed files with 9 additions and 1 deletions

View File

@@ -62,6 +62,7 @@
"path-browserify": "^1.0.1", "path-browserify": "^1.0.1",
"path-to-regexp": "^6.2.2", "path-to-regexp": "^6.2.2",
"pinia": "^2.1.7", "pinia": "^2.1.7",
"qs": "^6.13.0",
"sockjs-client": "1.6.1", "sockjs-client": "1.6.1",
"sortablejs": "^1.15.2", "sortablejs": "^1.15.2",
"stompjs": "^2.3.3", "stompjs": "^2.3.3",
@@ -79,6 +80,7 @@
"@types/node": "^20.14.10", "@types/node": "^20.14.10",
"@types/nprogress": "^0.2.3", "@types/nprogress": "^0.2.3",
"@types/path-browserify": "^1.0.2", "@types/path-browserify": "^1.0.2",
"@types/qs": "^6.9.15",
"@types/sockjs-client": "^1.5.4", "@types/sockjs-client": "^1.5.4",
"@types/sortablejs": "^1.15.8", "@types/sortablejs": "^1.15.8",
"@types/stompjs": "^2.3.9", "@types/stompjs": "^2.3.9",
@@ -125,5 +127,6 @@
"license": "MIT", "license": "MIT",
"engines": { "engines": {
"node": ">=18.0.0" "node": ">=18.0.0"
} },
"packageManager": "pnpm@9.1.3+sha512.7c2ea089e1a6af306409c4fc8c4f0897bdac32b772016196c469d9428f1fe2d5a21daf8ad6512762654ac645b5d9136bb210ec9a00afa8dbc4677843ba362ecd"
} }

View File

@@ -2,12 +2,17 @@ import axios, { InternalAxiosRequestConfig, AxiosResponse } from "axios";
import { useUserStoreHook } from "@/store/modules/user"; import { useUserStoreHook } from "@/store/modules/user";
import { ResultEnum } from "@/enums/ResultEnum"; import { ResultEnum } from "@/enums/ResultEnum";
import { TOKEN_KEY } from "@/enums/CacheEnum"; import { TOKEN_KEY } from "@/enums/CacheEnum";
import qs from "qs";
// 创建 axios 实例 // 创建 axios 实例
const service = axios.create({ const service = axios.create({
baseURL: import.meta.env.VITE_APP_BASE_API, baseURL: import.meta.env.VITE_APP_BASE_API,
timeout: 50000, timeout: 50000,
headers: { "Content-Type": "application/json;charset=utf-8" }, headers: { "Content-Type": "application/json;charset=utf-8" },
paramsSerializer: (params) => {
return qs.stringify(params);
},
}); });
// 请求拦截器 // 请求拦截器