From c09b154a3f04f07395a823bb33d550ffffb96f53 Mon Sep 17 00:00:00 2001 From: JiangQiang Date: Mon, 5 Dec 2022 10:48:16 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dget=E8=AF=B7=E6=B1=82?= =?UTF-8?q?=E4=BC=A0=E9=80=92=E5=B5=8C=E5=A5=97=E5=AF=B9=E8=B1=A1=E6=88=96?= =?UTF-8?q?=E6=95=B0=E7=BB=84=E6=97=B6=E6=97=A0=E6=B3=95=E6=AD=A3=E5=B8=B8?= =?UTF-8?q?=E7=BC=96=E7=A0=81=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 1 + src/types/global.d.ts | 1 + src/utils/request.ts | 6 ++++++ 3 files changed, 8 insertions(+) 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}); + } + } }); // 添加请求拦截器