From f764713903c48c4e5777b9db0b2e0fffd7b69a4c Mon Sep 17 00:00:00 2001 From: fxy060608 Date: Wed, 17 Jun 2020 13:37:16 +0800 Subject: [PATCH] feat(v3): preload --- packages/uni-app-plus/dist/index.v3.js | 28 ++++++++++++++----- .../service/framework/plugins/index.js | 16 ++++++++++- 2 files changed, 36 insertions(+), 8 deletions(-) diff --git a/packages/uni-app-plus/dist/index.v3.js b/packages/uni-app-plus/dist/index.v3.js index 157975fb9..d5650ab40 100644 --- a/packages/uni-app-plus/dist/index.v3.js +++ b/packages/uni-app-plus/dist/index.v3.js @@ -12139,32 +12139,32 @@ var serviceContext = (function () { this.id = uploadTaskId; this._callbackId = callbackId; this._callbacks = []; - } + } abort () { - invokeMethod('operateRequestTask', { + invokeMethod('operateUploadTask', { uploadTaskId: this.id, operationType: 'abort' }); - } + } onProgressUpdate (callback) { if (typeof callback !== 'function') { return } this._callbacks.push(callback); - } + } onHeadersReceived () { - } + } offProgressUpdate (callback) { const index = this._callbacks.indexOf(callback); if (index >= 0) { this._callbacks.splice(index, 1); } - } + } offHeadersReceived () { @@ -12206,7 +12206,7 @@ var serviceContext = (function () { errMsg: 'request:fail ' + errMsg }); // eslint-disable-next-line no-fallthrough - default: + default: // progressUpdate 可能晚于 success setTimeout(() => { delete uploadTasks$1[uploadTaskId]; @@ -14208,6 +14208,20 @@ var serviceContext = (function () { Vue.prototype.$mount = function mount (el, hydrating) { if (this.mpType === 'app') { this.$options.render = function () {}; + if (weex.config.preload) { // preload + if (process.env.NODE_ENV !== 'production') { + console.log('[uni-app] preload app-service.js'); + } + const globalEvent = weex.requireModule('globalEvent'); + globalEvent.addEventListener('launchApp', () => { + if (process.env.NODE_ENV !== 'production') { + console.log('[uni-app] launchApp'); + } + registerApp(this); + oldMount.call(this, el, hydrating); + }); + return + } registerApp(this); } return oldMount.call(this, el, hydrating) diff --git a/src/platforms/app-plus/service/framework/plugins/index.js b/src/platforms/app-plus/service/framework/plugins/index.js index be12a01a9..070f83497 100644 --- a/src/platforms/app-plus/service/framework/plugins/index.js +++ b/src/platforms/app-plus/service/framework/plugins/index.js @@ -47,6 +47,20 @@ export default { Vue.prototype.$mount = function mount (el, hydrating) { if (this.mpType === 'app') { this.$options.render = function () {} + if (weex.config.preload) { // preload + if (process.env.NODE_ENV !== 'production') { + console.log('[uni-app] preload app-service.js') + } + const globalEvent = weex.requireModule('globalEvent') + globalEvent.addEventListener('launchApp', () => { + if (process.env.NODE_ENV !== 'production') { + console.log('[uni-app] launchApp') + } + registerApp(this) + oldMount.call(this, el, hydrating) + }) + return + } registerApp(this) } return oldMount.call(this, el, hydrating) @@ -70,4 +84,4 @@ export default { return callback ? undefined : result } } -} +} -- GitLab