@lemon-fe/mini-app 0.1.26 → 0.1.31
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.
- package/es/components/AppContainer/index.css +6 -2
- package/es/components/AppContainer/index.js +5 -7
- package/es/components/Capsule/index.css +21 -0
- package/es/components/Capsule/index.d.ts +2 -0
- package/es/components/Capsule/index.js +51 -0
- package/es/components/Screen/index.css +0 -1
- package/es/components/Screen/index.js +19 -5
- package/es/global.d.ts +4 -0
- package/es/global.js +2 -1
- package/es/index.d.ts +1 -1
- package/es/typings.d.ts +7 -0
- package/package.json +2 -2
|
@@ -11,10 +11,14 @@
|
|
|
11
11
|
|
|
12
12
|
.lemon-transition-enter-active {
|
|
13
13
|
transform: translate3d(0, 0, 0);
|
|
14
|
-
|
|
14
|
+
transition: transform 300ms;
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
.lemon-transition-exit {
|
|
18
|
+
transform: translate3d(0, 0, 0);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.lemon-transition-exit-active {
|
|
18
22
|
transform: translate3d(100%, 0, 0);
|
|
19
|
-
|
|
23
|
+
transition: transform 300ms;
|
|
20
24
|
}
|
|
@@ -25,12 +25,13 @@ function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Sy
|
|
|
25
25
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
26
26
|
|
|
27
27
|
import React, { cloneElement, useCallback, useEffect, useMemo, useState } from 'react';
|
|
28
|
-
import {
|
|
28
|
+
import { TransitionGroup } from 'react-transition-group';
|
|
29
29
|
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
33
|
import { mini } from '../../global';
|
|
34
|
+
import Capsule from '../Capsule';
|
|
34
35
|
import './index.css';
|
|
35
36
|
|
|
36
37
|
function App(props) {
|
|
@@ -125,19 +126,16 @@ function App(props) {
|
|
|
125
126
|
var screens = /*#__PURE__*/React.createElement(TransitionGroup, {
|
|
126
127
|
className: "lemon-routes"
|
|
127
128
|
}, state.routes.map(function (item, index) {
|
|
128
|
-
return /*#__PURE__*/React.createElement(
|
|
129
|
+
return /*#__PURE__*/React.createElement(Screen, {
|
|
129
130
|
key: item.route.path,
|
|
130
|
-
timeout: 300,
|
|
131
|
-
classNames: "lemon-transition"
|
|
132
|
-
}, /*#__PURE__*/React.createElement(Screen, {
|
|
133
131
|
route: item.route,
|
|
134
132
|
params: item.params,
|
|
135
133
|
index: index
|
|
136
|
-
})
|
|
134
|
+
});
|
|
137
135
|
}));
|
|
138
136
|
return /*#__PURE__*/React.createElement(NavigationContext.Provider, {
|
|
139
137
|
value: ctx
|
|
140
|
-
}, children ? /*#__PURE__*/cloneElement(children, {}, screens) : screens);
|
|
138
|
+
}, children ? /*#__PURE__*/cloneElement(children, {}, screens) : screens, window.ReactNativeWebView === undefined && /*#__PURE__*/React.createElement(Capsule, null));
|
|
141
139
|
}
|
|
142
140
|
|
|
143
141
|
export default App;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
.lemon-capsule {
|
|
2
|
+
position: fixed;
|
|
3
|
+
top: calc(env(safe-area-inset-top) + 7px);
|
|
4
|
+
right: 15px;
|
|
5
|
+
height: 30px;
|
|
6
|
+
background-color: rgba(255, 255, 255, 0.6);
|
|
7
|
+
border: 1px solid rgba(151, 151, 151, 0.2);
|
|
8
|
+
border-radius: 15px;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
.lemon-capsule-item {
|
|
12
|
+
display: flex;
|
|
13
|
+
align-items: center;
|
|
14
|
+
justify-content: center;
|
|
15
|
+
width: 44px;
|
|
16
|
+
height: 100%;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
.lemon-capsule-item:active {
|
|
20
|
+
opacity: 0.5;
|
|
21
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import './index.css';
|
|
3
|
+
export default function Capsule() {
|
|
4
|
+
var generateCode = function generateCode() {
|
|
5
|
+
var url = "nhsoft://external-apps?url=".concat(encodeURIComponent(window.location.href));
|
|
6
|
+
window.alert("".concat(url, "\uFF0C\u8BF7\u590D\u5236\u5E76\u751F\u6210\u4E8C\u7EF4\u7801\u901A\u8FC7APP\u626B\u63CF"));
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
10
|
+
className: "lemon-capsule",
|
|
11
|
+
onClick: generateCode
|
|
12
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
13
|
+
className: "lemon-capsule-item",
|
|
14
|
+
tabIndex: 0
|
|
15
|
+
}, /*#__PURE__*/React.createElement("svg", {
|
|
16
|
+
viewBox: "0 0 1024 1024",
|
|
17
|
+
version: "1.1",
|
|
18
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
19
|
+
"p-id": "4228",
|
|
20
|
+
width: "24",
|
|
21
|
+
height: "24",
|
|
22
|
+
fill: "#333"
|
|
23
|
+
}, /*#__PURE__*/React.createElement("path", {
|
|
24
|
+
d: "M152.075264 123.511808c101.716992 0 203.435008 0 305.152 0 31.031296 3.073024 23.552 57.696256 23.552 93.184 0 63.742976 0 105.755648 0 168.96 0 36.721664 6.915072 81.729536-17.408 92.16-15.840256 6.793216-58.351616 2.048-78.848 2.048-56.271872 0-102.012928 0-161.792 0-37.400576 0-88.469504 8.927232-94.208-23.552 0-103.083008 0-206.164992 0-309.248C132.70528 135.544832 140.061696 127.200256 152.075264 123.511808zM194.059264 193.143808c0 73.387008 0 146.772992 0 220.16 73.387008 0 146.772992 0 220.16 0 0-74.411008 0-148.820992 0-223.232-73.044992 0-146.091008 0-219.136 0C193.890304 190.24384 193.9712 191.690752 194.059264 193.143808z",
|
|
25
|
+
"p-id": "4229"
|
|
26
|
+
}), /*#__PURE__*/React.createElement("path", {
|
|
27
|
+
d: "M561.675264 123.511808c101.716992 0 203.435008 0 305.152 0 12.447744 4.61824 21.001216 13.1328 23.552 27.648 0 100.352 0 200.705024 0 301.056-2.792448 12.510208-9.324544 23.196672-21.504 26.624-19.904512 5.600256-52.977664 1.024-76.8 1.024-56.127488 0-102.14912 0-156.672 0-23.626752 0-58.642432 4.97664-77.824-1.024-27.077632-8.471552-19.456-61.329408-19.456-98.304 0-49.115136 0-106.445824 0-157.696C538.123264 180.148224 528.75264 129.476608 561.675264 123.511808zM603.659264 193.143808c0 73.387008 0 146.772992 0 220.16 73.387008 0 146.772992 0 220.16 0 0-74.411008 0-148.820992 0-223.232-73.044992 0-146.091008 0-219.136 0C603.490304 190.24384 603.5712 191.690752 603.659264 193.143808z",
|
|
28
|
+
"p-id": "4230"
|
|
29
|
+
}), /*#__PURE__*/React.createElement("path", {
|
|
30
|
+
d: "M294.411264 257.655808c30.661632-5.786624 54.774784 14.930944 55.296 43.008 0.687104 37.025792-37.129216 57.365504-66.56 41.984C249.47712 325.050368 251.693056 265.71776 294.411264 257.655808z",
|
|
31
|
+
"p-id": "4231"
|
|
32
|
+
}), /*#__PURE__*/React.createElement("path", {
|
|
33
|
+
d: "M704.011264 257.655808c72.223744-13.493248 70.839296 100.886528 0 89.088C658.929664 339.23584 657.47456 266.350592 704.011264 257.655808z",
|
|
34
|
+
"p-id": "4232"
|
|
35
|
+
}), /*#__PURE__*/React.createElement("path", {
|
|
36
|
+
d: "M455.179264 895.607808c-100.692992 0-201.385984 0-302.08 0-12.540928-3.843072-21.01248-11.75552-24.576-24.576 0-102.740992 0-205.483008 0-308.224 2.982912-9.019392 9.868288-19.542016 20.48-22.528 20.0448-5.640192 52.7872-1.024 76.8-1.024 55.189504 0 105.184256 0 156.672 0 23.154688 0 56.85248-5.168128 77.824 1.024 28.371968 8.37632 20.48 60.376064 20.48 97.28 0 56.7296 0 105.121792 0 162.816C480.779264 840.206336 489.356288 892.051456 455.179264 895.607808zM194.059264 608.887808c0 73.388032 0 146.772992 0 220.16 73.387008 0 146.772992 0 220.16 0 0-74.411008 0-148.820992 0-223.232-73.044992 0-146.091008 0-219.136 0C193.890304 605.98784 193.9712 607.434752 194.059264 608.887808z",
|
|
37
|
+
"p-id": "4233"
|
|
38
|
+
}), /*#__PURE__*/React.createElement("path", {
|
|
39
|
+
d: "M890.379264 566.903808c0 28.672 0 57.344 0 86.016-2.388992 29.014016-0.342016 62.462976-1.024 93.184-72.704 0-145.408 0-218.112 0 0-16.724992 0-33.451008 0-50.176-20.481024-2.387968-45.395968-0.342016-67.584-1.024-2.388992 64.854016-0.340992 134.142976-1.024 200.704-13.312 0-26.624 0-39.936 0-34.337792-6.882304-24.576-58.407936-24.576-99.328 0-57.078784 0-104.042496 0-158.72 0-23.865344-4.830208-59.64288 1.024-78.848 6.984704-22.913024 37.274624-19.456 67.584-19.456 51.24096 0 96.891904 0 148.48 0 0 45.396992 0 90.795008 0 136.192 22.868992 0 45.739008 0 68.608 0 0.681984-45.056-1.364992-92.841984 1.024-136.192C857.858048 537.302016 888.439808 537.783296 890.379264 566.903808z",
|
|
40
|
+
"p-id": "4234"
|
|
41
|
+
}), /*#__PURE__*/React.createElement("path", {
|
|
42
|
+
d: "M299.531264 672.375808c32.740352-3.623936 59.804672 27.841536 47.104 62.464-17.604608 47.98976-101.778432 29.953024-86.016-30.72C264.976384 687.348736 277.561344 674.807808 299.531264 672.375808z",
|
|
43
|
+
"p-id": "4235"
|
|
44
|
+
}), /*#__PURE__*/React.createElement("path", {
|
|
45
|
+
d: "M744.971264 895.607808c-24.576 0-49.152 0-73.728 0 0.681984-26.284032-1.363968-55.294976 1.024-79.872 24.235008 0 48.468992 0 72.704 0C744.971264 842.359808 744.971264 868.983808 744.971264 895.607808z",
|
|
46
|
+
"p-id": "4236"
|
|
47
|
+
}), /*#__PURE__*/React.createElement("path", {
|
|
48
|
+
d: "M890.379264 815.735808c0 17.408 0 34.816 0 52.224-2.84672 14.56128-11.36128 23.45472-24.576 27.648-17.408 0-34.816 0-52.224 0 0.681984-26.284032-1.363968-55.294976 1.024-79.872C839.862272 815.735808 865.120256 815.735808 890.379264 815.735808z",
|
|
49
|
+
"p-id": "4237"
|
|
50
|
+
}))));
|
|
51
|
+
}
|
|
@@ -1,10 +1,17 @@
|
|
|
1
|
+
var _excluded = ["route", "params", "index"];
|
|
2
|
+
|
|
1
3
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
2
4
|
|
|
3
5
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
4
6
|
|
|
5
7
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
6
8
|
|
|
7
|
-
|
|
9
|
+
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
10
|
+
|
|
11
|
+
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
12
|
+
|
|
13
|
+
import React, { createElement, memo, useContext, useMemo, useRef } from 'react';
|
|
14
|
+
import { CSSTransition } from 'react-transition-group';
|
|
8
15
|
import { NavigationContext, ScreenContext } from '../../context';
|
|
9
16
|
import { mini } from '../../global';
|
|
10
17
|
import './index.css';
|
|
@@ -12,7 +19,9 @@ import './index.css';
|
|
|
12
19
|
function Screen(props) {
|
|
13
20
|
var route = props.route,
|
|
14
21
|
params = props.params,
|
|
15
|
-
index = props.index
|
|
22
|
+
index = props.index,
|
|
23
|
+
restProps = _objectWithoutProperties(props, _excluded);
|
|
24
|
+
|
|
16
25
|
var ctx = useMemo(function () {
|
|
17
26
|
return {
|
|
18
27
|
params: params
|
|
@@ -26,10 +35,15 @@ function Screen(props) {
|
|
|
26
35
|
navigation = _useContext.navigation,
|
|
27
36
|
headerStyle = _useContext.headerStyle;
|
|
28
37
|
|
|
29
|
-
|
|
38
|
+
var ref = useRef(null);
|
|
39
|
+
return /*#__PURE__*/React.createElement(CSSTransition, _objectSpread({
|
|
40
|
+
timeout: 300,
|
|
41
|
+
classNames: "lemon-transition"
|
|
42
|
+
}, restProps), /*#__PURE__*/React.createElement(ScreenContext.Provider, {
|
|
30
43
|
value: ctx
|
|
31
44
|
}, /*#__PURE__*/React.createElement("div", {
|
|
32
|
-
className: "lemon-route"
|
|
45
|
+
className: "lemon-route",
|
|
46
|
+
ref: ref
|
|
33
47
|
}, /*#__PURE__*/React.createElement("div", {
|
|
34
48
|
className: "lemon-route-header",
|
|
35
49
|
style: _objectSpread(_objectSpread({
|
|
@@ -55,7 +69,7 @@ function Screen(props) {
|
|
|
55
69
|
className: "lemon-route-header-center"
|
|
56
70
|
}, route.title))), /*#__PURE__*/React.createElement("div", {
|
|
57
71
|
className: "lemon-route-body"
|
|
58
|
-
}, /*#__PURE__*/createElement(route.screen))));
|
|
72
|
+
}, /*#__PURE__*/createElement(route.screen)))));
|
|
59
73
|
}
|
|
60
74
|
|
|
61
75
|
export default /*#__PURE__*/memo(Screen);
|
package/es/global.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { UserInfo } from './typings';
|
|
1
2
|
interface Mini {
|
|
2
3
|
getSystemInfoSync(): {
|
|
3
4
|
statusBarHeight: number;
|
|
@@ -19,6 +20,9 @@ interface Mini {
|
|
|
19
20
|
params: 'default' | 'light-content' | 'dark-content';
|
|
20
21
|
}): void;
|
|
21
22
|
exit(): void;
|
|
23
|
+
getUserInfo(opt: {
|
|
24
|
+
success?: (user: UserInfo) => void;
|
|
25
|
+
}): void;
|
|
22
26
|
}
|
|
23
27
|
declare global {
|
|
24
28
|
interface Window {
|
package/es/global.js
CHANGED
|
@@ -15,7 +15,8 @@ export var mini = {
|
|
|
15
15
|
getExtraPayload: function getExtraPayload() {},
|
|
16
16
|
scanCode: function scanCode() {},
|
|
17
17
|
exit: function exit() {},
|
|
18
|
-
setStatusBarStyle: function setStatusBarStyle() {}
|
|
18
|
+
setStatusBarStyle: function setStatusBarStyle() {},
|
|
19
|
+
getUserInfo: function getUserInfo() {}
|
|
19
20
|
};
|
|
20
21
|
export function createApp(render) {
|
|
21
22
|
var count = 0;
|
package/es/index.d.ts
CHANGED
package/es/typings.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lemon-fe/mini-app",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.31",
|
|
4
4
|
"description": "> TODO: description",
|
|
5
5
|
"author": "鲁盛杰 <lusj@cnlemon.net>",
|
|
6
6
|
"homepage": "",
|
|
@@ -34,5 +34,5 @@
|
|
|
34
34
|
"@types/react-transition-group": "^4.4.4",
|
|
35
35
|
"color-string": "^1.9.0"
|
|
36
36
|
},
|
|
37
|
-
"gitHead": "
|
|
37
|
+
"gitHead": "1ac5e09139b34294d3b5fb044b6143203ff44152"
|
|
38
38
|
}
|