From 39c2550b8c6341af935c2772aa6d0b1306cccf89 Mon Sep 17 00:00:00 2001 From: fxy060608 Date: Tue, 9 Apr 2019 16:20:37 +0800 Subject: [PATCH] =?UTF-8?q?fix(runtime):=20=E9=83=A8=E5=88=86=20api=20?= =?UTF-8?q?=E8=BF=94=E5=9B=9E=E5=AF=B9=E8=B1=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/uni-app-plus/dist/index.js | 16 ++++++++++++---- packages/uni-mp-weixin/dist/index.js | 16 ++++++++++++---- src/core/helpers/promise.js | 10 ++++++---- 3 files changed, 30 insertions(+), 12 deletions(-) diff --git a/packages/uni-app-plus/dist/index.js b/packages/uni-app-plus/dist/index.js index 378731553..a2f563911 100644 --- a/packages/uni-app-plus/dist/index.js +++ b/packages/uni-app-plus/dist/index.js @@ -44,6 +44,8 @@ const SYNC_API_RE = /requireNativePlugin|upx2px|hideKeyboard|canIUse|^create|Syn const CONTEXT_API_RE = /^create|Manager$/; +const TASK_APIS = ['request', 'downloadFile', 'uploadFile', 'connectSocket']; + const CALLBACK_API_RE = /^on/; function isContextApi (name) { @@ -57,6 +59,10 @@ function isCallbackApi (name) { return CALLBACK_API_RE.test(name) } +function isTaskApi (name) { + return TASK_APIS.indexOf(name) !== -1 +} + function handlePromise (promise) { return promise.then(data => { return [null, data] @@ -65,10 +71,12 @@ function handlePromise (promise) { } function shouldPromise (name) { - if (isSyncApi(name)) { - return false - } - if (isCallbackApi(name)) { + if ( + isContextApi(name) || + isSyncApi(name) || + isCallbackApi(name) || + isTaskApi(name) + ) { return false } return true diff --git a/packages/uni-mp-weixin/dist/index.js b/packages/uni-mp-weixin/dist/index.js index d79d68705..a14042120 100644 --- a/packages/uni-mp-weixin/dist/index.js +++ b/packages/uni-mp-weixin/dist/index.js @@ -44,6 +44,8 @@ const SYNC_API_RE = /requireNativePlugin|upx2px|hideKeyboard|canIUse|^create|Syn const CONTEXT_API_RE = /^create|Manager$/; +const TASK_APIS = ['request', 'downloadFile', 'uploadFile', 'connectSocket']; + const CALLBACK_API_RE = /^on/; function isContextApi (name) { @@ -57,6 +59,10 @@ function isCallbackApi (name) { return CALLBACK_API_RE.test(name) } +function isTaskApi (name) { + return TASK_APIS.indexOf(name) !== -1 +} + function handlePromise (promise) { return promise.then(data => { return [null, data] @@ -65,10 +71,12 @@ function handlePromise (promise) { } function shouldPromise (name) { - if (isSyncApi(name)) { - return false - } - if (isCallbackApi(name)) { + if ( + isContextApi(name) || + isSyncApi(name) || + isCallbackApi(name) || + isTaskApi(name) + ) { return false } return true diff --git a/src/core/helpers/promise.js b/src/core/helpers/promise.js index 687b6655b..05fecf823 100644 --- a/src/core/helpers/promise.js +++ b/src/core/helpers/promise.js @@ -33,10 +33,12 @@ function handlePromise (promise) { } export function shouldPromise (name) { - if (isSyncApi(name)) { - return false - } - if (isCallbackApi(name)) { + if ( + isContextApi(name) || + isSyncApi(name) || + isCallbackApi(name) || + isTaskApi(name) + ) { return false } return true -- GitLab