diff --git a/packages/client/src/api-client/APIClient.ts b/packages/client/src/api-client/APIClient.ts index 8889a9622..3908cb109 100644 --- a/packages/client/src/api-client/APIClient.ts +++ b/packages/client/src/api-client/APIClient.ts @@ -1,6 +1,7 @@ import { observable } from '@formily/reactive'; import { Result } from 'ahooks/lib/useRequest/src/types'; import axios, { AxiosInstance, AxiosRequestConfig, AxiosResponse } from 'axios'; +import qs from 'qs'; export interface ActionParams { filterByTk?: any; @@ -37,9 +38,22 @@ export class APIClient { } else { this.axios = axios.create(instance); } + this.qsMiddleware(); this.authMiddleware(); } + qsMiddleware() { + this.axios.interceptors.request.use((config) => { + config.paramsSerializer = (params) => { + return qs.stringify(params, { + strictNullHandling: true, + arrayFormat: 'brackets', + }); + }; + return config; + }); + } + authMiddleware() { this.axios.interceptors.request.use((config) => { const token = localStorage.getItem(this.tokenKey); diff --git a/packages/client/src/collection-manager/action-hooks.ts b/packages/client/src/collection-manager/action-hooks.ts index 05e0fc769..8eb9822a5 100644 --- a/packages/client/src/collection-manager/action-hooks.ts +++ b/packages/client/src/collection-manager/action-hooks.ts @@ -79,11 +79,7 @@ export const useBulkDestroyAction = () => { return { async run() { await resource.destroy({ - filter: { - [targetKey]: { - $in: state?.selectedRowKeys || [], - }, - }, + filterByTk: state?.selectedRowKeys || [], }); setState?.({ selectedRowKeys: [] }); refresh(); diff --git a/packages/resourcer/src/utils.ts b/packages/resourcer/src/utils.ts index ebc7fdcc7..216aaad94 100644 --- a/packages/resourcer/src/utils.ts +++ b/packages/resourcer/src/utils.ts @@ -198,7 +198,7 @@ export function parseQuery(input: string): any { // 原始 query string 中如果一个键连等号“=”都没有可以被认为是 null 类型 strictNullHandling: true, // 逗号分隔转换为数组 - comma: true, + // comma: true, }); // filter 支持 json string if (typeof query.filter === 'string') {