diff --git a/package.json b/package.json index 6997bc2..b3c8dbc 100644 --- a/package.json +++ b/package.json @@ -28,6 +28,7 @@ "pinia": "^2.0.27", "print-js": "^1.6.0", "qrcodejs2-fixes": "^0.0.2", + "qs": "^6.11.0", "screenfull": "^6.0.2", "sortablejs": "^1.15.0", "splitpanes": "^3.1.5", diff --git a/src/types/global.d.ts b/src/types/global.d.ts index 584e065..a46b866 100644 --- a/src/types/global.d.ts +++ b/src/types/global.d.ts @@ -5,6 +5,7 @@ declare module 'splitpanes'; declare module 'js-cookie'; declare module '@wangeditor/editor-for-vue'; declare module 'js-table2excel'; +declare module 'qs'; // 声明一个模块,防止引入文件时报错 declare module '*.json'; diff --git a/src/utils/request.ts b/src/utils/request.ts index e428ae0..41b22b4 100644 --- a/src/utils/request.ts +++ b/src/utils/request.ts @@ -1,12 +1,18 @@ import axios, { AxiosInstance, AxiosRequestConfig } from 'axios'; import { ElMessage, ElMessageBox } from 'element-plus'; import { Session } from '/@/utils/storage'; +import qs from 'qs'; // 配置新建一个 axios 实例 const service: AxiosInstance = axios.create({ baseURL: import.meta.env.VITE_API_URL, timeout: 50000, headers: { 'Content-Type': 'application/json' }, + paramsSerializer: { + serialize: function (params) { + return qs.stringify(params, {allowDots: true}); + } + } }); // 添加请求拦截器