提交 180dc642 编写于 作者: Q qiang

fix: 解决安卓 request 响应超时最大 3s 的问题

上级 c32e3c5c
......@@ -40,8 +40,9 @@ export function createRequestTaskById (requestTaskId, {
}
if (__uniConfig.crossDomain === true) {
headers['User-Agent'] = USER_AGENT
}
if (__uniConfig.networkTimeout.request) {
}
const timeout = __uniConfig.networkTimeout.request
if (timeout) {
abortTimeout = setTimeout(() => {
aborted = true
publishStateChange({
......@@ -50,14 +51,16 @@ export function createRequestTaskById (requestTaskId, {
statusCode: 0,
errMsg: 'timeout'
})
}, __uniConfig.networkTimeout.request)
}, timeout)
}
const options = {
method,
url,
// weex 官方文档有误,headers 类型实际 object,用 string 类型会无响应
headers,
type: 'text'
type: 'text',
// weex 官方文档未说明实际支持 timeout,单位:ms
timeout: timeout || 6e5
}
if (method !== 'GET') {
options.body = data
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册