@ray-js/framework 0.5.7-beta-2 → 0.5.9
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/api/index.js +1 -1
- package/lib/api/tabBar.js +9 -17
- package/lib/app/createApp.jsx +10 -0
- package/lib/app/createAppInstance.jsx +12 -0
- package/lib/app/index.d.ts +1 -2
- package/lib/app/index.js +0 -1
- package/lib/app/index.jsx +6 -0
- package/lib/components/AppWrapper/index.d.ts +3 -1
- package/lib/components/AppWrapper/index.jsx +29 -0
- package/lib/components/Application/index.d.ts +1 -1
- package/lib/components/Application/index.jsx +58 -0
- package/lib/components/PageWrapper/index.d.ts +1 -0
- package/lib/components/PageWrapper/index.jsx +117 -0
- package/lib/components/TabBar/index.jsx +54 -0
- package/lib/createApp.jsx +10 -0
- package/lib/index.d.ts +1 -1
- package/lib/index.js +2 -2
- package/lib/runtime/index.js +3 -3
- package/lib/runtime/responsive.js +19 -21
- package/lib/store/appStore.js +18 -20
- package/lib/utils/index.js +1 -1
- package/lib/utils/normalizeTabBar.js +10 -17
- package/lib/utils/withPublicPath.js +2 -4
- package/package.json +10 -11
- package/lib/index.native.d.ts +0 -1
- package/lib/index.native.js +0 -1
package/lib/api/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { showTabBar, hideTabBar } from './tabBar';
|
|
1
|
+
export { showTabBar, hideTabBar } from './tabBar';
|
package/lib/api/tabBar.js
CHANGED
|
@@ -1,21 +1,13 @@
|
|
|
1
1
|
import { appStoreEmitter, actions } from '../store/appStore';
|
|
2
2
|
export function showTabBar(options) {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
animation: options.animation
|
|
8
|
-
});
|
|
9
|
-
options === null || options === void 0 ? void 0 : (_options$success = options.success) === null || _options$success === void 0 ? void 0 : _options$success.call(options);
|
|
10
|
-
options === null || options === void 0 ? void 0 : (_options$complete = options.complete) === null || _options$complete === void 0 ? void 0 : _options$complete.call(options);
|
|
3
|
+
var _a, _b;
|
|
4
|
+
appStoreEmitter.emit(actions.toggleTabBar, { visible: true, animation: options.animation });
|
|
5
|
+
(_a = options === null || options === void 0 ? void 0 : options.success) === null || _a === void 0 ? void 0 : _a.call(options);
|
|
6
|
+
(_b = options === null || options === void 0 ? void 0 : options.complete) === null || _b === void 0 ? void 0 : _b.call(options);
|
|
11
7
|
}
|
|
12
8
|
export function hideTabBar(options) {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
});
|
|
19
|
-
options === null || options === void 0 ? void 0 : (_options$success2 = options.success) === null || _options$success2 === void 0 ? void 0 : _options$success2.call(options);
|
|
20
|
-
options === null || options === void 0 ? void 0 : (_options$complete2 = options.complete) === null || _options$complete2 === void 0 ? void 0 : _options$complete2.call(options);
|
|
21
|
-
}
|
|
9
|
+
var _a, _b;
|
|
10
|
+
appStoreEmitter.emit(actions.toggleTabBar, { visible: false, animation: options.animation });
|
|
11
|
+
(_a = options === null || options === void 0 ? void 0 : options.success) === null || _a === void 0 ? void 0 : _a.call(options);
|
|
12
|
+
(_b = options === null || options === void 0 ? void 0 : options.complete) === null || _b === void 0 ? void 0 : _b.call(options);
|
|
13
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import ReactDOM from 'react-dom';
|
|
3
|
+
import { Application } from '../components/Application';
|
|
4
|
+
export function createApp(options) {
|
|
5
|
+
const root = document.createElement('div');
|
|
6
|
+
root.id = 'root';
|
|
7
|
+
document.body.appendChild(root);
|
|
8
|
+
// 作为 web 构建的启动入口文件
|
|
9
|
+
ReactDOM.render(<Application {...options}/>, root);
|
|
10
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { getCurrent } from '@ray-js/runtime';
|
|
2
|
+
/**
|
|
3
|
+
* 创建抽象的 App Instance 对标到小程序,提供给 getApp() 进行使用
|
|
4
|
+
* @param appThis
|
|
5
|
+
*/
|
|
6
|
+
export function createAppInstance(appThis) {
|
|
7
|
+
const current = getCurrent();
|
|
8
|
+
// App 实例仅且注册一次
|
|
9
|
+
if (!current.app) {
|
|
10
|
+
current.app = appThis;
|
|
11
|
+
}
|
|
12
|
+
}
|
package/lib/app/index.d.ts
CHANGED
package/lib/app/index.js
CHANGED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import styles from './index.module.less';
|
|
3
|
+
import { getApp } from '../../app';
|
|
4
|
+
import location from '@ray-js/location';
|
|
5
|
+
export class AppWrapper extends React.Component {
|
|
6
|
+
componentDidMount() {
|
|
7
|
+
const app = getApp();
|
|
8
|
+
if (typeof app.onLaunch === 'function') {
|
|
9
|
+
app.onLaunch({
|
|
10
|
+
path: location.pathname,
|
|
11
|
+
query: location.query,
|
|
12
|
+
params: location.params,
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
// 初次展现
|
|
16
|
+
if (typeof app.onShow === 'function') {
|
|
17
|
+
app.onShow({
|
|
18
|
+
path: location.pathname,
|
|
19
|
+
query: location.query,
|
|
20
|
+
params: location.params,
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
render() {
|
|
25
|
+
return (<div id='Application' className={styles.application}>
|
|
26
|
+
{this.props.children}
|
|
27
|
+
</div>);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
@@ -16,5 +16,5 @@ export declare class Application extends React.Component<ApplicationProps, {
|
|
|
16
16
|
constructor(props: Readonly<ApplicationProps>);
|
|
17
17
|
componentDidMount(): void;
|
|
18
18
|
getGlobalConfig: (path: string | string[], defaultValue?: any) => any;
|
|
19
|
-
render(): JSX.Element
|
|
19
|
+
render(): JSX.Element;
|
|
20
20
|
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import '../../runtime';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { createRouter } from '@ray-js/router';
|
|
4
|
+
import { createAppInstance } from '../../app/createAppInstance';
|
|
5
|
+
import { get } from '../../utils';
|
|
6
|
+
import { normalizeTabBar } from '../../utils/normalizeTabBar';
|
|
7
|
+
import { AppWrapper } from '../AppWrapper';
|
|
8
|
+
import { PageWrapper } from '../PageWrapper';
|
|
9
|
+
import { TabBar } from '../TabBar';
|
|
10
|
+
const isClassComponent = (Component) => {
|
|
11
|
+
return Component.prototype && typeof Component.prototype.render === 'function';
|
|
12
|
+
};
|
|
13
|
+
export class Application extends React.Component {
|
|
14
|
+
constructor(props) {
|
|
15
|
+
super(props);
|
|
16
|
+
this.getGlobalConfig = (path, defaultValue) => {
|
|
17
|
+
const { globalConfig = {} } = this.props;
|
|
18
|
+
const value = get(globalConfig, path, defaultValue);
|
|
19
|
+
return value;
|
|
20
|
+
};
|
|
21
|
+
this.state = {};
|
|
22
|
+
const title = this.getGlobalConfig(['window', 'navigationBarTitleText'], 'Ray App');
|
|
23
|
+
document.title = title;
|
|
24
|
+
}
|
|
25
|
+
componentDidMount() {
|
|
26
|
+
const { routes, pages, tabBar, globalConfig } = this.props;
|
|
27
|
+
const { basename } = globalConfig;
|
|
28
|
+
document.body.style.backgroundColor = this.getGlobalConfig(['window', 'backgroundColor'], '#fff');
|
|
29
|
+
createRouter({
|
|
30
|
+
basename,
|
|
31
|
+
routes,
|
|
32
|
+
pages,
|
|
33
|
+
tabBar,
|
|
34
|
+
onChange: (component, props) => {
|
|
35
|
+
this.setState({ component, matchedPage: props.page });
|
|
36
|
+
},
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
render() {
|
|
40
|
+
const { app: App, tabBar, routes, basename } = this.props;
|
|
41
|
+
const { component: PageComponent, matchedPage } = this.state;
|
|
42
|
+
// 空页面暂不渲染,否则 appEvent 无法应用到页面内部
|
|
43
|
+
if (!matchedPage) {
|
|
44
|
+
return null;
|
|
45
|
+
}
|
|
46
|
+
const isClassType = isClassComponent(PageComponent);
|
|
47
|
+
return (<AppWrapper>
|
|
48
|
+
<App ref={(appThis) => {
|
|
49
|
+
createAppInstance(appThis);
|
|
50
|
+
}}>
|
|
51
|
+
<PageWrapper isClassType={isClassType} page={matchedPage} key={matchedPage.route} getGlobalConfig={this.getGlobalConfig}>
|
|
52
|
+
<PageComponent />
|
|
53
|
+
</PageWrapper>
|
|
54
|
+
{matchedPage.isTabBar && (<TabBar basename={basename} config={normalizeTabBar(tabBar, routes)}/>)}
|
|
55
|
+
</App>
|
|
56
|
+
</AppWrapper>);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
@@ -6,6 +6,7 @@ declare type PageWrapperProps = {
|
|
|
6
6
|
isClassType: boolean;
|
|
7
7
|
page: Page;
|
|
8
8
|
getGlobalConfig: (path: string | string[], defaultValue?: any) => any;
|
|
9
|
+
children: any;
|
|
9
10
|
};
|
|
10
11
|
export declare class PageWrapper extends React.Component<PageWrapperProps, any> {
|
|
11
12
|
$instance: PageInstance;
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
// import { normalizeTabBar } from '../../utils/normalizeTabBar';
|
|
3
|
+
import { lifecycle, PageInstance, PageInstanceContext } from '@ray-js/runtime';
|
|
4
|
+
import { pageLifecycles } from '@ray-js/types';
|
|
5
|
+
import { get } from '../../utils';
|
|
6
|
+
import './index.module.less';
|
|
7
|
+
export class PageWrapper extends React.Component {
|
|
8
|
+
constructor(props) {
|
|
9
|
+
super(props);
|
|
10
|
+
this.$reachBottomDistance = 50;
|
|
11
|
+
this.handlePageResize = () => {
|
|
12
|
+
const windowWidth = document.documentElement.clientWidth;
|
|
13
|
+
const windowHeight = document.documentElement.clientHeight;
|
|
14
|
+
lifecycle.emit({
|
|
15
|
+
uniqueId: this.$instance.uniqueId,
|
|
16
|
+
name: pageLifecycles.onResize,
|
|
17
|
+
args: { windowWidth, windowHeight },
|
|
18
|
+
});
|
|
19
|
+
};
|
|
20
|
+
this.handlePageScroll = () => {
|
|
21
|
+
const event = { scrollTop: window.scrollY };
|
|
22
|
+
lifecycle.emit({
|
|
23
|
+
uniqueId: this.$instance.uniqueId,
|
|
24
|
+
name: pageLifecycles.onPageScroll,
|
|
25
|
+
args: event,
|
|
26
|
+
});
|
|
27
|
+
this.checkReachBottom();
|
|
28
|
+
};
|
|
29
|
+
this.checkReachBottom = () => {
|
|
30
|
+
const isCurrentReachBottom = document.body.scrollHeight - (window.innerHeight + window.scrollY) <=
|
|
31
|
+
this.$reachBottomDistance;
|
|
32
|
+
if (!this.$isReachBottom && isCurrentReachBottom) {
|
|
33
|
+
this.$isReachBottom = true;
|
|
34
|
+
lifecycle.emit({
|
|
35
|
+
uniqueId: this.$instance.uniqueId,
|
|
36
|
+
name: pageLifecycles.onReachBottom,
|
|
37
|
+
});
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
this.$isReachBottom = isCurrentReachBottom;
|
|
41
|
+
};
|
|
42
|
+
this.getPageConfig = (field, defaultValue) => {
|
|
43
|
+
const { page } = this.props;
|
|
44
|
+
const pageConfig = page.config;
|
|
45
|
+
return get(pageConfig, field, defaultValue);
|
|
46
|
+
};
|
|
47
|
+
this.$instance = new PageInstance();
|
|
48
|
+
lifecycle.addInstance(this.$instance);
|
|
49
|
+
this.getGlobalConfig = this.props.getGlobalConfig;
|
|
50
|
+
}
|
|
51
|
+
componentDidMount() {
|
|
52
|
+
const title = this.getPageConfig('navigationBarTitleText', '');
|
|
53
|
+
document.title = title;
|
|
54
|
+
window.addEventListener('scroll', this.handlePageScroll);
|
|
55
|
+
window.addEventListener('resize', this.handlePageResize);
|
|
56
|
+
const backgroundColor = this.getPageConfig('backgroundColor');
|
|
57
|
+
if (backgroundColor) {
|
|
58
|
+
document.body.style.backgroundColor = backgroundColor;
|
|
59
|
+
}
|
|
60
|
+
// 获取页面触底的距离
|
|
61
|
+
this.$reachBottomDistance = this.getPageConfig('onReachBottomDistance', this.getGlobalConfig(['window', 'onReachBottomDistance'], 50) // 全局配置
|
|
62
|
+
);
|
|
63
|
+
// FIXME: 应用实例化未完成,didMount 从内至外执行
|
|
64
|
+
// 此时触发 onShow onReady 获取不到 getApp 实例,组件内也存在这样的情况
|
|
65
|
+
lifecycle.emit({
|
|
66
|
+
uniqueId: this.$instance.uniqueId,
|
|
67
|
+
name: pageLifecycles.onShow,
|
|
68
|
+
});
|
|
69
|
+
lifecycle.emit({
|
|
70
|
+
uniqueId: this.$instance.uniqueId,
|
|
71
|
+
name: pageLifecycles.onReady,
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
componentWillUnmount() {
|
|
75
|
+
window.removeEventListener('scroll', this.handlePageScroll);
|
|
76
|
+
window.removeEventListener('resize', this.handlePageResize);
|
|
77
|
+
// FIXME: 目前是 SPA 的页面直接切换,卸载前直接调用事件
|
|
78
|
+
lifecycle.emit({
|
|
79
|
+
uniqueId: this.$instance.uniqueId,
|
|
80
|
+
name: pageLifecycles.onHide,
|
|
81
|
+
});
|
|
82
|
+
lifecycle.emit({
|
|
83
|
+
uniqueId: this.$instance.uniqueId,
|
|
84
|
+
name: pageLifecycles.onUnload,
|
|
85
|
+
});
|
|
86
|
+
lifecycle.removeInstance(this.$instance);
|
|
87
|
+
// TODO: 实现 onPullDownRefresh 生命周期
|
|
88
|
+
}
|
|
89
|
+
render() {
|
|
90
|
+
const { page, children, isClassType } = this.props;
|
|
91
|
+
const $instance = this.$instance;
|
|
92
|
+
const globalBackgroundColor = this.getGlobalConfig(['window', 'backgroundColor'], '#fff');
|
|
93
|
+
const backgroundColor = this.getPageConfig('backgroundColor', globalBackgroundColor);
|
|
94
|
+
document.body.style.backgroundColor = backgroundColor;
|
|
95
|
+
return (<PageInstanceContext.Provider value={{ $instance, pageConfig: page.config }}>
|
|
96
|
+
<v-page data-route={page.route}>
|
|
97
|
+
{isClassType
|
|
98
|
+
? // @ts-ignore
|
|
99
|
+
React.cloneElement(children, {
|
|
100
|
+
ref(ins) {
|
|
101
|
+
if (ins) {
|
|
102
|
+
// 实现 class 生命周期用法的挂载
|
|
103
|
+
Object.keys(pageLifecycles).forEach((event) => {
|
|
104
|
+
if (typeof ins[event] === 'function') {
|
|
105
|
+
$instance.registerLifecycle(event, ins, ins[event]);
|
|
106
|
+
}
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
},
|
|
110
|
+
})
|
|
111
|
+
: children}
|
|
112
|
+
{/* TODO: 如果需要转场动画,需要在 PageWrapper 中渲染 */}
|
|
113
|
+
{/* {page?.isTabBar && <TabBar config={tabBarConfig} />} */}
|
|
114
|
+
</v-page>
|
|
115
|
+
</PageInstanceContext.Provider>);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import clsx from 'clsx';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import router from '@ray-js/router';
|
|
4
|
+
import { events, appStoreEmitter, renderOptions } from '../../store/appStore';
|
|
5
|
+
import { withPublicPath } from '../../utils/withPublicPath';
|
|
6
|
+
import styles from './index.module.less';
|
|
7
|
+
export class TabBar extends React.Component {
|
|
8
|
+
constructor() {
|
|
9
|
+
super(...arguments);
|
|
10
|
+
this.state = {
|
|
11
|
+
currentRoute: router.scheduler.currentRoute,
|
|
12
|
+
renderOptions: renderOptions,
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
componentDidMount() {
|
|
16
|
+
this.unChangeHandle = router.scheduler.on('routeChange', (route) => {
|
|
17
|
+
this.setState({
|
|
18
|
+
currentRoute: route,
|
|
19
|
+
});
|
|
20
|
+
});
|
|
21
|
+
this.unAppStoreChange = appStoreEmitter.on(events.tabBarChange, (state) => {
|
|
22
|
+
this.setState({ renderOptions: state });
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
componentWillUnmount() {
|
|
26
|
+
var _a, _b;
|
|
27
|
+
(_a = this.unChangeHandle) === null || _a === void 0 ? void 0 : _a.call(this);
|
|
28
|
+
(_b = this.unAppStoreChange) === null || _b === void 0 ? void 0 : _b.call(this);
|
|
29
|
+
}
|
|
30
|
+
render() {
|
|
31
|
+
const { config, basename = '' } = this.props;
|
|
32
|
+
const { currentRoute, renderOptions } = this.state;
|
|
33
|
+
return (<div data-route={currentRoute} className={clsx(styles.wrapper, {
|
|
34
|
+
[styles.hidden]: !renderOptions.tabBarVisible && !renderOptions.tabBarAnimation,
|
|
35
|
+
[styles.showIn]: renderOptions.tabBarVisible && renderOptions.tabBarAnimation,
|
|
36
|
+
[styles.hideOut]: !renderOptions.tabBarVisible && renderOptions.tabBarAnimation,
|
|
37
|
+
})}>
|
|
38
|
+
<div className={styles.tabBar}>
|
|
39
|
+
{config.list.map((item) => {
|
|
40
|
+
const fullRoute = basename + item.route;
|
|
41
|
+
const isActive = currentRoute === fullRoute;
|
|
42
|
+
return (<div data-full-route={fullRoute} key={item.route || item.id} className={styles.item} onClick={() => {
|
|
43
|
+
router.push(item.route);
|
|
44
|
+
}}>
|
|
45
|
+
{item.icon && (<img className={styles.icon} src={`${withPublicPath(isActive ? item.activeIcon : item.icon)}`}/>)}
|
|
46
|
+
<span className={styles.text} style={{ color: isActive ? config.selectedColor : config.textColor }}>
|
|
47
|
+
{item.text}
|
|
48
|
+
</span>
|
|
49
|
+
</div>);
|
|
50
|
+
})}
|
|
51
|
+
</div>
|
|
52
|
+
</div>);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import ReactDOM from 'react-dom';
|
|
3
|
+
import { Application } from './components/Application';
|
|
4
|
+
export function createApp(options) {
|
|
5
|
+
const root = document.createElement('div');
|
|
6
|
+
root.id = 'root';
|
|
7
|
+
document.body.appendChild(root);
|
|
8
|
+
// 作为 web 构建的启动入口文件
|
|
9
|
+
ReactDOM.render(<Application {...options}/>, root);
|
|
10
|
+
}
|
package/lib/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export { createApp, getApp } from './app';
|
|
2
|
-
export { lifecycle, PageInstance, PageInstanceContext, useAppEvent, usePageEvent,
|
|
2
|
+
export { lifecycle, PageInstance, PageInstanceContext, withPageLifecycle, useAppEvent, usePageEvent, useNativeEffect, useQuery, usePageInstance, useComponentInstance, } from '@ray-js/runtime';
|
|
3
3
|
export * from './api';
|
package/lib/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export { createApp, getApp } from './app';
|
|
2
|
-
export { lifecycle, PageInstance, PageInstanceContext, useAppEvent, usePageEvent,
|
|
3
|
-
export * from './api';
|
|
2
|
+
export { lifecycle, PageInstance, PageInstanceContext, withPageLifecycle, useAppEvent, usePageEvent, useNativeEffect, useQuery, usePageInstance, useComponentInstance, } from '@ray-js/runtime';
|
|
3
|
+
export * from './api';
|
package/lib/runtime/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { responsive } from './responsive';
|
|
2
|
-
|
|
3
|
-
responsive();
|
|
1
|
+
import { responsive } from './responsive';
|
|
2
|
+
// 响应式设计 rem 单位
|
|
3
|
+
responsive();
|
|
@@ -1,22 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
var htmlRoot = document.querySelector('html');
|
|
1
|
+
const htmlRoot = document.querySelector('html');
|
|
3
2
|
export function responsive() {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
}
|
|
3
|
+
function setRem() {
|
|
4
|
+
let clientWidth = htmlRoot.clientWidth;
|
|
5
|
+
// clientWidth = Math.min(clientWidth, 640); // PC 模式下限定最大值
|
|
6
|
+
htmlRoot.style.fontSize = `${clientWidth / 7.5}px`;
|
|
7
|
+
const div = document.createElement('div');
|
|
8
|
+
div.style.width = '7.5rem';
|
|
9
|
+
document.body.appendChild(div);
|
|
10
|
+
htmlRoot.style.fontSize = `${(parseFloat(htmlRoot.style.fontSize) * clientWidth) / div.clientWidth}px`;
|
|
11
|
+
document.body.removeChild(div);
|
|
12
|
+
document.body.style.fontSize = `16px`;
|
|
13
|
+
}
|
|
14
|
+
let b = null;
|
|
15
|
+
window.addEventListener('resize', function () {
|
|
16
|
+
clearTimeout(b);
|
|
17
|
+
b = setTimeout(setRem, 100);
|
|
18
|
+
}, !1);
|
|
19
|
+
setRem();
|
|
20
|
+
}
|
package/lib/store/appStore.js
CHANGED
|
@@ -1,26 +1,24 @@
|
|
|
1
|
-
import "core-js/modules/es.object.assign.js";
|
|
2
1
|
import { Emitter } from '@ray-js/framework-shared';
|
|
3
|
-
export
|
|
4
|
-
export
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
export const appStoreEmitter = new Emitter();
|
|
3
|
+
export const renderOptions = {
|
|
4
|
+
tabBarVisible: true,
|
|
5
|
+
tabBarAnimation: false,
|
|
7
6
|
};
|
|
8
|
-
export
|
|
9
|
-
|
|
10
|
-
|
|
7
|
+
export const actions = {
|
|
8
|
+
toggleTabBar: 'toggleTabBar',
|
|
9
|
+
onChange: 'onChange',
|
|
11
10
|
};
|
|
12
|
-
export
|
|
13
|
-
|
|
11
|
+
export const events = {
|
|
12
|
+
tabBarChange: 'tabBarChange',
|
|
14
13
|
};
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
appStoreEmitter.emit(eventName, renderOptions);
|
|
14
|
+
const update = (eventName, nextState) => {
|
|
15
|
+
Object.assign(renderOptions, nextState);
|
|
16
|
+
appStoreEmitter.emit(eventName, renderOptions);
|
|
19
17
|
};
|
|
20
|
-
|
|
21
18
|
appStoreEmitter.on(actions.toggleTabBar, function (next) {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
});
|
|
19
|
+
if (next.visible !== renderOptions.tabBarVisible)
|
|
20
|
+
update(events.tabBarChange, {
|
|
21
|
+
tabBarVisible: next.visible,
|
|
22
|
+
tabBarAnimation: next.animation,
|
|
23
|
+
});
|
|
24
|
+
});
|
package/lib/utils/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import get from 'lodash.get';
|
|
2
|
-
export { get };
|
|
2
|
+
export { get };
|
|
@@ -1,18 +1,11 @@
|
|
|
1
|
-
import "core-js/modules/es.array.map.js";
|
|
2
|
-
import "core-js/modules/es.array.find.js";
|
|
3
|
-
import "core-js/modules/es.object.to-string.js";
|
|
4
1
|
export function normalizeTabBar(tabBar, routes) {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
return tabBar;
|
|
18
|
-
}
|
|
2
|
+
if (tabBar.list) {
|
|
3
|
+
tabBar.list = tabBar.list.map((item) => {
|
|
4
|
+
if (item.id) {
|
|
5
|
+
item.route = routes.find((i) => i.id === item.id).route;
|
|
6
|
+
}
|
|
7
|
+
return item;
|
|
8
|
+
});
|
|
9
|
+
}
|
|
10
|
+
return tabBar;
|
|
11
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ray-js/framework",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.9",
|
|
4
4
|
"description": "Ray Core",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ray"
|
|
@@ -20,21 +20,20 @@
|
|
|
20
20
|
"watch": "tsc -p ./tsconfig.build.json --module esnext --outDir lib --watch"
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@ray-js/framework-mp": "^0.5.
|
|
24
|
-
"@ray-js/framework-
|
|
25
|
-
"@ray-js/
|
|
26
|
-
"@ray-js/
|
|
27
|
-
"@ray-js/
|
|
28
|
-
"@ray-js/
|
|
29
|
-
"@ray-js/runtime": "^0.5.7-beta-2",
|
|
23
|
+
"@ray-js/framework-mp": "^0.5.9",
|
|
24
|
+
"@ray-js/framework-shared": "^0.5.9",
|
|
25
|
+
"@ray-js/library": "^0.5.9",
|
|
26
|
+
"@ray-js/location": "^0.5.9",
|
|
27
|
+
"@ray-js/router": "^0.5.9",
|
|
28
|
+
"@ray-js/runtime": "^0.5.9",
|
|
30
29
|
"clsx": "^1.1.1",
|
|
31
30
|
"hoist-non-react-statics": "^3.3.2",
|
|
32
31
|
"lodash.get": "^4.4.2",
|
|
33
32
|
"tiny-invariant": "^1.1.0"
|
|
34
33
|
},
|
|
35
34
|
"devDependencies": {
|
|
36
|
-
"@ray-js/cli": "^0.5.
|
|
37
|
-
"@ray-js/types": "^0.5.
|
|
35
|
+
"@ray-js/cli": "^0.5.9",
|
|
36
|
+
"@ray-js/types": "^0.5.9"
|
|
38
37
|
},
|
|
39
38
|
"maintainers": [
|
|
40
39
|
{
|
|
@@ -42,6 +41,6 @@
|
|
|
42
41
|
"email": "tuyafe@tuya.com"
|
|
43
42
|
}
|
|
44
43
|
],
|
|
45
|
-
"gitHead": "
|
|
44
|
+
"gitHead": "8618821f05c00f4987138f5b523ae6261e32c9a6",
|
|
46
45
|
"repository": {}
|
|
47
46
|
}
|
package/lib/index.native.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from '@ray-js/framework-native';
|
package/lib/index.native.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from '@ray-js/framework-native';
|