chore: api 支持 forceAppendDataToQuery 配置 (#3824)

This commit is contained in:
liaoxuezhi 2022-03-22 18:52:17 +08:00 committed by GitHub
parent e1979aec2d
commit 7fdf80aadd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 3 deletions

View File

@ -599,6 +599,13 @@ export interface SchemaApiObject {
*/
cache?: number;
/**
* query api crud
* query
*
*/
forceAppendDataToQuery?: boolean;
/**
* qs
*/

View File

@ -135,13 +135,15 @@ export function buildApi(
// get 类请求,把 data 附带到 url 上。
if (api.method === 'get' || api.method === 'jsonp') {
if (!~raw.indexOf('$') && !api.data && autoAppend) {
if (
!api.data &&
((!~raw.indexOf('$') && autoAppend) || api.forceAppendDataToQuery)
) {
api.query = api.data = data;
} else if (
api.attachDataToQuery === false &&
api.data &&
!~raw.indexOf('$') &&
autoAppend
((!~raw.indexOf('$') && autoAppend) || api.forceAppendDataToQuery)
) {
const idx = api.url.indexOf('?');
if (~idx) {