diff --git a/packages/uni-mp-alipay/dist/uni.api.esm.js b/packages/uni-mp-alipay/dist/uni.api.esm.js index 70ac01eb5b6a2fc3756884de936444a51d11d4ad..cbee7b1c7791b415f9731daab3a502b5f3a2b751 100644 --- a/packages/uni-mp-alipay/dist/uni.api.esm.js +++ b/packages/uni-mp-alipay/dist/uni.api.esm.js @@ -1,4 +1,8 @@ import { isArray, hasOwn, isString, isPlainObject, isObject, capitalize, toRawType, makeMap, isPromise, isFunction, extend } from '@vue/shared'; +import { injectHook } from 'vue'; + +//App +const ON_LAUNCH = 'onLaunch'; const eventChannels = {}; const eventChannelStack = []; @@ -36,6 +40,15 @@ const navigateTo = { }, }; +my.appLaunchHooks = []; +function onAppLaunch(hook) { + const app = getApp({ allowDefault: true }); + if (app && app.$vm) { + return injectHook(ON_LAUNCH, hook, app.$vm.$); + } + my.appLaunchHooks.push(hook); +} + function getBaseSystemInfo() { return my.getSystemInfoSync() } @@ -722,6 +735,7 @@ const baseApis = { upx2px, addInterceptor, removeInterceptor, + onAppLaunch, }; function initUni(api, protocols) { const wrapper = initWrapper(protocols); @@ -882,14 +896,14 @@ function createIntersectionObserver(component, options) { } var shims = /*#__PURE__*/Object.freeze({ - __proto__: null, - getProvider: getProvider, - setStorageSync: setStorageSync, - getStorageSync: getStorageSync, - removeStorageSync: removeStorageSync, - startGyroscope: startGyroscope, - createSelectorQuery: createSelectorQuery, - createIntersectionObserver: createIntersectionObserver + __proto__: null, + getProvider: getProvider, + setStorageSync: setStorageSync, + getStorageSync: getStorageSync, + removeStorageSync: removeStorageSync, + startGyroscope: startGyroscope, + createSelectorQuery: createSelectorQuery, + createIntersectionObserver: createIntersectionObserver }); function handleNetworkInfo(fromRes, toRes) { @@ -1315,58 +1329,58 @@ const chooseAddress = { }; var protocols = /*#__PURE__*/Object.freeze({ - __proto__: null, - returnValue: returnValue, - request: request, - setNavigationBarColor: setNavigationBarColor, - setNavigationBarTitle: setNavigationBarTitle, - showModal: showModal, - showToast: showToast, - showActionSheet: showActionSheet, - showLoading: showLoading, - uploadFile: uploadFile, - downloadFile: downloadFile, - getFileInfo: getFileInfo, - compressImage: compressImage, - chooseVideo: chooseVideo, - connectSocket: connectSocket, - chooseImage: chooseImage, - previewImage: previewImage, - saveFile: saveFile, - getSavedFileInfo: getSavedFileInfo, - getSavedFileList: getSavedFileList, - removeSavedFile: removeSavedFile, - getLocation: getLocation, - openLocation: openLocation, - getNetworkType: getNetworkType, - onNetworkStatusChange: onNetworkStatusChange, - stopAccelerometer: stopAccelerometer, - stopCompass: stopCompass, - scanCode: scanCode, - setClipboardData: setClipboardData, - getClipboardData: getClipboardData, - pageScrollTo: pageScrollTo, - login: login, - getUserInfo: getUserInfo, - requestPayment: requestPayment, - getBLEDeviceServices: getBLEDeviceServices, - createBLEConnection: createBLEConnection, - closeBLEConnection: closeBLEConnection, - onBLEConnectionStateChange: onBLEConnectionStateChange, - makePhoneCall: makePhoneCall, - stopGyroscope: stopGyroscope, - getSystemInfo: getSystemInfo, - getSystemInfoSync: getSystemInfoSync, - canvasToTempFilePath: canvasToTempFilePath, - setScreenBrightness: setScreenBrightness, - getScreenBrightness: getScreenBrightness, - showShareMenu: showShareMenu, - hideHomeButton: hideHomeButton, - saveImageToPhotosAlbum: saveImageToPhotosAlbum, - saveVideoToPhotosAlbum: saveVideoToPhotosAlbum, - chooseAddress: chooseAddress, - redirectTo: redirectTo, - navigateTo: navigateTo + __proto__: null, + returnValue: returnValue, + request: request, + setNavigationBarColor: setNavigationBarColor, + setNavigationBarTitle: setNavigationBarTitle, + showModal: showModal, + showToast: showToast, + showActionSheet: showActionSheet, + showLoading: showLoading, + uploadFile: uploadFile, + downloadFile: downloadFile, + getFileInfo: getFileInfo, + compressImage: compressImage, + chooseVideo: chooseVideo, + connectSocket: connectSocket, + chooseImage: chooseImage, + previewImage: previewImage, + saveFile: saveFile, + getSavedFileInfo: getSavedFileInfo, + getSavedFileList: getSavedFileList, + removeSavedFile: removeSavedFile, + getLocation: getLocation, + openLocation: openLocation, + getNetworkType: getNetworkType, + onNetworkStatusChange: onNetworkStatusChange, + stopAccelerometer: stopAccelerometer, + stopCompass: stopCompass, + scanCode: scanCode, + setClipboardData: setClipboardData, + getClipboardData: getClipboardData, + pageScrollTo: pageScrollTo, + login: login, + getUserInfo: getUserInfo, + requestPayment: requestPayment, + getBLEDeviceServices: getBLEDeviceServices, + createBLEConnection: createBLEConnection, + closeBLEConnection: closeBLEConnection, + onBLEConnectionStateChange: onBLEConnectionStateChange, + makePhoneCall: makePhoneCall, + stopGyroscope: stopGyroscope, + getSystemInfo: getSystemInfo, + getSystemInfoSync: getSystemInfoSync, + canvasToTempFilePath: canvasToTempFilePath, + setScreenBrightness: setScreenBrightness, + getScreenBrightness: getScreenBrightness, + showShareMenu: showShareMenu, + hideHomeButton: hideHomeButton, + saveImageToPhotosAlbum: saveImageToPhotosAlbum, + saveVideoToPhotosAlbum: saveVideoToPhotosAlbum, + chooseAddress: chooseAddress, + redirectTo: redirectTo, + navigateTo: navigateTo }); var index = initUni(shims, protocols); diff --git a/packages/uni-mp-alipay/dist/uni.mp.esm.js b/packages/uni-mp-alipay/dist/uni.mp.esm.js index 3f22d256170fd544f8f52ba6baf2f7387d085922..6abd8712ead71555d457ef21f445928e69822e04 100644 --- a/packages/uni-mp-alipay/dist/uni.mp.esm.js +++ b/packages/uni-mp-alipay/dist/uni.mp.esm.js @@ -1,5 +1,5 @@ import { isPlainObject, isArray, extend, hyphenate, isObject, hasOwn, toNumber, capitalize, isFunction, NOOP, EMPTY_OBJ, camelize } from '@vue/shared'; -import { onUnmounted } from 'vue'; +import { onUnmounted, injectHook } from 'vue'; const encode = encodeURIComponent; function stringifyQuery(obj, encodeStr = encode) { @@ -476,7 +476,7 @@ function initScopedSlotsParams(instance) { const vueIds = instance.attrs.vueId; if (vueIds) { const vueId = vueIds.split(',')[0]; - const object = center[vueId] = center[vueId] || {}; + const object = (center[vueId] = center[vueId] || {}); object[name] = value; if (parents[vueId]) { parents[vueId].$forceUpdate(); @@ -542,6 +542,13 @@ function initUnknownHooks(mpOptions, vueOptions, excludes = EXCLUDE_HOOKS) { findHooks(vueOptions).forEach((hook) => initHook(mpOptions, hook, excludes)); } +my.appLaunchHooks = []; +function injectAppLaunchHooks(appInstance) { + my.appLaunchHooks.forEach((hook) => { + injectHook(ON_LAUNCH, hook, appInstance); + }); +} + const HOOKS = [ ON_SHOW, ON_HIDE, @@ -566,7 +573,9 @@ function parseApp(instance, parseAppOptions) { mpInstance: this, slots: [], }); + injectAppLaunchHooks(internalInstance); ctx.globalData = this.globalData; + options.app = this; instance.$callHook(ON_LAUNCH, options); }, }; diff --git a/packages/uni-mp-baidu/dist/uni.api.esm.js b/packages/uni-mp-baidu/dist/uni.api.esm.js index eb8b2d96185c84f1804493d29d62fe5061b428c0..d60c8db10911e460a176cdefa0cf33a1b63005d3 100644 --- a/packages/uni-mp-baidu/dist/uni.api.esm.js +++ b/packages/uni-mp-baidu/dist/uni.api.esm.js @@ -1,4 +1,8 @@ import { isArray, hasOwn, isString, isPlainObject, isObject, capitalize, toRawType, makeMap, isPromise, isFunction, extend } from '@vue/shared'; +import { injectHook } from 'vue'; + +//App +const ON_LAUNCH = 'onLaunch'; const eventChannels = {}; const eventChannelStack = []; @@ -36,6 +40,15 @@ const navigateTo = { }, }; +swan.appLaunchHooks = []; +function onAppLaunch(hook) { + const app = getApp({ allowDefault: true }); + if (app && app.$vm) { + return injectHook(ON_LAUNCH, hook, app.$vm.$); + } + swan.appLaunchHooks.push(hook); +} + function getBaseSystemInfo() { return swan.getSystemInfoSync() } @@ -722,6 +735,7 @@ const baseApis = { upx2px, addInterceptor, removeInterceptor, + onAppLaunch, }; function initUni(api, protocols) { const wrapper = initWrapper(protocols); @@ -847,9 +861,9 @@ function requestPayment(params) { } var shims = /*#__PURE__*/Object.freeze({ - __proto__: null, - getProvider: getProvider, - requestPayment: requestPayment + __proto__: null, + getProvider: getProvider, + requestPayment: requestPayment }); function createTodoMethod(contextName, methodName) { @@ -922,21 +936,21 @@ const getAccountInfoSync = { }; var protocols = /*#__PURE__*/Object.freeze({ - __proto__: null, - request: request, - connectSocket: connectSocket, - getRecorderManager: getRecorderManager, - getBackgroundAudioManager: getBackgroundAudioManager, - scanCode: scanCode, - navigateToMiniProgram: navigateToMiniProgram, - navigateBackMiniProgram: navigateBackMiniProgram, - showShareMenu: showShareMenu, - getAccountInfoSync: getAccountInfoSync, - redirectTo: redirectTo, - navigateTo: navigateTo, - previewImage: previewImage, - getSystemInfo: getSystemInfo, - getSystemInfoSync: getSystemInfoSync + __proto__: null, + request: request, + connectSocket: connectSocket, + getRecorderManager: getRecorderManager, + getBackgroundAudioManager: getBackgroundAudioManager, + scanCode: scanCode, + navigateToMiniProgram: navigateToMiniProgram, + navigateBackMiniProgram: navigateBackMiniProgram, + showShareMenu: showShareMenu, + getAccountInfoSync: getAccountInfoSync, + redirectTo: redirectTo, + navigateTo: navigateTo, + previewImage: previewImage, + getSystemInfo: getSystemInfo, + getSystemInfoSync: getSystemInfoSync }); var index = initUni(shims, protocols); diff --git a/packages/uni-mp-baidu/dist/uni.mp.esm.js b/packages/uni-mp-baidu/dist/uni.mp.esm.js index 20a90cbce4d924830fb3331837879321022370eb..3699e0cbe30e1d5b961c43bef16158ab43804408 100644 --- a/packages/uni-mp-baidu/dist/uni.mp.esm.js +++ b/packages/uni-mp-baidu/dist/uni.mp.esm.js @@ -1,5 +1,5 @@ import { isPlainObject, hasOwn, isArray, extend, hyphenate, isObject, toNumber, isFunction, NOOP, camelize } from '@vue/shared'; -import { onUnmounted } from 'vue'; +import { onUnmounted, injectHook } from 'vue'; const encode = encodeURIComponent; function stringifyQuery(obj, encodeStr = encode) { @@ -501,7 +501,7 @@ function initScopedSlotsParams(instance) { const vueIds = instance.attrs.vueId; if (vueIds) { const vueId = vueIds.split(',')[0]; - const object = center[vueId] = center[vueId] || {}; + const object = (center[vueId] = center[vueId] || {}); object[name] = value; if (parents[vueId]) { parents[vueId].$forceUpdate(); @@ -567,6 +567,13 @@ function initUnknownHooks(mpOptions, vueOptions, excludes = EXCLUDE_HOOKS) { findHooks(vueOptions).forEach((hook) => initHook$1(mpOptions, hook, excludes)); } +swan.appLaunchHooks = []; +function injectAppLaunchHooks(appInstance) { + swan.appLaunchHooks.forEach((hook) => { + injectHook(ON_LAUNCH, hook, appInstance); + }); +} + const HOOKS = [ ON_SHOW, ON_HIDE, @@ -591,7 +598,9 @@ function parseApp(instance, parseAppOptions) { mpInstance: this, slots: [], }); + injectAppLaunchHooks(internalInstance); ctx.globalData = this.globalData; + options.app = this; instance.$callHook(ON_LAUNCH, options); }, }; diff --git a/packages/uni-mp-kuaishou/dist/uni.api.esm.js b/packages/uni-mp-kuaishou/dist/uni.api.esm.js index a1d2da6ccb1188e0738edc5b2f45dbfb661b0cc3..a71abe19788af49d6b83156ca0e48259ae6d5bfe 100644 --- a/packages/uni-mp-kuaishou/dist/uni.api.esm.js +++ b/packages/uni-mp-kuaishou/dist/uni.api.esm.js @@ -1,4 +1,8 @@ import { isArray, hasOwn, isString, isPlainObject, isObject, capitalize, toRawType, makeMap, isPromise, isFunction, extend } from '@vue/shared'; +import { injectHook } from 'vue'; + +//App +const ON_LAUNCH = 'onLaunch'; const eventChannels = {}; const eventChannelStack = []; @@ -36,6 +40,15 @@ const navigateTo = { }, }; +ks.appLaunchHooks = []; +function onAppLaunch(hook) { + const app = getApp({ allowDefault: true }); + if (app && app.$vm) { + return injectHook(ON_LAUNCH, hook, app.$vm.$); + } + ks.appLaunchHooks.push(hook); +} + function getBaseSystemInfo() { return ks.getSystemInfoSync() } @@ -722,6 +735,7 @@ const baseApis = { upx2px, addInterceptor, removeInterceptor, + onAppLaunch, }; function initUni(api, protocols) { const wrapper = initWrapper(protocols); @@ -827,17 +841,17 @@ const getProvider = initGetProvider({ }); var shims = /*#__PURE__*/Object.freeze({ - __proto__: null, - getProvider: getProvider + __proto__: null, + getProvider: getProvider }); var protocols = /*#__PURE__*/Object.freeze({ - __proto__: null, - redirectTo: redirectTo, - navigateTo: navigateTo, - previewImage: previewImage, - getSystemInfo: getSystemInfo, - getSystemInfoSync: getSystemInfoSync + __proto__: null, + redirectTo: redirectTo, + navigateTo: navigateTo, + previewImage: previewImage, + getSystemInfo: getSystemInfo, + getSystemInfoSync: getSystemInfoSync }); var index = initUni(shims, protocols); diff --git a/packages/uni-mp-kuaishou/dist/uni.mp.esm.js b/packages/uni-mp-kuaishou/dist/uni.mp.esm.js index b1d3f97766cce8a8ff66658f731a724f23621796..adabcd52519bc9be63eff2c349affa9d6d01019c 100644 --- a/packages/uni-mp-kuaishou/dist/uni.mp.esm.js +++ b/packages/uni-mp-kuaishou/dist/uni.mp.esm.js @@ -1,5 +1,5 @@ import { isPlainObject, hasOwn, isArray, extend, hyphenate, isObject, toNumber, isFunction, NOOP, camelize } from '@vue/shared'; -import { onUnmounted } from 'vue'; +import { onUnmounted, injectHook } from 'vue'; const encode = encodeURIComponent; function stringifyQuery(obj, encodeStr = encode) { @@ -501,7 +501,7 @@ function initScopedSlotsParams(instance) { const vueIds = instance.attrs.vueId; if (vueIds) { const vueId = vueIds.split(',')[0]; - const object = center[vueId] = center[vueId] || {}; + const object = (center[vueId] = center[vueId] || {}); object[name] = value; if (parents[vueId]) { parents[vueId].$forceUpdate(); @@ -567,6 +567,13 @@ function initUnknownHooks(mpOptions, vueOptions, excludes = EXCLUDE_HOOKS) { findHooks(vueOptions).forEach((hook) => initHook$1(mpOptions, hook, excludes)); } +ks.appLaunchHooks = []; +function injectAppLaunchHooks(appInstance) { + ks.appLaunchHooks.forEach((hook) => { + injectHook(ON_LAUNCH, hook, appInstance); + }); +} + const HOOKS = [ ON_SHOW, ON_HIDE, @@ -591,7 +598,9 @@ function parseApp(instance, parseAppOptions) { mpInstance: this, slots: [], }); + injectAppLaunchHooks(internalInstance); ctx.globalData = this.globalData; + options.app = this; instance.$callHook(ON_LAUNCH, options); }, }; diff --git a/packages/uni-mp-qq/dist/uni.api.esm.js b/packages/uni-mp-qq/dist/uni.api.esm.js index 3a0dc8318edf0a97ddf500e0be10bcb00acab26c..6ee33ac8fabbf3bfbc3b7018e0193af230522a1e 100644 --- a/packages/uni-mp-qq/dist/uni.api.esm.js +++ b/packages/uni-mp-qq/dist/uni.api.esm.js @@ -1,4 +1,8 @@ import { isArray, hasOwn, isString, isPlainObject, isObject, capitalize, toRawType, makeMap, isPromise, isFunction, extend } from '@vue/shared'; +import { injectHook } from 'vue'; + +//App +const ON_LAUNCH = 'onLaunch'; const eventChannels = {}; const eventChannelStack = []; @@ -36,6 +40,15 @@ const navigateTo = { }, }; +qq.appLaunchHooks = []; +function onAppLaunch(hook) { + const app = getApp({ allowDefault: true }); + if (app && app.$vm) { + return injectHook(ON_LAUNCH, hook, app.$vm.$); + } + qq.appLaunchHooks.push(hook); +} + function getBaseSystemInfo() { return qq.getSystemInfoSync() } @@ -722,6 +735,7 @@ const baseApis = { upx2px, addInterceptor, removeInterceptor, + onAppLaunch, }; function initUni(api, protocols) { const wrapper = initWrapper(protocols); @@ -827,17 +841,17 @@ const getProvider = initGetProvider({ }); var shims = /*#__PURE__*/Object.freeze({ - __proto__: null, - getProvider: getProvider + __proto__: null, + getProvider: getProvider }); var protocols = /*#__PURE__*/Object.freeze({ - __proto__: null, - redirectTo: redirectTo, - navigateTo: navigateTo, - previewImage: previewImage, - getSystemInfo: getSystemInfo, - getSystemInfoSync: getSystemInfoSync + __proto__: null, + redirectTo: redirectTo, + navigateTo: navigateTo, + previewImage: previewImage, + getSystemInfo: getSystemInfo, + getSystemInfoSync: getSystemInfoSync }); var index = initUni(shims, protocols); diff --git a/packages/uni-mp-qq/dist/uni.mp.esm.js b/packages/uni-mp-qq/dist/uni.mp.esm.js index 05f4361200c710eb0487391164e813defabf82e9..cc518154a062ff8843f37d5863d2928829a50c7a 100644 --- a/packages/uni-mp-qq/dist/uni.mp.esm.js +++ b/packages/uni-mp-qq/dist/uni.mp.esm.js @@ -1,5 +1,5 @@ import { isPlainObject, hasOwn, isArray, extend, hyphenate, isObject, toNumber, isFunction, NOOP, camelize } from '@vue/shared'; -import { onUnmounted } from 'vue'; +import { onUnmounted, injectHook } from 'vue'; const encode = encodeURIComponent; function stringifyQuery(obj, encodeStr = encode) { @@ -501,7 +501,7 @@ function initScopedSlotsParams(instance) { const vueIds = instance.attrs.vueId; if (vueIds) { const vueId = vueIds.split(',')[0]; - const object = center[vueId] = center[vueId] || {}; + const object = (center[vueId] = center[vueId] || {}); object[name] = value; if (parents[vueId]) { parents[vueId].$forceUpdate(); @@ -567,6 +567,13 @@ function initUnknownHooks(mpOptions, vueOptions, excludes = EXCLUDE_HOOKS) { findHooks(vueOptions).forEach((hook) => initHook$1(mpOptions, hook, excludes)); } +qq.appLaunchHooks = []; +function injectAppLaunchHooks(appInstance) { + qq.appLaunchHooks.forEach((hook) => { + injectHook(ON_LAUNCH, hook, appInstance); + }); +} + const HOOKS = [ ON_SHOW, ON_HIDE, @@ -591,7 +598,9 @@ function parseApp(instance, parseAppOptions) { mpInstance: this, slots: [], }); + injectAppLaunchHooks(internalInstance); ctx.globalData = this.globalData; + options.app = this; instance.$callHook(ON_LAUNCH, options); }, }; diff --git a/packages/uni-mp-toutiao/dist/uni.api.esm.js b/packages/uni-mp-toutiao/dist/uni.api.esm.js index 1641db8f3c4e7b6ca76970a3effb1e5bf4482c15..758ac002d89bcab69f3aa9d501b5a8626c7f1ef9 100644 --- a/packages/uni-mp-toutiao/dist/uni.api.esm.js +++ b/packages/uni-mp-toutiao/dist/uni.api.esm.js @@ -1,4 +1,8 @@ import { isArray, hasOwn, isString, isPlainObject, isObject, capitalize, toRawType, makeMap, isPromise, isFunction, extend } from '@vue/shared'; +import { injectHook } from 'vue'; + +//App +const ON_LAUNCH = 'onLaunch'; const eventChannels = {}; const eventChannelStack = []; @@ -36,6 +40,15 @@ const navigateTo = { }, }; +tt.appLaunchHooks = []; +function onAppLaunch(hook) { + const app = getApp({ allowDefault: true }); + if (app && app.$vm) { + return injectHook(ON_LAUNCH, hook, app.$vm.$); + } + tt.appLaunchHooks.push(hook); +} + function getBaseSystemInfo() { return tt.getSystemInfoSync() } @@ -722,6 +735,7 @@ const baseApis = { upx2px, addInterceptor, removeInterceptor, + onAppLaunch, }; function initUni(api, protocols) { const wrapper = initWrapper(protocols); @@ -809,8 +823,8 @@ const getProvider = initGetProvider({ }); var shims = /*#__PURE__*/Object.freeze({ - __proto__: null, - getProvider: getProvider + __proto__: null, + getProvider: getProvider }); const chooseImage = { @@ -886,23 +900,23 @@ const getFileInfo = { }; var protocols = /*#__PURE__*/Object.freeze({ - __proto__: null, - chooseImage: chooseImage, - connectSocket: connectSocket, - chooseVideo: chooseVideo, - scanCode: scanCode, - startAccelerometer: startAccelerometer, - showToast: showToast, - showLoading: showLoading, - showModal: showModal, - showActionSheet: showActionSheet, - login: login, - getUserInfo: getUserInfo, - requestPayment: requestPayment, - getFileInfo: getFileInfo, - redirectTo: redirectTo, - navigateTo: navigateTo, - previewImage: previewImage + __proto__: null, + chooseImage: chooseImage, + connectSocket: connectSocket, + chooseVideo: chooseVideo, + scanCode: scanCode, + startAccelerometer: startAccelerometer, + showToast: showToast, + showLoading: showLoading, + showModal: showModal, + showActionSheet: showActionSheet, + login: login, + getUserInfo: getUserInfo, + requestPayment: requestPayment, + getFileInfo: getFileInfo, + redirectTo: redirectTo, + navigateTo: navigateTo, + previewImage: previewImage }); var index = initUni(shims, protocols); diff --git a/packages/uni-mp-toutiao/dist/uni.mp.esm.js b/packages/uni-mp-toutiao/dist/uni.mp.esm.js index fa129fc15188e0e50e3d40896a7c6fe4cb2d4a35..e4088f0178b5cd8d8a9f9c6ec66410b8443d3c69 100644 --- a/packages/uni-mp-toutiao/dist/uni.mp.esm.js +++ b/packages/uni-mp-toutiao/dist/uni.mp.esm.js @@ -1,5 +1,5 @@ import { isPlainObject, hasOwn, isArray, extend, hyphenate, isObject, toNumber, isFunction, NOOP, camelize } from '@vue/shared'; -import { onUnmounted } from 'vue'; +import { onUnmounted, injectHook } from 'vue'; const encode = encodeURIComponent; function stringifyQuery(obj, encodeStr = encode) { @@ -501,7 +501,7 @@ function initScopedSlotsParams(instance) { const vueIds = instance.attrs.vueId; if (vueIds) { const vueId = vueIds.split(',')[0]; - const object = center[vueId] = center[vueId] || {}; + const object = (center[vueId] = center[vueId] || {}); object[name] = value; if (parents[vueId]) { parents[vueId].$forceUpdate(); @@ -570,6 +570,13 @@ function initUnknownHooks(mpOptions, vueOptions, excludes = EXCLUDE_HOOKS) { findHooks(vueOptions).forEach((hook) => initHook$1(mpOptions, hook, excludes)); } +tt.appLaunchHooks = []; +function injectAppLaunchHooks(appInstance) { + tt.appLaunchHooks.forEach((hook) => { + injectHook(ON_LAUNCH, hook, appInstance); + }); +} + const HOOKS = [ ON_SHOW, ON_HIDE, @@ -594,7 +601,9 @@ function parseApp(instance, parseAppOptions) { mpInstance: this, slots: [], }); + injectAppLaunchHooks(internalInstance); ctx.globalData = this.globalData; + options.app = this; instance.$callHook(ON_LAUNCH, options); }, }; diff --git a/packages/uni-mp-weixin/dist/uni.api.esm.js b/packages/uni-mp-weixin/dist/uni.api.esm.js index efaf972f558b49a7597439f8744a17a04eeabf97..429473fb040a1e6b930bd3cb0bbfc7143eed0ccc 100644 --- a/packages/uni-mp-weixin/dist/uni.api.esm.js +++ b/packages/uni-mp-weixin/dist/uni.api.esm.js @@ -1,4 +1,17 @@ import { isArray, hasOwn, isString, isPlainObject, isObject, capitalize, toRawType, makeMap, isPromise, isFunction, extend } from '@vue/shared'; +import { injectHook } from 'vue'; + +//App +const ON_LAUNCH = 'onLaunch'; + +wx.appLaunchHooks = []; +function onAppLaunch(hook) { + const app = getApp({ allowDefault: true }); + if (app && app.$vm) { + return injectHook(ON_LAUNCH, hook, app.$vm.$); + } + wx.appLaunchHooks.push(hook); +} function getBaseSystemInfo() { return wx.getSystemInfoSync() @@ -686,6 +699,7 @@ const baseApis = { upx2px, addInterceptor, removeInterceptor, + onAppLaunch, }; function initUni(api, protocols) { const wrapper = initWrapper(protocols); @@ -791,16 +805,16 @@ const getProvider = initGetProvider({ }); var shims = /*#__PURE__*/Object.freeze({ - __proto__: null, - getProvider: getProvider + __proto__: null, + getProvider: getProvider }); var protocols = /*#__PURE__*/Object.freeze({ - __proto__: null, - redirectTo: redirectTo, - previewImage: previewImage, - getSystemInfo: getSystemInfo, - getSystemInfoSync: getSystemInfoSync + __proto__: null, + redirectTo: redirectTo, + previewImage: previewImage, + getSystemInfo: getSystemInfo, + getSystemInfoSync: getSystemInfoSync }); var index = initUni(shims, protocols); diff --git a/packages/uni-mp-weixin/dist/uni.mp.esm.js b/packages/uni-mp-weixin/dist/uni.mp.esm.js index 161e4e76862cdbf1f309394c56cc06736a668d9d..8defd74263d76914383ac382a5e751ae27027b51 100644 --- a/packages/uni-mp-weixin/dist/uni.mp.esm.js +++ b/packages/uni-mp-weixin/dist/uni.mp.esm.js @@ -1,5 +1,5 @@ import { isPlainObject, hasOwn, isArray, extend, hyphenate, isObject, toNumber, isFunction, NOOP, camelize } from '@vue/shared'; -import { onUnmounted } from 'vue'; +import { onUnmounted, injectHook } from 'vue'; const encode = encodeURIComponent; function stringifyQuery(obj, encodeStr = encode) { @@ -447,7 +447,7 @@ function initScopedSlotsParams(instance) { const vueIds = instance.attrs.vueId; if (vueIds) { const vueId = vueIds.split(',')[0]; - const object = center[vueId] = center[vueId] || {}; + const object = (center[vueId] = center[vueId] || {}); object[name] = value; if (parents[vueId]) { parents[vueId].$forceUpdate(); @@ -513,6 +513,13 @@ function initUnknownHooks(mpOptions, vueOptions, excludes = EXCLUDE_HOOKS) { findHooks(vueOptions).forEach((hook) => initHook$1(mpOptions, hook, excludes)); } +wx.appLaunchHooks = []; +function injectAppLaunchHooks(appInstance) { + wx.appLaunchHooks.forEach((hook) => { + injectHook(ON_LAUNCH, hook, appInstance); + }); +} + const HOOKS = [ ON_SHOW, ON_HIDE, @@ -537,7 +544,9 @@ function parseApp(instance, parseAppOptions) { mpInstance: this, slots: [], }); + injectAppLaunchHooks(internalInstance); ctx.globalData = this.globalData; + options.app = this; instance.$callHook(ON_LAUNCH, options); }, }; diff --git a/packages/uni-quickapp-webview/dist/uni.api.esm.js b/packages/uni-quickapp-webview/dist/uni.api.esm.js index 986602cc8d03cce8b44c7cc929fd7fd05ec5150b..d6efb2763126e7689038078c20f1c0885614a9db 100644 --- a/packages/uni-quickapp-webview/dist/uni.api.esm.js +++ b/packages/uni-quickapp-webview/dist/uni.api.esm.js @@ -1,4 +1,8 @@ import { isArray, hasOwn, isString, isPlainObject, isObject, capitalize, toRawType, makeMap, isPromise, isFunction, extend } from '@vue/shared'; +import { injectHook } from 'vue'; + +//App +const ON_LAUNCH = 'onLaunch'; const eventChannels = {}; const eventChannelStack = []; @@ -36,6 +40,15 @@ const navigateTo = { }, }; +qa.appLaunchHooks = []; +function onAppLaunch(hook) { + const app = getApp({ allowDefault: true }); + if (app && app.$vm) { + return injectHook(ON_LAUNCH, hook, app.$vm.$); + } + qa.appLaunchHooks.push(hook); +} + function getBaseSystemInfo() { return qa.getSystemInfoSync() } @@ -722,6 +735,7 @@ const baseApis = { upx2px, addInterceptor, removeInterceptor, + onAppLaunch, }; function initUni(api, protocols) { const wrapper = initWrapper(protocols); @@ -834,17 +848,17 @@ if (qa.canIUse('getVendorPaymentProvider')) { const getProvider = initGetProvider(providers); var shims = /*#__PURE__*/Object.freeze({ - __proto__: null, - getProvider: getProvider + __proto__: null, + getProvider: getProvider }); var protocols = /*#__PURE__*/Object.freeze({ - __proto__: null, - redirectTo: redirectTo, - navigateTo: navigateTo, - previewImage: previewImage, - getSystemInfo: getSystemInfo, - getSystemInfoSync: getSystemInfoSync + __proto__: null, + redirectTo: redirectTo, + navigateTo: navigateTo, + previewImage: previewImage, + getSystemInfo: getSystemInfo, + getSystemInfoSync: getSystemInfoSync }); var index = initUni(shims, protocols); diff --git a/packages/uni-quickapp-webview/dist/uni.mp.esm.js b/packages/uni-quickapp-webview/dist/uni.mp.esm.js index 0677cd47c8a0a3c659cbb48c656a54453084c7c9..f65210610e2d9c1254f02042e452b895193f1a83 100644 --- a/packages/uni-quickapp-webview/dist/uni.mp.esm.js +++ b/packages/uni-quickapp-webview/dist/uni.mp.esm.js @@ -1,4 +1,5 @@ import { isPlainObject, hasOwn, isArray, extend, hyphenate, isObject, toNumber, isFunction, NOOP, camelize } from '@vue/shared'; +import { injectHook } from 'vue'; const encode = encodeURIComponent; function stringifyQuery(obj, encodeStr = encode) { @@ -497,6 +498,13 @@ function initUnknownHooks(mpOptions, vueOptions, excludes = EXCLUDE_HOOKS) { findHooks(vueOptions).forEach((hook) => initHook$1(mpOptions, hook, excludes)); } +qa.appLaunchHooks = []; +function injectAppLaunchHooks(appInstance) { + qa.appLaunchHooks.forEach((hook) => { + injectHook(ON_LAUNCH, hook, appInstance); + }); +} + const HOOKS = [ ON_SHOW, ON_HIDE, @@ -521,7 +529,9 @@ function parseApp(instance, parseAppOptions) { mpInstance: this, slots: [], }); + injectAppLaunchHooks(internalInstance); ctx.globalData = this.globalData; + options.app = this; instance.$callHook(ON_LAUNCH, options); }, }; diff --git a/packages/vue-cli-plugin-uni/lib/configure-webpack.js b/packages/vue-cli-plugin-uni/lib/configure-webpack.js index 63ec16d38a74bc1c05029b405d385cc25aee4d10..8a9af8b25f7a0e0cc37bcaf518955a92e5661250 100644 --- a/packages/vue-cli-plugin-uni/lib/configure-webpack.js +++ b/packages/vue-cli-plugin-uni/lib/configure-webpack.js @@ -307,7 +307,9 @@ module.exports = function configureWebpack (platformOptions, manifestPlatformOpt .UNI_INPUT_DIR), // css中的'@/static/logo.png'会被转换成'./@/static/logo.png'加载 vue$: getPlatformVue(vueOptions), 'uni-pages': path.resolve(process.env.UNI_INPUT_DIR, 'pages.json'), - '@dcloudio/uni-stat': require.resolve('@dcloudio/uni-stat'), + '@dcloudio/uni-stat': process.env.UNI_USING_VUE3 ? require.resolve( + '@dcloudio/vue-cli-plugin-uni/packages/uni-stat') : require + .resolve('@dcloudio/uni-stat'), 'uni-stat-config': path.resolve(process.env.UNI_INPUT_DIR, 'pages.json') + '?' + JSON.stringify({