@lemon-fe/mini-app 0.1.4 → 0.1.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -30,6 +30,7 @@ import { parsePath } from '../../utils/path';
|
|
|
30
30
|
import { NavigationContext } from '../../context';
|
|
31
31
|
import Screen from '../Screen';
|
|
32
32
|
import { GO_BACK } from '../../constants';
|
|
33
|
+
import { mini } from '../../global';
|
|
33
34
|
import './index.css';
|
|
34
35
|
|
|
35
36
|
function App(props) {
|
|
@@ -91,8 +92,6 @@ function App(props) {
|
|
|
91
92
|
}, []);
|
|
92
93
|
var goBack = useCallback(function () {
|
|
93
94
|
setState(function (prev) {
|
|
94
|
-
var _window$ReactNativeWe;
|
|
95
|
-
|
|
96
95
|
var nextRoutes = _toConsumableArray(prev.routes);
|
|
97
96
|
|
|
98
97
|
if (nextRoutes.length > 1) {
|
|
@@ -100,16 +99,15 @@ function App(props) {
|
|
|
100
99
|
return _objectSpread(_objectSpread({}, prev), {}, {
|
|
101
100
|
routes: nextRoutes
|
|
102
101
|
});
|
|
102
|
+
} else {
|
|
103
|
+
mini.exit();
|
|
103
104
|
}
|
|
104
105
|
|
|
105
|
-
(_window$ReactNativeWe = window.ReactNativeWebView) === null || _window$ReactNativeWe === void 0 ? void 0 : _window$ReactNativeWe.postMessage(GO_BACK);
|
|
106
106
|
return prev;
|
|
107
107
|
});
|
|
108
108
|
}, []);
|
|
109
109
|
useEffect(function () {
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
return (_window$mini = window.mini) === null || _window$mini === void 0 ? void 0 : _window$mini.addListener(function (e) {
|
|
110
|
+
return mini.addListener(function (e) {
|
|
113
111
|
if (e === GO_BACK) {
|
|
114
112
|
goBack();
|
|
115
113
|
}
|
|
@@ -7,6 +7,7 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
|
|
|
7
7
|
import React, { createElement, memo, useMemo } from 'react';
|
|
8
8
|
import { ScreenContext } from '../../context';
|
|
9
9
|
import { useNavigation } from '../../hooks';
|
|
10
|
+
import { mini } from '../../global';
|
|
10
11
|
import './index.css';
|
|
11
12
|
|
|
12
13
|
function Screen(props) {
|
|
@@ -19,9 +20,7 @@ function Screen(props) {
|
|
|
19
20
|
};
|
|
20
21
|
}, [params]);
|
|
21
22
|
var statusBarHeight = useMemo(function () {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
return (_window$mini = window.mini) === null || _window$mini === void 0 ? void 0 : _window$mini.getSystemInfoSync().statusBarHeight;
|
|
23
|
+
return mini.getSystemInfoSync().statusBarHeight;
|
|
25
24
|
}, []);
|
|
26
25
|
var navigation = useNavigation();
|
|
27
26
|
return /*#__PURE__*/React.createElement(ScreenContext.Provider, {
|
package/es/global.d.ts
CHANGED
package/es/global.js
CHANGED
|
@@ -12,7 +12,9 @@ export var mini = {
|
|
|
12
12
|
};
|
|
13
13
|
},
|
|
14
14
|
addListener: function addListener() {},
|
|
15
|
-
getExtraPayload: function getExtraPayload() {}
|
|
15
|
+
getExtraPayload: function getExtraPayload() {},
|
|
16
|
+
scanCode: function scanCode() {},
|
|
17
|
+
exit: function exit() {}
|
|
16
18
|
};
|
|
17
19
|
export function createApp(render) {
|
|
18
20
|
var count = 0;
|
|
@@ -24,7 +26,7 @@ export function createApp(render) {
|
|
|
24
26
|
if (count <= 10) {
|
|
25
27
|
setTimeout(check, 100);
|
|
26
28
|
} else {
|
|
27
|
-
|
|
29
|
+
render();
|
|
28
30
|
}
|
|
29
31
|
} else {
|
|
30
32
|
mini = window.mini;
|