fix: 微服务版本 区间查询和中文搜索条件一起使用 无法正确查询

This commit is contained in:
dap
2024-12-06 09:27:11 +08:00
parent 827ef2e403
commit 48ca7aca8c
4 changed files with 23 additions and 1 deletions

View File

@@ -13,6 +13,7 @@
**BUG FIXES** **BUG FIXES**
- 操作日志详情 在description组件中json预览样式异常 - 操作日志详情 在description组件中json预览样式异常
- 微服务版本 区间查询和中文搜索条件一起使用 无法正确查询
# 1.1.2 # 1.1.2

View File

@@ -10,6 +10,7 @@ import {
authenticateResponseInterceptor, authenticateResponseInterceptor,
errorMessageResponseInterceptor, errorMessageResponseInterceptor,
RequestClient, RequestClient,
stringify,
} from '@vben/request'; } from '@vben/request';
import { useAccessStore } from '@vben/stores'; import { useAccessStore } from '@vben/stores';
@@ -94,6 +95,23 @@ function createRequestClient(baseURL: string) {
// 添加全局clientId // 添加全局clientId
config.headers.clientId = clientId; config.headers.clientId = clientId;
/**
* 格式化get/delete参数
* 如果包含自定义的paramsSerializer则不走此逻辑
*/
if (
['DELETE', 'GET'].includes(config.method?.toUpperCase() || '') &&
config.params &&
!config.paramsSerializer
) {
/**
* 1. 格式化参数 微服务在传递区间时间选择(后端的params Map类型参数)需要格式化key 否则接收不到
* 2. 数组参数需要格式化 后端才能正常接收 会变成arr=1&arr=2&arr=3的格式来接收
*/
config.paramsSerializer = (params) =>
stringify(params, { arrayFormat: 'repeat' });
}
const { encrypt } = config; const { encrypt } = config;
// 全局开启请求加密功能 && 该请求开启 && 是post/put请求 // 全局开启请求加密功能 && 该请求开启 && 是post/put请求
if ( if (

View File

@@ -22,9 +22,11 @@
"dependencies": { "dependencies": {
"@vben/locales": "workspace:*", "@vben/locales": "workspace:*",
"@vben/utils": "workspace:*", "@vben/utils": "workspace:*",
"axios": "catalog:" "axios": "catalog:",
"qs": "^6.13.1"
}, },
"devDependencies": { "devDependencies": {
"@types/qs": "^6.9.17",
"axios-mock-adapter": "catalog:" "axios-mock-adapter": "catalog:"
} }
} }

View File

@@ -1,2 +1,3 @@
export * from './request-client'; export * from './request-client';
export * from 'axios'; export * from 'axios';
export { stringify } from 'qs';