Skip to content

Commit

Permalink
chore: 优化判断顺序
Browse files Browse the repository at this point in the history
  • Loading branch information
Manweill committed Jan 23, 2024
1 parent ba62651 commit c0d71c7
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions src/templates/template.ts
Original file line number Diff line number Diff line change
Expand Up @@ -238,23 +238,23 @@ ${options.useStaticMethod ? 'static' : ''} ${camelcase(
}

function requestBodyString(method: string, parsedParameters: [], bodyParameter: [], requestBody: string, contentType: string, formData: string) {
if (method === 'post' || method === 'put') {
return `
if (parsedParameters && bodyParameter && bodyParameter.length > 0 || !!requestBody) {
if (method === 'post' || method === 'put') {
return `
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 {
if (bodyParameter && bodyParameter.length > 0 || !!requestBody) {
}
else {
return `/** 适配移动开发(iOS13 等版本),只有 POST、PUT 等请求允许带body */ \n
console.warn('适配移动开发(iOS13 等版本),只有 POST、PUT 等请求允许带body')
`
console.warn('适配移动开发(iOS13 等版本),只有 POST、PUT 等请求允许带body')
`
}
}
}
Expand Down

0 comments on commit c0d71c7

Please sign in to comment.