@ray-js/framework 1.6.19 → 1.6.20
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/lib/components/Application/index.js +7 -8
- package/lib/components/PageWrapper/index.js +43 -44
- package/lib/components/TabBar/index.js +5 -10
- package/lib/runtime/responsive.js +3 -3
- package/lib/utils/normalizeBasename.js +1 -3
- package/lib/utils/withPublicPath.js +0 -2
- package/package.json +10 -10
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
2
1
|
import '../../runtime';
|
|
3
2
|
import React from 'react';
|
|
4
3
|
import { createRouter } from '@ray-js/router';
|
|
@@ -13,13 +12,6 @@ const isClassComponent = Component => {
|
|
|
13
12
|
export class Application extends React.Component {
|
|
14
13
|
constructor(props) {
|
|
15
14
|
super(props);
|
|
16
|
-
_defineProperty(this, "getGlobalConfig", (path, defaultValue) => {
|
|
17
|
-
const {
|
|
18
|
-
globalConfig = {}
|
|
19
|
-
} = this.props;
|
|
20
|
-
const value = get(globalConfig, path, defaultValue);
|
|
21
|
-
return value;
|
|
22
|
-
});
|
|
23
15
|
this.state = {};
|
|
24
16
|
const title = this.getGlobalConfig(['window', 'navigationBarTitleText'], 'Ray App');
|
|
25
17
|
document.title = title;
|
|
@@ -46,6 +38,13 @@ export class Application extends React.Component {
|
|
|
46
38
|
}
|
|
47
39
|
});
|
|
48
40
|
}
|
|
41
|
+
getGlobalConfig = (path, defaultValue) => {
|
|
42
|
+
const {
|
|
43
|
+
globalConfig = {}
|
|
44
|
+
} = this.props;
|
|
45
|
+
const value = get(globalConfig, path, defaultValue);
|
|
46
|
+
return value;
|
|
47
|
+
};
|
|
49
48
|
render() {
|
|
50
49
|
const {
|
|
51
50
|
app: App,
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
2
1
|
import "core-js/modules/esnext.iterator.constructor.js";
|
|
3
2
|
import "core-js/modules/esnext.iterator.for-each.js";
|
|
4
3
|
import React from 'react';
|
|
@@ -7,51 +6,9 @@ import { pageLifecycles } from '@ray-js/types';
|
|
|
7
6
|
import { get } from '../../utils';
|
|
8
7
|
import './index.module.less';
|
|
9
8
|
export class PageWrapper extends React.Component {
|
|
9
|
+
$reachBottomDistance = 50;
|
|
10
10
|
constructor(props) {
|
|
11
11
|
super(props);
|
|
12
|
-
_defineProperty(this, "$reachBottomDistance", 50);
|
|
13
|
-
_defineProperty(this, "handlePageResize", () => {
|
|
14
|
-
const windowWidth = document.documentElement.clientWidth;
|
|
15
|
-
const windowHeight = document.documentElement.clientHeight;
|
|
16
|
-
lifecycle.emit({
|
|
17
|
-
uniqueId: this.$instance.uniqueId,
|
|
18
|
-
name: pageLifecycles.onResize,
|
|
19
|
-
args: {
|
|
20
|
-
windowWidth,
|
|
21
|
-
windowHeight
|
|
22
|
-
}
|
|
23
|
-
});
|
|
24
|
-
});
|
|
25
|
-
_defineProperty(this, "handlePageScroll", () => {
|
|
26
|
-
const event = {
|
|
27
|
-
scrollTop: window.scrollY
|
|
28
|
-
};
|
|
29
|
-
lifecycle.emit({
|
|
30
|
-
uniqueId: this.$instance.uniqueId,
|
|
31
|
-
name: pageLifecycles.onPageScroll,
|
|
32
|
-
args: event
|
|
33
|
-
});
|
|
34
|
-
this.checkReachBottom();
|
|
35
|
-
});
|
|
36
|
-
_defineProperty(this, "checkReachBottom", () => {
|
|
37
|
-
const isCurrentReachBottom = document.body.scrollHeight - (window.innerHeight + window.scrollY) <= this.$reachBottomDistance;
|
|
38
|
-
if (!this.$isReachBottom && isCurrentReachBottom) {
|
|
39
|
-
this.$isReachBottom = true;
|
|
40
|
-
lifecycle.emit({
|
|
41
|
-
uniqueId: this.$instance.uniqueId,
|
|
42
|
-
name: pageLifecycles.onReachBottom
|
|
43
|
-
});
|
|
44
|
-
return;
|
|
45
|
-
}
|
|
46
|
-
this.$isReachBottom = isCurrentReachBottom;
|
|
47
|
-
});
|
|
48
|
-
_defineProperty(this, "getPageConfig", (field, defaultValue) => {
|
|
49
|
-
const {
|
|
50
|
-
page
|
|
51
|
-
} = this.props;
|
|
52
|
-
const pageConfig = page.config;
|
|
53
|
-
return get(pageConfig, field, defaultValue);
|
|
54
|
-
});
|
|
55
12
|
this.$instance = new PageInstance();
|
|
56
13
|
lifecycle.addInstance(this.$instance);
|
|
57
14
|
this.getGlobalConfig = this.props.getGlobalConfig;
|
|
@@ -97,6 +54,48 @@ export class PageWrapper extends React.Component {
|
|
|
97
54
|
lifecycle.removeInstance(this.$instance);
|
|
98
55
|
// TODO: 实现 onPullDownRefresh 生命周期
|
|
99
56
|
}
|
|
57
|
+
handlePageResize = () => {
|
|
58
|
+
const windowWidth = document.documentElement.clientWidth;
|
|
59
|
+
const windowHeight = document.documentElement.clientHeight;
|
|
60
|
+
lifecycle.emit({
|
|
61
|
+
uniqueId: this.$instance.uniqueId,
|
|
62
|
+
name: pageLifecycles.onResize,
|
|
63
|
+
args: {
|
|
64
|
+
windowWidth,
|
|
65
|
+
windowHeight
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
};
|
|
69
|
+
handlePageScroll = () => {
|
|
70
|
+
const event = {
|
|
71
|
+
scrollTop: window.scrollY
|
|
72
|
+
};
|
|
73
|
+
lifecycle.emit({
|
|
74
|
+
uniqueId: this.$instance.uniqueId,
|
|
75
|
+
name: pageLifecycles.onPageScroll,
|
|
76
|
+
args: event
|
|
77
|
+
});
|
|
78
|
+
this.checkReachBottom();
|
|
79
|
+
};
|
|
80
|
+
checkReachBottom = () => {
|
|
81
|
+
const isCurrentReachBottom = document.body.scrollHeight - (window.innerHeight + window.scrollY) <= this.$reachBottomDistance;
|
|
82
|
+
if (!this.$isReachBottom && isCurrentReachBottom) {
|
|
83
|
+
this.$isReachBottom = true;
|
|
84
|
+
lifecycle.emit({
|
|
85
|
+
uniqueId: this.$instance.uniqueId,
|
|
86
|
+
name: pageLifecycles.onReachBottom
|
|
87
|
+
});
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
this.$isReachBottom = isCurrentReachBottom;
|
|
91
|
+
};
|
|
92
|
+
getPageConfig = (field, defaultValue) => {
|
|
93
|
+
const {
|
|
94
|
+
page
|
|
95
|
+
} = this.props;
|
|
96
|
+
const pageConfig = page.config;
|
|
97
|
+
return get(pageConfig, field, defaultValue);
|
|
98
|
+
};
|
|
100
99
|
render() {
|
|
101
100
|
const {
|
|
102
101
|
page,
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
2
1
|
import "core-js/modules/esnext.iterator.map.js";
|
|
3
|
-
import "core-js/modules/web.dom-collections.iterator.js";
|
|
4
2
|
import clsx from 'clsx';
|
|
5
3
|
import React from 'react';
|
|
6
4
|
import router from '@ray-js/router';
|
|
@@ -8,13 +6,10 @@ import { events, appStoreEmitter, renderOptions } from '../../store/appStore';
|
|
|
8
6
|
import { withPublicPath } from '../../utils';
|
|
9
7
|
import styles from './index.module.less';
|
|
10
8
|
export class TabBar extends React.Component {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
renderOptions: renderOptions
|
|
16
|
-
});
|
|
17
|
-
}
|
|
9
|
+
state = (() => ({
|
|
10
|
+
currentRoute: router.scheduler.currentRoute,
|
|
11
|
+
renderOptions: renderOptions
|
|
12
|
+
}))();
|
|
18
13
|
componentDidMount() {
|
|
19
14
|
this.unChangeHandle = router.scheduler.on('routeChange', route => {
|
|
20
15
|
this.setState({
|
|
@@ -62,7 +57,7 @@ export class TabBar extends React.Component {
|
|
|
62
57
|
}
|
|
63
58
|
}, item.icon && /*#__PURE__*/React.createElement("img", {
|
|
64
59
|
className: styles.icon,
|
|
65
|
-
src:
|
|
60
|
+
src: `${withPublicPath(isActive ? item.activeIcon : item.icon)}`
|
|
66
61
|
}), /*#__PURE__*/React.createElement("span", {
|
|
67
62
|
className: styles.text,
|
|
68
63
|
style: {
|
|
@@ -3,13 +3,13 @@ export function responsive() {
|
|
|
3
3
|
function setRem() {
|
|
4
4
|
let clientWidth = htmlRoot.clientWidth;
|
|
5
5
|
// clientWidth = Math.min(clientWidth, 640); // PC 模式下限定最大值
|
|
6
|
-
htmlRoot.style.fontSize =
|
|
6
|
+
htmlRoot.style.fontSize = `${clientWidth / 7.5}px`;
|
|
7
7
|
const div = document.createElement('div');
|
|
8
8
|
div.style.width = '7.5rem';
|
|
9
9
|
document.body.appendChild(div);
|
|
10
|
-
htmlRoot.style.fontSize =
|
|
10
|
+
htmlRoot.style.fontSize = `${parseFloat(htmlRoot.style.fontSize) * clientWidth / div.clientWidth}px`;
|
|
11
11
|
document.body.removeChild(div);
|
|
12
|
-
document.body.style.fontSize =
|
|
12
|
+
document.body.style.fontSize = `16px`;
|
|
13
13
|
}
|
|
14
14
|
let b = null;
|
|
15
15
|
window.addEventListener('resize', function () {
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
import "core-js/modules/es.regexp.exec.js";
|
|
2
1
|
import slash from 'slash';
|
|
3
2
|
export function normalizeBasename(p) {
|
|
4
|
-
|
|
5
|
-
p = slash((_p = p) !== null && _p !== void 0 ? _p : '/');
|
|
3
|
+
p = slash(p !== null && p !== void 0 ? p : '/');
|
|
6
4
|
if (!/^\//.test(p)) {
|
|
7
5
|
p = '/' + p;
|
|
8
6
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ray-js/framework",
|
|
3
|
-
"version": "1.6.
|
|
3
|
+
"version": "1.6.20",
|
|
4
4
|
"description": "Ray Core",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ray"
|
|
@@ -23,12 +23,12 @@
|
|
|
23
23
|
"watch": "tsc -p ./tsconfig.build.json --module esnext --outDir lib --watch"
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@ray-js/framework-mp": "1.6.
|
|
27
|
-
"@ray-js/framework-shared": "1.6.
|
|
28
|
-
"@ray-js/library": "1.6.
|
|
29
|
-
"@ray-js/location": "1.6.
|
|
30
|
-
"@ray-js/router": "1.6.
|
|
31
|
-
"@ray-js/runtime": "1.6.
|
|
26
|
+
"@ray-js/framework-mp": "1.6.20",
|
|
27
|
+
"@ray-js/framework-shared": "1.6.20",
|
|
28
|
+
"@ray-js/library": "1.6.20",
|
|
29
|
+
"@ray-js/location": "1.6.20",
|
|
30
|
+
"@ray-js/router": "1.6.20",
|
|
31
|
+
"@ray-js/runtime": "1.6.20",
|
|
32
32
|
"clsx": "^1.2.1",
|
|
33
33
|
"hoist-non-react-statics": "^3.3.2",
|
|
34
34
|
"lodash.get": "^4.4.2",
|
|
@@ -37,12 +37,12 @@
|
|
|
37
37
|
"tiny-invariant": "^1.3.3"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
|
-
"@ray-js/cli": "1.6.
|
|
41
|
-
"@ray-js/types": "1.6.
|
|
40
|
+
"@ray-js/cli": "1.6.20",
|
|
41
|
+
"@ray-js/types": "1.6.20"
|
|
42
42
|
},
|
|
43
43
|
"publishConfig": {
|
|
44
44
|
"access": "public",
|
|
45
45
|
"registry": "https://registry.npmjs.com"
|
|
46
46
|
},
|
|
47
|
-
"gitHead": "
|
|
47
|
+
"gitHead": "09a3ae02055470a3c05e953f2a4aec0d34c12952"
|
|
48
48
|
}
|