1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192 |
- /* eslint no-undef: 0 */
- /* eslint arrow-parens: 0 */
- import React from 'react';
- import { enquireScreen } from 'enquire-js';
- import Nav0 from './Nav0';
- import Content13 from './Content13';
- import Footer0 from './Footer0';
- import {
- Nav00DataSource,
- Content130DataSource,
- Footer00DataSource,
- } from './data.source';
- import './less/antMotionStyle.less';
- import MyMap from '../../components/Map'
- let isMobile;
- enquireScreen((b) => {
- isMobile = b;
- });
- const { location = {} } = typeof window !== 'undefined' ? window : {};
- export default class Home extends React.Component {
- constructor(props) {
- super(props);
- this.state = {
- isMobile,
- show: !location.port, // 如果不是 dva 2.0 请删除
- };
- }
- componentDidMount() {
- // 适配手机屏幕;
- enquireScreen((b) => {
- this.setState({ isMobile: !!b });
- });
- // dva 2.0 样式在组件渲染之后动态加载,导致滚动组件不生效;线上不影响;
- /* 如果不是 dva 2.0 请删除 start */
- if (location.port) {
- // 样式 build 时间在 200-300ms 之间;
- setTimeout(() => {
- this.setState({
- show: true,
- });
- }, 500);
- }
- /* 如果不是 dva 2.0 请删除 end */
- }
- render() {
- const children = [
- <Nav0
- id="Nav0_0"
- key="Nav0_0"
- dataSource={Nav00DataSource}
- isMobile={this.state.isMobile}
- />,
- <Content13
- id="Content13_0"
- key="Content13_0"
- dataSource={Content130DataSource}
- isMobile={this.state.isMobile}
- />,
- <MyMap
- id="Content13_1"
- key="Content13_1"
- isMobile={this.state.isMobile}
- />,
- <Footer0
- id="Footer0_0"
- key="Footer0_0"
- dataSource={Footer00DataSource}
- isMobile={this.state.isMobile}
- />,
- ];
- return (
- <div
- className="templates-wrapper"
- ref={(d) => {
- this.dom = d;
- }}
- >
- {/* 如果不是 dva 2.0 替换成 {children} start */}
- {this.state.show && children}
- {/* 如果不是 dva 2.0 替换成 {children} end */}
- </div>
- );
- }
- }
|