Skip to content

Commit

Permalink
fix: miniapp app lifecycle is invalid (#5263)
Browse files Browse the repository at this point in the history
  • Loading branch information
SoloJiang authored Apr 7, 2022
1 parent 4124a69 commit 54e6873
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 17 deletions.
4 changes: 4 additions & 0 deletions packages/create-app-shared/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## 1.2.6

- [fix] miniapp app lifecycle is invalid

## 1.2.5

- [feat] be able to pass arguments to memory router
Expand Down
2 changes: 1 addition & 1 deletion packages/create-app-shared/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "create-app-shared",
"version": "1.2.5",
"version": "1.2.6",
"description": "",
"author": "ice-admin@alibaba-inc.com",
"homepage": "https://github.com/alibaba/ice#readme",
Expand Down
21 changes: 20 additions & 1 deletion packages/create-app-shared/src/collectAppLifeCycle.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
import { addAppLifeCycle } from './appLifeCycles';
import { SHOW, LAUNCH, ERROR, HIDE, TAB_ITEM_CLICK } from './constants';
import {
SHOW,
LAUNCH,
ERROR,
HIDE,
TAB_ITEM_CLICK,
NOT_FOUND,
SHARE,
UNHANDLED_REJECTION,
} from './constants';
import type { AppConfig } from './types';

export default function collectAppLifeCycle(appConfig: AppConfig) {
Expand All @@ -15,4 +24,14 @@ export default function collectAppLifeCycle(appConfig: AppConfig) {
addAppLifeCycle(HIDE, onHide);
// Add tab bar item click callback
addAppLifeCycle(TAB_ITEM_CLICK, onTabItemClick);

// Add lifecycle callbacks which only valid in Alibaba MiniApp
const { onPageNotFound, onShareAppMessage, onUnhandledRejection } =
appConfig.app;
// Add global share callback
addAppLifeCycle(SHARE, onShareAppMessage);
// Add unhandledrejection callback
addAppLifeCycle(UNHANDLED_REJECTION, onUnhandledRejection);
// Add page not found callback
addAppLifeCycle(NOT_FOUND, onPageNotFound);
}
14 changes: 0 additions & 14 deletions packages/create-app-shared/src/miniapp/collectAppLifeCycle.ts

This file was deleted.

2 changes: 1 addition & 1 deletion packages/create-app-shared/src/miniapp/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export { default as initAppLifeCycles} from './initAppLifeCycles';
export { setHistory, getHistory, history } from '../storage';
export { pathRedirect } from '../utils';
export { default as getSearchParams} from './getSearchParams';
export { default as collectAppLifeCycle} from './collectAppLifeCycle';
export { default as collectAppLifeCycle} from '../collectAppLifeCycle';
export { default as RuntimeModule, RuntimePlugin } from '../runtimeModule';
export { default as createBaseApp } from '../createBaseApp';
export * from '../nativeEventListener';
Expand Down

0 comments on commit 54e6873

Please sign in to comment.