diff --git a/packages/uni-mp-alipay/dist/uni.mp.esm.js b/packages/uni-mp-alipay/dist/uni.mp.esm.js index af4fc21c121bd2afbd7274c6580c7e0fe34f5c09..94872c356cef70f5cb339e0aff8cbcf5834f1003 100644 --- a/packages/uni-mp-alipay/dist/uni.mp.esm.js +++ b/packages/uni-mp-alipay/dist/uni.mp.esm.js @@ -374,9 +374,18 @@ function initCreateSubpackageApp(parseAppOptions) { } }); initAppLifecycle(appOptions, vm); + if (process.env.UNI_SUBPACKAGE) { + (my.$subpackages || (my.$subpackages = {}))[process.env.UNI_SUBPACKAGE] = { + $vm: vm, + }; + } }; } function initAppLifecycle(appOptions, vm) { + if (isFunction(appOptions.onLaunch)) { + const args = my.getLaunchOptionsSync && my.getLaunchOptionsSync(); + appOptions.onLaunch(args); + } if (isFunction(appOptions.onShow) && my.onAppShow) { my.onAppShow((args) => { vm.$callHook('onShow', args); @@ -387,10 +396,6 @@ function initAppLifecycle(appOptions, vm) { vm.$callHook('onHide', args); }); } - if (isFunction(appOptions.onLaunch)) { - const args = my.getLaunchOptionsSync && my.getLaunchOptionsSync(); - vm.$callHook('onLaunch', args || {}); - } } function initLocale(appVm) { const locale = ref(my.getSystemInfoSync().language || 'zh-Hans'); @@ -581,9 +586,18 @@ function initBehaviors(vueOptions) { let $createComponentFn; let $destroyComponentFn; +function getAppVm() { + if (process.env.UNI_MP_PLUGIN) { + return my.$vm; + } + if (process.env.UNI_SUBPACKAGE) { + return my.$subpackages[process.env.UNI_SUBPACKAGE].$vm; + } + return getApp().$vm; +} function $createComponent(initialVNode, options) { if (!$createComponentFn) { - $createComponentFn = getApp().$vm.$createComponent; + $createComponentFn = getAppVm().$createComponent; } const proxy = $createComponentFn(initialVNode, options); return getExposeProxy(proxy.$) || proxy; @@ -598,6 +612,9 @@ function $destroyComponent(instance) { function initCreatePluginApp(parseAppOptions) { return function createApp(vm) { initAppLifecycle(parseApp(vm, parseAppOptions), vm); + if (process.env.UNI_MP_PLUGIN) { + my.$vm = vm; + } }; } diff --git a/packages/uni-mp-baidu/dist/uni.mp.esm.js b/packages/uni-mp-baidu/dist/uni.mp.esm.js index ed8d93e9b416f1a385af7d4460898ea8769023f8..edac9f460c0567e7314d981cad1764ba1fb11769 100644 --- a/packages/uni-mp-baidu/dist/uni.mp.esm.js +++ b/packages/uni-mp-baidu/dist/uni.mp.esm.js @@ -401,9 +401,18 @@ function initCreateSubpackageApp(parseAppOptions) { } }); initAppLifecycle(appOptions, vm); + if (process.env.UNI_SUBPACKAGE) { + (swan.$subpackages || (swan.$subpackages = {}))[process.env.UNI_SUBPACKAGE] = { + $vm: vm, + }; + } }; } function initAppLifecycle(appOptions, vm) { + if (isFunction(appOptions.onLaunch)) { + const args = swan.getLaunchOptionsSync && swan.getLaunchOptionsSync(); + appOptions.onLaunch(args); + } if (isFunction(appOptions.onShow) && swan.onAppShow) { swan.onAppShow((args) => { vm.$callHook('onShow', args); @@ -414,10 +423,6 @@ function initAppLifecycle(appOptions, vm) { vm.$callHook('onHide', args); }); } - if (isFunction(appOptions.onLaunch)) { - const args = swan.getLaunchOptionsSync && swan.getLaunchOptionsSync(); - vm.$callHook('onLaunch', args || {}); - } } function initLocale(appVm) { const locale = ref(swan.getSystemInfoSync().language || 'zh-Hans'); @@ -816,9 +821,18 @@ function initCreateComponent(parseOptions) { } let $createComponentFn; let $destroyComponentFn; +function getAppVm() { + if (process.env.UNI_MP_PLUGIN) { + return swan.$vm; + } + if (process.env.UNI_SUBPACKAGE) { + return swan.$subpackages[process.env.UNI_SUBPACKAGE].$vm; + } + return getApp().$vm; +} function $createComponent(initialVNode, options) { if (!$createComponentFn) { - $createComponentFn = getApp().$vm.$createComponent; + $createComponentFn = getAppVm().$createComponent; } const proxy = $createComponentFn(initialVNode, options); return getExposeProxy(proxy.$) || proxy; @@ -1158,6 +1172,7 @@ swan.EventChannel = EventChannel; swan.createApp = global.createApp = createApp; swan.createPage = createPage; swan.createComponent = createComponent; -swan.createSubpackageApp = createSubpackageApp; +swan.createSubpackageApp = global.createSubpackageApp = + createSubpackageApp; export { createApp, createComponent, createPage, createSubpackageApp }; diff --git a/packages/uni-mp-kuaishou/dist/uni.mp.esm.js b/packages/uni-mp-kuaishou/dist/uni.mp.esm.js index 7e7de9cc973952430f8a2d88b84bebbe270d7175..e948c7465d7863561232436fd58c5d87a329e619 100644 --- a/packages/uni-mp-kuaishou/dist/uni.mp.esm.js +++ b/packages/uni-mp-kuaishou/dist/uni.mp.esm.js @@ -399,9 +399,18 @@ function initCreateSubpackageApp(parseAppOptions) { } }); initAppLifecycle(appOptions, vm); + if (process.env.UNI_SUBPACKAGE) { + (ks.$subpackages || (ks.$subpackages = {}))[process.env.UNI_SUBPACKAGE] = { + $vm: vm, + }; + } }; } function initAppLifecycle(appOptions, vm) { + if (isFunction(appOptions.onLaunch)) { + const args = ks.getLaunchOptionsSync && ks.getLaunchOptionsSync(); + appOptions.onLaunch(args); + } if (isFunction(appOptions.onShow) && ks.onAppShow) { ks.onAppShow((args) => { vm.$callHook('onShow', args); @@ -412,10 +421,6 @@ function initAppLifecycle(appOptions, vm) { vm.$callHook('onHide', args); }); } - if (isFunction(appOptions.onLaunch)) { - const args = ks.getLaunchOptionsSync && ks.getLaunchOptionsSync(); - vm.$callHook('onLaunch', args || {}); - } } function initLocale(appVm) { const locale = ref(ks.getSystemInfoSync().language || 'zh-Hans'); @@ -803,9 +808,18 @@ function initCreateComponent(parseOptions) { } let $createComponentFn; let $destroyComponentFn; +function getAppVm() { + if (process.env.UNI_MP_PLUGIN) { + return ks.$vm; + } + if (process.env.UNI_SUBPACKAGE) { + return ks.$subpackages[process.env.UNI_SUBPACKAGE].$vm; + } + return getApp().$vm; +} function $createComponent(initialVNode, options) { if (!$createComponentFn) { - $createComponentFn = getApp().$vm.$createComponent; + $createComponentFn = getAppVm().$createComponent; } const proxy = $createComponentFn(initialVNode, options); return getExposeProxy(proxy.$) || proxy; @@ -1053,6 +1067,7 @@ ks.EventChannel = EventChannel; ks.createApp = global.createApp = createApp; ks.createPage = createPage; ks.createComponent = createComponent; -ks.createSubpackageApp = createSubpackageApp; +ks.createSubpackageApp = global.createSubpackageApp = + createSubpackageApp; export { createApp, createComponent, createPage, createSubpackageApp }; diff --git a/packages/uni-mp-lark/dist/uni.mp.esm.js b/packages/uni-mp-lark/dist/uni.mp.esm.js index 408ab016e4fcd34a753c3709d9a6b0e8f4942ff7..f2128101f2a6a76594693b9e22e58203693da7de 100644 --- a/packages/uni-mp-lark/dist/uni.mp.esm.js +++ b/packages/uni-mp-lark/dist/uni.mp.esm.js @@ -398,9 +398,18 @@ function initCreateSubpackageApp(parseAppOptions) { } }); initAppLifecycle(appOptions, vm); + if (process.env.UNI_SUBPACKAGE) { + (tt.$subpackages || (tt.$subpackages = {}))[process.env.UNI_SUBPACKAGE] = { + $vm: vm, + }; + } }; } function initAppLifecycle(appOptions, vm) { + if (isFunction(appOptions.onLaunch)) { + const args = tt.getLaunchOptionsSync && tt.getLaunchOptionsSync(); + appOptions.onLaunch(args); + } if (isFunction(appOptions.onShow) && tt.onAppShow) { tt.onAppShow((args) => { vm.$callHook('onShow', args); @@ -411,10 +420,6 @@ function initAppLifecycle(appOptions, vm) { vm.$callHook('onHide', args); }); } - if (isFunction(appOptions.onLaunch)) { - const args = tt.getLaunchOptionsSync && tt.getLaunchOptionsSync(); - vm.$callHook('onLaunch', args || {}); - } } function initLocale(appVm) { const locale = ref(tt.getSystemInfoSync().language || 'zh-Hans'); @@ -776,9 +781,18 @@ function initCreateComponent(parseOptions) { } let $createComponentFn; let $destroyComponentFn; +function getAppVm() { + if (process.env.UNI_MP_PLUGIN) { + return tt.$vm; + } + if (process.env.UNI_SUBPACKAGE) { + return tt.$subpackages[process.env.UNI_SUBPACKAGE].$vm; + } + return getApp().$vm; +} function $createComponent(initialVNode, options) { if (!$createComponentFn) { - $createComponentFn = getApp().$vm.$createComponent; + $createComponentFn = getAppVm().$createComponent; } const proxy = $createComponentFn(initialVNode, options); return getExposeProxy(proxy.$) || proxy; @@ -1113,6 +1127,7 @@ tt.EventChannel = EventChannel; tt.createApp = global.createApp = createApp; tt.createPage = createPage; tt.createComponent = createComponent; -tt.createSubpackageApp = createSubpackageApp; +tt.createSubpackageApp = global.createSubpackageApp = + createSubpackageApp; export { createApp, createComponent, createPage, createSubpackageApp }; diff --git a/packages/uni-mp-qq/dist/uni.mp.esm.js b/packages/uni-mp-qq/dist/uni.mp.esm.js index bd2bf8428c82c232145cea1ac486f692364c7d01..44e7cbe7531d2f7d511e77adc4670a3aed0f3558 100644 --- a/packages/uni-mp-qq/dist/uni.mp.esm.js +++ b/packages/uni-mp-qq/dist/uni.mp.esm.js @@ -395,9 +395,18 @@ function initCreateSubpackageApp(parseAppOptions) { } }); initAppLifecycle(appOptions, vm); + if (process.env.UNI_SUBPACKAGE) { + (qq.$subpackages || (qq.$subpackages = {}))[process.env.UNI_SUBPACKAGE] = { + $vm: vm, + }; + } }; } function initAppLifecycle(appOptions, vm) { + if (isFunction(appOptions.onLaunch)) { + const args = qq.getLaunchOptionsSync && qq.getLaunchOptionsSync(); + appOptions.onLaunch(args); + } if (isFunction(appOptions.onShow) && qq.onAppShow) { qq.onAppShow((args) => { vm.$callHook('onShow', args); @@ -408,10 +417,6 @@ function initAppLifecycle(appOptions, vm) { vm.$callHook('onHide', args); }); } - if (isFunction(appOptions.onLaunch)) { - const args = qq.getLaunchOptionsSync && qq.getLaunchOptionsSync(); - vm.$callHook('onLaunch', args || {}); - } } function initLocale(appVm) { const locale = ref(qq.getSystemInfoSync().language || 'zh-Hans'); @@ -765,9 +770,18 @@ function initCreateComponent(parseOptions) { } let $createComponentFn; let $destroyComponentFn; +function getAppVm() { + if (process.env.UNI_MP_PLUGIN) { + return qq.$vm; + } + if (process.env.UNI_SUBPACKAGE) { + return qq.$subpackages[process.env.UNI_SUBPACKAGE].$vm; + } + return getApp().$vm; +} function $createComponent(initialVNode, options) { if (!$createComponentFn) { - $createComponentFn = getApp().$vm.$createComponent; + $createComponentFn = getAppVm().$createComponent; } const proxy = $createComponentFn(initialVNode, options); return getExposeProxy(proxy.$) || proxy; @@ -815,6 +829,9 @@ function initCreatePage(parseOptions) { function initCreatePluginApp(parseAppOptions) { return function createApp(vm) { initAppLifecycle(parseApp(vm, parseAppOptions), vm); + if (process.env.UNI_MP_PLUGIN) { + qq.$vm = vm; + } }; } @@ -945,6 +962,7 @@ qq.EventChannel = EventChannel; qq.createApp = global.createApp = createApp; qq.createPage = createPage; qq.createComponent = createComponent; -qq.createSubpackageApp = createSubpackageApp; +qq.createSubpackageApp = global.createSubpackageApp = + createSubpackageApp; export { createApp, createComponent, createPage, createPluginApp, createSubpackageApp }; diff --git a/packages/uni-mp-toutiao/dist/uni.mp.esm.js b/packages/uni-mp-toutiao/dist/uni.mp.esm.js index 887e36c5cade8470d26de7ccdfb0eaa64bb6457b..dd07f95e806858e17b32598205947c8a26ac2426 100644 --- a/packages/uni-mp-toutiao/dist/uni.mp.esm.js +++ b/packages/uni-mp-toutiao/dist/uni.mp.esm.js @@ -398,9 +398,18 @@ function initCreateSubpackageApp(parseAppOptions) { } }); initAppLifecycle(appOptions, vm); + if (process.env.UNI_SUBPACKAGE) { + (tt.$subpackages || (tt.$subpackages = {}))[process.env.UNI_SUBPACKAGE] = { + $vm: vm, + }; + } }; } function initAppLifecycle(appOptions, vm) { + if (isFunction(appOptions.onLaunch)) { + const args = tt.getLaunchOptionsSync && tt.getLaunchOptionsSync(); + appOptions.onLaunch(args); + } if (isFunction(appOptions.onShow) && tt.onAppShow) { tt.onAppShow((args) => { vm.$callHook('onShow', args); @@ -411,10 +420,6 @@ function initAppLifecycle(appOptions, vm) { vm.$callHook('onHide', args); }); } - if (isFunction(appOptions.onLaunch)) { - const args = tt.getLaunchOptionsSync && tt.getLaunchOptionsSync(); - vm.$callHook('onLaunch', args || {}); - } } function initLocale(appVm) { const locale = ref(tt.getSystemInfoSync().language || 'zh-Hans'); @@ -777,9 +782,18 @@ function initCreateComponent(parseOptions) { } let $createComponentFn; let $destroyComponentFn; +function getAppVm() { + if (process.env.UNI_MP_PLUGIN) { + return tt.$vm; + } + if (process.env.UNI_SUBPACKAGE) { + return tt.$subpackages[process.env.UNI_SUBPACKAGE].$vm; + } + return getApp().$vm; +} function $createComponent(initialVNode, options) { if (!$createComponentFn) { - $createComponentFn = getApp().$vm.$createComponent; + $createComponentFn = getAppVm().$createComponent; } const proxy = $createComponentFn(initialVNode, options); return getExposeProxy(proxy.$) || proxy; @@ -1135,6 +1149,7 @@ tt.EventChannel = EventChannel; tt.createApp = global.createApp = createApp; tt.createPage = createPage; tt.createComponent = createComponent; -tt.createSubpackageApp = createSubpackageApp; +tt.createSubpackageApp = global.createSubpackageApp = + createSubpackageApp; export { createApp, createComponent, createPage, createSubpackageApp }; diff --git a/packages/uni-mp-weixin/dist/uni.mp.esm.js b/packages/uni-mp-weixin/dist/uni.mp.esm.js index 071b11e60fafc1f6bd83b385aaf43b940a1e39ba..156cf8a9230ddaa399d5477494a3555c28a93b4a 100644 --- a/packages/uni-mp-weixin/dist/uni.mp.esm.js +++ b/packages/uni-mp-weixin/dist/uni.mp.esm.js @@ -332,9 +332,18 @@ function initCreateSubpackageApp(parseAppOptions) { } }); initAppLifecycle(appOptions, vm); + if (process.env.UNI_SUBPACKAGE) { + (wx.$subpackages || (wx.$subpackages = {}))[process.env.UNI_SUBPACKAGE] = { + $vm: vm, + }; + } }; } function initAppLifecycle(appOptions, vm) { + if (isFunction(appOptions.onLaunch)) { + const args = wx.getLaunchOptionsSync && wx.getLaunchOptionsSync(); + appOptions.onLaunch(args); + } if (isFunction(appOptions.onShow) && wx.onAppShow) { wx.onAppShow((args) => { vm.$callHook('onShow', args); @@ -345,10 +354,6 @@ function initAppLifecycle(appOptions, vm) { vm.$callHook('onHide', args); }); } - if (isFunction(appOptions.onLaunch)) { - const args = wx.getLaunchOptionsSync && wx.getLaunchOptionsSync(); - vm.$callHook('onLaunch', args || {}); - } } function initLocale(appVm) { const locale = ref(wx.getSystemInfoSync().language || 'zh-Hans'); @@ -702,9 +707,18 @@ function initCreateComponent(parseOptions) { } let $createComponentFn; let $destroyComponentFn; +function getAppVm() { + if (process.env.UNI_MP_PLUGIN) { + return wx.$vm; + } + if (process.env.UNI_SUBPACKAGE) { + return wx.$subpackages[process.env.UNI_SUBPACKAGE].$vm; + } + return getApp().$vm; +} function $createComponent(initialVNode, options) { if (!$createComponentFn) { - $createComponentFn = getApp().$vm.$createComponent; + $createComponentFn = getAppVm().$createComponent; } const proxy = $createComponentFn(initialVNode, options); return getExposeProxy(proxy.$) || proxy; @@ -752,6 +766,9 @@ function initCreatePage(parseOptions) { function initCreatePluginApp(parseAppOptions) { return function createApp(vm) { initAppLifecycle(parseApp(vm, parseAppOptions), vm); + if (process.env.UNI_MP_PLUGIN) { + wx.$vm = vm; + } }; } @@ -881,8 +898,10 @@ const createSubpackageApp = initCreateSubpackageApp(); wx.createApp = global.createApp = createApp; wx.createPage = createPage; wx.createComponent = createComponent; - wx.createPluginApp = createPluginApp; - wx.createSubpackageApp = createSubpackageApp; + wx.createPluginApp = global.createPluginApp = + createPluginApp; + wx.createSubpackageApp = global.createSubpackageApp = + createSubpackageApp; } export { createApp, createComponent, createPage, createPluginApp, createSubpackageApp }; diff --git a/packages/uni-quickapp-webview/dist/uni.mp.esm.js b/packages/uni-quickapp-webview/dist/uni.mp.esm.js index 80436138eb02836cf75ace25ac2a176b1b1733c2..036fb83fab030ce1a8c303f290532bd3d0a2ac77 100644 --- a/packages/uni-quickapp-webview/dist/uni.mp.esm.js +++ b/packages/uni-quickapp-webview/dist/uni.mp.esm.js @@ -460,9 +460,18 @@ function initCreateSubpackageApp(parseAppOptions) { } }); initAppLifecycle(appOptions, vm); + if (process.env.UNI_SUBPACKAGE) { + (qa.$subpackages || (qa.$subpackages = {}))[process.env.UNI_SUBPACKAGE] = { + $vm: vm, + }; + } }; } function initAppLifecycle(appOptions, vm) { + if (isFunction(appOptions.onLaunch)) { + const args = qa.getLaunchOptionsSync && qa.getLaunchOptionsSync(); + appOptions.onLaunch(args); + } if (isFunction(appOptions.onShow) && qa.onAppShow) { qa.onAppShow((args) => { vm.$callHook('onShow', args); @@ -473,10 +482,6 @@ function initAppLifecycle(appOptions, vm) { vm.$callHook('onHide', args); }); } - if (isFunction(appOptions.onLaunch)) { - const args = qa.getLaunchOptionsSync && qa.getLaunchOptionsSync(); - vm.$callHook('onLaunch', args || {}); - } } function initLocale(appVm) { const locale = ref(qa.getSystemInfoSync().language || 'zh-Hans'); @@ -819,9 +824,18 @@ function initCreateComponent(parseOptions) { } let $createComponentFn; let $destroyComponentFn; +function getAppVm() { + if (process.env.UNI_MP_PLUGIN) { + return qa.$vm; + } + if (process.env.UNI_SUBPACKAGE) { + return qa.$subpackages[process.env.UNI_SUBPACKAGE].$vm; + } + return getApp().$vm; +} function $createComponent(initialVNode, options) { if (!$createComponentFn) { - $createComponentFn = getApp().$vm.$createComponent; + $createComponentFn = getAppVm().$createComponent; } const proxy = $createComponentFn(initialVNode, options); return getExposeProxy(proxy.$) || proxy; @@ -1155,6 +1169,7 @@ qa.EventChannel = EventChannel$1; qa.createApp = global.createApp = createApp; qa.createPage = createPage; qa.createComponent = createComponent; -qa.createSubpackageApp = createSubpackageApp; +qa.createSubpackageApp = global.createSubpackageApp = + createSubpackageApp; export { createApp, createComponent, createPage, createSubpackageApp };