Skip to content

Commit

Permalink
fix tips with form-data
Browse files Browse the repository at this point in the history
  • Loading branch information
Manweill committed Mar 15, 2024
1 parent 6956938 commit 275e523
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions src/templates/template.ts
Original file line number Diff line number Diff line change
Expand Up @@ -238,21 +238,23 @@ ${options.useStaticMethod ? 'static' : ''} ${camelcase(
}

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

/** serviceTemplate */
Expand Down

0 comments on commit 275e523

Please sign in to comment.