From 6db473793a4d284a372db84c954a34829e5d0127 Mon Sep 17 00:00:00 2001 From: yandadaFreedom <525966780@qq.com> Date: Tue, 25 Jul 2023 21:48:22 +0800 Subject: [PATCH 1/5] =?UTF-8?q?feat:=20=E7=BB=9F=E4=B8=80api-proxy?= =?UTF-8?q?=E8=BF=94=E5=9B=9E=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/api-proxy/src/index.web.js | 15 ++- packages/api-proxy/src/mini/promisify.js | 1 + .../src/web/api/action-sheet/ActionSheet.js | 4 - packages/api-proxy/src/web/api/modal/Modal.js | 9 +- .../api-proxy/src/web/api/pull-down/index.js | 36 ++--- packages/api-proxy/src/web/api/route/index.js | 127 ++++++++---------- .../src/web/api/socket/SocketTask.js | 8 -- .../api-proxy/src/web/api/storage/index.js | 7 - .../api-proxy/src/web/api/system/index.js | 1 - .../api-proxy/src/web/api/tab-bar/index.js | 20 ++- packages/api-proxy/src/web/api/toast/Toast.js | 2 - 11 files changed, 90 insertions(+), 140 deletions(-) diff --git a/packages/api-proxy/src/index.web.js b/packages/api-proxy/src/index.web.js index 837b69ca35..457ce5ebc7 100644 --- a/packages/api-proxy/src/index.web.js +++ b/packages/api-proxy/src/index.web.js @@ -1,10 +1,17 @@ import * as allApi from './web/api' +import promisify from './mini/promisify' import { genFromMap } from './common/js' -export default function install (target) { +export default function install (target, options = {}) { + const { + usePromise = false, // 是否转为 promise 格式 + whiteList = [], // 强制变成 promise 格式的 api + blackList = [] // 强制不变成 promise 格式的 api + } = options const fromMap = genFromMap() - - Object.keys(allApi).forEach(api => { + const promisedApi = usePromise ? promisify(allApi, whiteList, blackList) : {} + const finalApi = Object.assign({}, allApi, promisedApi) + Object.keys(finalApi).forEach(api => { target[api] = function (...args) { if (args.length > 0) { const from = args.pop() @@ -13,7 +20,7 @@ export default function install (target) { } } - return allApi[api].apply(target, args) + return finalApi[api].apply(target, args) } }) } diff --git a/packages/api-proxy/src/mini/promisify.js b/packages/api-proxy/src/mini/promisify.js index 3f909812fd..9b07e09fd3 100644 --- a/packages/api-proxy/src/mini/promisify.js +++ b/packages/api-proxy/src/mini/promisify.js @@ -21,6 +21,7 @@ const blackList = [ 'createSelectorQuery', 'createIntersectionObserver', 'hideKeyboard', + // todo 小程序支持 promise 风格调用 'stopPullDownRefresh', 'createWorker', 'pageScrollTo', diff --git a/packages/api-proxy/src/web/api/action-sheet/ActionSheet.js b/packages/api-proxy/src/web/api/action-sheet/ActionSheet.js index 478d4f36d8..e32e614463 100644 --- a/packages/api-proxy/src/web/api/action-sheet/ActionSheet.js +++ b/packages/api-proxy/src/web/api/action-sheet/ActionSheet.js @@ -64,7 +64,6 @@ export default class ActionSheet extends ToPromise { tapIndex: index } webHandleSuccess(res, opts.success, opts.complete) - this.toPromiseResolve(res) } list.appendChild(sheet) }) @@ -77,13 +76,10 @@ export default class ActionSheet extends ToPromise { this.hide() const err = { errMsg: 'showActionSheet:fail cancel' } webHandleFail(err, opts.fail, opts.complete) - !opts.fail && this.toPromiseReject(err) } this.box.classList.add('show') this.actionSheet.classList.add('show') - - return this.toPromiseInitPromise() } hide () { diff --git a/packages/api-proxy/src/web/api/modal/Modal.js b/packages/api-proxy/src/web/api/modal/Modal.js index cccf033829..0128420552 100644 --- a/packages/api-proxy/src/web/api/modal/Modal.js +++ b/packages/api-proxy/src/web/api/modal/Modal.js @@ -1,4 +1,4 @@ -import { ToPromise, webHandleSuccess } from '../../../common/js' +import { webHandleSuccess } from '../../../common/js' import '../../../common/stylus/Modal.styl' // import { forEach } from '@didi/mpx-fetch/src/util' // 汉字为两个字符,字母/数字为一个字符 @@ -13,9 +13,8 @@ const _getLength = (t) => { } return len } -export default class Modal extends ToPromise { +export default class Modal { constructor () { - super() this.defaultOpts = { title: '', content: '', @@ -110,7 +109,6 @@ export default class Modal extends ToPromise { confirm: false } webHandleSuccess(result, opts.success, opts.complete) - this.toPromiseResolve(result) } this.confirmBtn.onclick = () => { this.hide() @@ -120,12 +118,9 @@ export default class Modal extends ToPromise { confirm: true } webHandleSuccess(result, opts.success, opts.complete) - this.toPromiseResolve(result) } this.modal.classList.add('show') - - return this.toPromiseInitPromise() } hide () { diff --git a/packages/api-proxy/src/web/api/pull-down/index.js b/packages/api-proxy/src/web/api/pull-down/index.js index 4605bccaf0..98f7a79cd2 100644 --- a/packages/api-proxy/src/web/api/pull-down/index.js +++ b/packages/api-proxy/src/web/api/pull-down/index.js @@ -20,17 +20,13 @@ function stopPullDownRefresh (options = {}) { } } } - return new Promise((resolve, reject) => { - if (err) { - const res = { errMsg: `stopPullDownRefresh:fail ${err}` } - webHandleFail(res, options.fail, options.complete) - reject(res) - } else { - const res = { errMsg: 'stopPullDownRefresh:ok' } - webHandleSuccess(res, options.success, options.complete) - resolve(res) - } - }) + if (err) { + const res = { errMsg: `stopPullDownRefresh:fail ${err}` } + webHandleFail(res, options.fail, options.complete) + } else { + const res = { errMsg: 'stopPullDownRefresh:ok' } + webHandleSuccess(res, options.success, options.complete) + } } } @@ -54,17 +50,13 @@ function startPullDownRefresh (options = {}) { } } } - return new Promise((resolve, reject) => { - if (err) { - const res = { errMsg: `startPullDownRefresh:fail ${err}` } - webHandleFail(res, options.fail, options.complete) - reject(res) - } else { - const res = { errMsg: 'startPullDownRefresh:ok' } - webHandleSuccess(res, options.success, options.complete) - resolve(res) - } - }) + if (err) { + const res = { errMsg: `startPullDownRefresh:fail ${err}` } + webHandleFail(res, options.fail, options.complete) + } else { + const res = { errMsg: 'startPullDownRefresh:ok' } + webHandleSuccess(res, options.success, options.complete) + } } } diff --git a/packages/api-proxy/src/web/api/route/index.js b/packages/api-proxy/src/web/api/route/index.js index b85a636036..b9a1c64cfa 100644 --- a/packages/api-proxy/src/web/api/route/index.js +++ b/packages/api-proxy/src/web/api/route/index.js @@ -13,23 +13,19 @@ function redirectTo (options = {}) { return Promise.reject(res) } router.__mpxAction = { type: 'redirect' } - return new Promise((resolve, reject) => { - router.replace( - { - path: options.url - }, - () => { - const res = { errMsg: 'redirectTo:ok' } - webHandleSuccess(res, options.success, options.complete) - resolve(res) - }, - err => { - const res = { errMsg: `redirectTo:fail ${err}` } - webHandleFail(res, options.fail, options.complete) - reject(res) - } - ) - }) + router.replace( + { + path: options.url + }, + () => { + const res = { errMsg: 'redirectTo:ok' } + webHandleSuccess(res, options.success, options.complete) + }, + err => { + const res = { errMsg: `redirectTo:fail ${err}` } + webHandleFail(res, options.fail, options.complete) + } + ) } } @@ -53,23 +49,19 @@ function navigateTo (options = {}) { if (options.events) { eventChannel._addListeners(options.events) } - return new Promise((resolve, reject) => { - router.push( - { - path: options.url - }, - () => { - const res = { errMsg: 'navigateTo:ok', eventChannel } - webHandleSuccess(res, options.success, options.complete) - resolve(res) - }, - err => { - const res = { errMsg: err } - webHandleFail(res, options.fail, options.complete) - reject(res) - } - ) - }) + router.push( + { + path: options.url + }, + () => { + const res = { errMsg: 'navigateTo:ok', eventChannel } + webHandleSuccess(res, options.success, options.complete) + }, + err => { + const res = { errMsg: err } + webHandleFail(res, options.fail, options.complete) + } + ) } } @@ -88,7 +80,6 @@ function navigateBack (options = {}) { router.go(-delta) const res = { errMsg: 'navigateBack:ok' } webHandleSuccess(res, options.success, options.complete) - return Promise.resolve(res) } } @@ -114,30 +105,25 @@ function reLaunch (options = {}) { router.go(-delta) } else { router.__mpxAction.replaced = true - return new Promise((resolve, reject) => { - router.replace( - { - path: options.url, - query: { - reLaunchCount - } - }, - () => { - const res = { errMsg: 'reLaunch:ok' } - webHandleSuccess(res, options.success, options.complete) - resolve(res) - }, - err => { - const res = { errMsg: err } - webHandleFail(res, options.fail, options.complete) - !options.fail && reject(res) + router.replace( + { + path: options.url, + query: { + reLaunchCount } - ) - }) + }, + () => { + const res = { errMsg: 'reLaunch:ok' } + webHandleSuccess(res, options.success, options.complete) + }, + err => { + const res = { errMsg: err } + webHandleFail(res, options.fail, options.complete) + } + ) } const res = { errMsg: 'reLaunch:ok' } webHandleSuccess(res, options.success, options.complete) - return Promise.resolve(res) } } @@ -166,28 +152,23 @@ function switchTab (options = {}) { router.go(-delta) } else { router.__mpxAction.replaced = true - return new Promise((resolve, reject) => { - router.replace( - { - path: options.url - }, - () => { - const res = { errMsg: 'switchTab:ok' } - webHandleSuccess(res, options.success, options.complete) - resolve(res) - }, - err => { - const res = { errMsg: err } - webHandleFail(res, options.fail, options.complete) - !options.fail && reject(res) - } - ) - }) + router.replace( + { + path: options.url + }, + () => { + const res = { errMsg: 'switchTab:ok' } + webHandleSuccess(res, options.success, options.complete) + }, + err => { + const res = { errMsg: err } + webHandleFail(res, options.fail, options.complete) + } + ) } } const res = { errMsg: 'switchTab:ok' } webHandleSuccess(res, options.success, options.complete) - return Promise.resolve(res) } } diff --git a/packages/api-proxy/src/web/api/socket/SocketTask.js b/packages/api-proxy/src/web/api/socket/SocketTask.js index 512b537f86..52ac6d1aa3 100644 --- a/packages/api-proxy/src/web/api/socket/SocketTask.js +++ b/packages/api-proxy/src/web/api/socket/SocketTask.js @@ -46,13 +46,9 @@ class SocketTask { this._socket.send(data) const res = { errMsg: 'sendSocketMessage:ok' } webHandleSuccess(res, success, complete) - return Promise.resolve(res) } else { const res = { errMsg: 'sendSocketMessage:fail' } webHandleFail(res, fail, complete) - if (!fail) { - return Promise.reject(res) - } } } @@ -66,13 +62,9 @@ class SocketTask { this._socket.close() const res = { errMsg: 'closeSocket:ok' } webHandleSuccess(res, success, complete) - return Promise.resolve(res) } catch (err) { const res = { errMsg: `closeSocket:fail ${err}` } webHandleFail(res, fail, complete) - if (!fail) { - return Promise.reject(res) - } } } diff --git a/packages/api-proxy/src/web/api/storage/index.js b/packages/api-proxy/src/web/api/storage/index.js index 66d4b09eaa..1c136ae88d 100644 --- a/packages/api-proxy/src/web/api/storage/index.js +++ b/packages/api-proxy/src/web/api/storage/index.js @@ -46,11 +46,9 @@ function getStorage (options = {}) { if (result) { const res = { errMsg: 'getStorage:ok', data: data } webHandleSuccess(res, success, complete) - return Promise.resolve(res) } else { const res = { errMsg: 'getStorage:fail', data: null } webHandleFail(res, fail, complete) - return Promise.reject(res) } } @@ -95,7 +93,6 @@ function getStorageInfo (options = {}) { } catch (err) { const res = { errMsg: `getStorageInfo:fail ${err}` } webHandleFail(res, fail, complete) - return Promise.reject(res) } } @@ -123,11 +120,9 @@ function removeStorage (options = { key: '' }) { const res = { errMsg: 'removeStorage:ok' } webHandleSuccess(res, success, complete) - return Promise.resolve(res) } catch (err) { const res = { errMsg: `removeStorage:fail ${err}` } webHandleFail(res, fail, complete) - return Promise.reject(res) } } @@ -151,11 +146,9 @@ function clearStorage (options = {}) { const res = { errMsg: 'clearStorage:ok' } webHandleSuccess(res, success, complete) - return Promise.resolve(res) } catch (err) { const res = { errMsg: `clearStorage:fail ${err}` } webHandleFail(res, fail, complete) - return Promise.reject(res) } } diff --git a/packages/api-proxy/src/web/api/system/index.js b/packages/api-proxy/src/web/api/system/index.js index eab97bc4fd..a7b708550f 100644 --- a/packages/api-proxy/src/web/api/system/index.js +++ b/packages/api-proxy/src/web/api/system/index.js @@ -77,7 +77,6 @@ function getSystemInfo (options = {}) { const info = getSystemInfoSync() const res = Object.assign({ errMsg: 'getSystemInfo:ok' }, info) webHandleSuccess(res, options.success, options.complete) - return Promise.resolve(res) } export { diff --git a/packages/api-proxy/src/web/api/tab-bar/index.js b/packages/api-proxy/src/web/api/tab-bar/index.js index 199912f269..3e9db8b221 100644 --- a/packages/api-proxy/src/web/api/tab-bar/index.js +++ b/packages/api-proxy/src/web/api/tab-bar/index.js @@ -21,10 +21,9 @@ function setTabBarStyle (options = {}) { if (resolved) { webHandleSuccess(resolved, options.success, options.complete) - return Promise.resolve(resolved) + } else { + webHandleFail(rejected, options.fail, options.complete) } - webHandleFail(rejected, options.fail, options.complete) - return Promise.reject(rejected) } function setTabBarItem (options = {}) { @@ -52,10 +51,9 @@ function setTabBarItem (options = {}) { if (resolved) { webHandleSuccess(resolved, options.success, options.complete) - return Promise.resolve(resolved) + } else { + webHandleFail(rejected, options.fail, options.complete) } - webHandleFail(rejected, options.fail, options.complete) - return Promise.reject(rejected) } function showTabBar (options = {}) { @@ -70,10 +68,9 @@ function showTabBar (options = {}) { if (resolved) { webHandleSuccess(resolved, options.success, options.complete) - return Promise.resolve(resolved) + } else { + webHandleFail(rejected, options.fail, options.complete) } - webHandleFail(rejected, options.fail, options.complete) - return Promise.reject(rejected) } function hideTabBar (options = {}) { @@ -88,10 +85,9 @@ function hideTabBar (options = {}) { if (resolved) { webHandleSuccess(resolved, options.success, options.complete) - return Promise.resolve(resolved) + } else { + webHandleFail(rejected, options.fail, options.complete) } - webHandleFail(rejected, options.fail, options.complete) - return Promise.reject(rejected) } export { diff --git a/packages/api-proxy/src/web/api/toast/Toast.js b/packages/api-proxy/src/web/api/toast/Toast.js index 988d5863dd..66a712572d 100644 --- a/packages/api-proxy/src/web/api/toast/Toast.js +++ b/packages/api-proxy/src/web/api/toast/Toast.js @@ -84,7 +84,6 @@ export default class Toast { const errMsg = type === 'loading' ? 'showLoading:ok' : 'showToast:ok' webHandleSuccess({ errMsg }, opts.success, opts.complete) - return Promise.resolve({ errMsg }) } hide (options = {}, type) { @@ -100,6 +99,5 @@ export default class Toast { } this.hideTimer = setTimeout(() => { this.toast.classList.remove('show') }, duration) - return Promise.resolve({ errMsg }) } } From e99e068277030b97bc9952b4b78e7fcfd600819a Mon Sep 17 00:00:00 2001 From: yandadaFreedom <525966780@qq.com> Date: Wed, 26 Jul 2023 20:16:03 +0800 Subject: [PATCH 2/5] =?UTF-8?q?feat:=20request=20=E8=BF=94=E5=9B=9E?= =?UTF-8?q?=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/api-proxy/src/web/api/request/index.js | 6 ++---- packages/api-proxy/src/web/api/socket/SocketTask.js | 8 ++++++++ 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/packages/api-proxy/src/web/api/request/index.js b/packages/api-proxy/src/web/api/request/index.js index 28f3c43cfc..a91a265a2d 100644 --- a/packages/api-proxy/src/web/api/request/index.js +++ b/packages/api-proxy/src/web/api/request/index.js @@ -47,7 +47,7 @@ function request (options = { url: '' }) { delete rOptions.data } - const promise = axios(rOptions).then(res => { + axios(rOptions).then(res => { let data = res.data if (responseType === 'text' && dataType === 'json') { try { @@ -70,9 +70,7 @@ function request (options = { url: '' }) { return Promise.reject(res) } }) - - promise.__returned = requestTask - return promise + return requestTask } export { diff --git a/packages/api-proxy/src/web/api/socket/SocketTask.js b/packages/api-proxy/src/web/api/socket/SocketTask.js index 52ac6d1aa3..512b537f86 100644 --- a/packages/api-proxy/src/web/api/socket/SocketTask.js +++ b/packages/api-proxy/src/web/api/socket/SocketTask.js @@ -46,9 +46,13 @@ class SocketTask { this._socket.send(data) const res = { errMsg: 'sendSocketMessage:ok' } webHandleSuccess(res, success, complete) + return Promise.resolve(res) } else { const res = { errMsg: 'sendSocketMessage:fail' } webHandleFail(res, fail, complete) + if (!fail) { + return Promise.reject(res) + } } } @@ -62,9 +66,13 @@ class SocketTask { this._socket.close() const res = { errMsg: 'closeSocket:ok' } webHandleSuccess(res, success, complete) + return Promise.resolve(res) } catch (err) { const res = { errMsg: `closeSocket:fail ${err}` } webHandleFail(res, fail, complete) + if (!fail) { + return Promise.reject(res) + } } } From 3d3ea0fbe19bee3e03f6873c7985fa5bae2da266 Mon Sep 17 00:00:00 2001 From: yandadaFreedom <525966780@qq.com> Date: Thu, 27 Jul 2023 15:09:36 +0800 Subject: [PATCH 3/5] =?UTF-8?q?chore:=20=E7=BB=9F=E4=B8=80=E8=A7=84?= =?UTF-8?q?=E8=8C=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/api-proxy/src/index.web.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/api-proxy/src/index.web.js b/packages/api-proxy/src/index.web.js index 457ce5ebc7..8e39f27a19 100644 --- a/packages/api-proxy/src/index.web.js +++ b/packages/api-proxy/src/index.web.js @@ -1,4 +1,4 @@ -import * as allApi from './web/api' +import * as transedApi from './web/api' import promisify from './mini/promisify' import { genFromMap } from './common/js' @@ -9,9 +9,9 @@ export default function install (target, options = {}) { blackList = [] // 强制不变成 promise 格式的 api } = options const fromMap = genFromMap() - const promisedApi = usePromise ? promisify(allApi, whiteList, blackList) : {} - const finalApi = Object.assign({}, allApi, promisedApi) - Object.keys(finalApi).forEach(api => { + const promisedApi = usePromise ? promisify(transedApi, whiteList, blackList) : {} + const allApi = Object.assign({}, transedApi, promisedApi) + Object.keys(allApi).forEach(api => { target[api] = function (...args) { if (args.length > 0) { const from = args.pop() @@ -20,7 +20,7 @@ export default function install (target, options = {}) { } } - return finalApi[api].apply(target, args) + return allApi[api].apply(target, args) } }) } From f8d96b4c4e082c58dfef60cd35f2b0f82c699a2a Mon Sep 17 00:00:00 2001 From: yandadaFreedom <525966780@qq.com> Date: Thu, 24 Aug 2023 15:12:51 +0800 Subject: [PATCH 4/5] =?UTF-8?q?chore:=20=E4=BF=AE=E6=94=B9=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E5=BC=95=E7=94=A8=E8=B7=AF=E5=BE=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/api-proxy/__tests__/web/toast.spec.js | 2 +- packages/api-proxy/src/{mini => common/js}/promisify.js | 2 +- packages/api-proxy/src/index.js | 2 +- packages/api-proxy/src/index.web.js | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) rename packages/api-proxy/src/{mini => common/js}/promisify.js (97%) diff --git a/packages/api-proxy/__tests__/web/toast.spec.js b/packages/api-proxy/__tests__/web/toast.spec.js index a7a88a2c10..6b6ecba7d3 100644 --- a/packages/api-proxy/__tests__/web/toast.spec.js +++ b/packages/api-proxy/__tests__/web/toast.spec.js @@ -1,7 +1,7 @@ import '@testing-library/jest-dom/extend-expect' import { showToast, hideToast -} from '../../src/web/api//toast/index' +} from '../../src/web/api/toast/index' describe('test toast', () => { afterAll(() => { diff --git a/packages/api-proxy/src/mini/promisify.js b/packages/api-proxy/src/common/js/promisify.js similarity index 97% rename from packages/api-proxy/src/mini/promisify.js rename to packages/api-proxy/src/common/js/promisify.js index 9b07e09fd3..efb74d4f35 100644 --- a/packages/api-proxy/src/mini/promisify.js +++ b/packages/api-proxy/src/common/js/promisify.js @@ -1,4 +1,4 @@ -import { genFromMap, getEnvObj, noop } from '../common/js' +import { genFromMap, getEnvObj, noop } from './utils' const envObj = getEnvObj() diff --git a/packages/api-proxy/src/index.js b/packages/api-proxy/src/index.js index b7cc5ea817..9c93c0972d 100644 --- a/packages/api-proxy/src/index.js +++ b/packages/api-proxy/src/index.js @@ -1,5 +1,5 @@ import transformApi from './mini/transform' -import promisify from './mini/promisify' +import promisify from './common/js/promisify' export default function install (target, options = {}) { const { diff --git a/packages/api-proxy/src/index.web.js b/packages/api-proxy/src/index.web.js index 8e39f27a19..4f6b40e9b9 100644 --- a/packages/api-proxy/src/index.web.js +++ b/packages/api-proxy/src/index.web.js @@ -1,5 +1,5 @@ import * as transedApi from './web/api' -import promisify from './mini/promisify' +import promisify from './common/js/promisify' import { genFromMap } from './common/js' export default function install (target, options = {}) { From 0bdcc362526dcc82ece6a5d303bc8a9797977361 Mon Sep 17 00:00:00 2001 From: yandadaFreedom <525966780@qq.com> Date: Thu, 24 Aug 2023 15:26:28 +0800 Subject: [PATCH 5/5] =?UTF-8?q?chore:=20=E4=BF=AE=E6=94=B9=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E5=BC=95=E7=94=A8=E8=B7=AF=E5=BE=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/api-proxy/src/common/js/index.js | 1 + packages/api-proxy/src/common/js/promisify.js | 4 +++- packages/api-proxy/src/index.js | 2 +- packages/api-proxy/src/index.web.js | 3 +-- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/packages/api-proxy/src/common/js/index.js b/packages/api-proxy/src/common/js/index.js index bf7227ce40..b1b579d20d 100644 --- a/packages/api-proxy/src/common/js/index.js +++ b/packages/api-proxy/src/common/js/index.js @@ -1,3 +1,4 @@ export * from './ToPromise' export * from './web' export * from './utils' +export * from './promisify' diff --git a/packages/api-proxy/src/common/js/promisify.js b/packages/api-proxy/src/common/js/promisify.js index efb74d4f35..29816ef4e8 100644 --- a/packages/api-proxy/src/common/js/promisify.js +++ b/packages/api-proxy/src/common/js/promisify.js @@ -97,4 +97,6 @@ function promisify (listObj, whiteList, customBlackList) { return result } -export default promisify +export { + promisify +} diff --git a/packages/api-proxy/src/index.js b/packages/api-proxy/src/index.js index 9c93c0972d..22f6c90173 100644 --- a/packages/api-proxy/src/index.js +++ b/packages/api-proxy/src/index.js @@ -1,5 +1,5 @@ import transformApi from './mini/transform' -import promisify from './common/js/promisify' +import { promisify } from './common/js' export default function install (target, options = {}) { const { diff --git a/packages/api-proxy/src/index.web.js b/packages/api-proxy/src/index.web.js index 4f6b40e9b9..1fdbd73414 100644 --- a/packages/api-proxy/src/index.web.js +++ b/packages/api-proxy/src/index.web.js @@ -1,6 +1,5 @@ import * as transedApi from './web/api' -import promisify from './common/js/promisify' -import { genFromMap } from './common/js' +import { promisify, genFromMap } from './common/js' export default function install (target, options = {}) { const {