Skip to content

Commit

Permalink
requestBody 不作为强制排除,仅提示
Browse files Browse the repository at this point in the history
  • Loading branch information
Manweill committed Feb 26, 2024
1 parent 6ae8270 commit 2ab1441
Showing 1 changed file with 13 additions and 14 deletions.
27 changes: 13 additions & 14 deletions src/templates/template.ts
Original file line number Diff line number Diff line change
Expand Up @@ -239,23 +239,22 @@ ${options.useStaticMethod ? 'static' : ''} ${camelcase(

function requestBodyString(method: string, parsedParameters: [], bodyParameter: [], requestBody: string, contentType: string, formData: string) {
if (parsedParameters && bodyParameter && bodyParameter.length > 0 || !!requestBody) {
if (method === 'post' || method === 'put') {
return `

const tips = `/** 适配移动开发(iOS13 等版本),只有 POST、PUT 等请求允许带body */ \n
console.warn('适配移动开发(iOS13 等版本),只有 POST、PUT 等请求允许带body')`
return `
${method === 'post' || method === 'put' ? '' : tips}
let data = ${parsedParameters && bodyParameter && bodyParameter.length > 0
?
bodyParameter
: !!requestBody
? 'params.body'
: 'null'
}
?
bodyParameter
: !!requestBody
? 'params.body'
: 'null'
}
${contentType === 'multipart/form-data' ? formData : ''}
configs.data = data;`
}
else {
return `/** 适配移动开发(iOS13 等版本),只有 POST、PUT 等请求允许带body */ \n
console.warn('适配移动开发(iOS13 等版本),只有 POST、PUT 等请求允许带body')
`
}
}
return ''
}
Expand Down

0 comments on commit 2ab1441

Please sign in to comment.