From 9246a43bac4ff8ac3001622553fc22b93b7dc6ae Mon Sep 17 00:00:00 2001 From: fxy060608 Date: Thu, 4 Feb 2021 11:23:15 +0800 Subject: [PATCH] feat(mp): add App Lifecycle to subpackage --- src/core/runtime/wrapper/create-subpackage-app.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/core/runtime/wrapper/create-subpackage-app.js b/src/core/runtime/wrapper/create-subpackage-app.js index c2a3c74b8b..855b32ca3c 100644 --- a/src/core/runtime/wrapper/create-subpackage-app.js +++ b/src/core/runtime/wrapper/create-subpackage-app.js @@ -1,6 +1,7 @@ import 'uni-platform/runtime/index' import { + isFn, hasOwn } from 'uni-shared' @@ -24,5 +25,19 @@ export default function createSubpackageApp (vm) { app[name] = appOptions[name] } }) + if (isFn(appOptions.onShow) && __GLOBAL__.onAppShow) { + __GLOBAL__.onAppShow((...args) => { + appOptions.onShow.apply(app, args) + }) + } + if (isFn(appOptions.onHide) && __GLOBAL__.onAppHide) { + __GLOBAL__.onAppHide((...args) => { + appOptions.onHide.apply(app, args) + }) + } + if (isFn(appOptions.onLaunch)) { + const args = __GLOBAL__.getLaunchOptionsSync && __GLOBAL__.getLaunchOptionsSync() + appOptions.onLaunch.call(app, args) + } return vm } -- GitLab