import React, { Component } from 'react'; import Routes from './routes'; import DocumentTitle from 'react-document-title'; import SiderCustom from './components/SiderCustom'; import HeaderCustom from './components/HeaderCustom'; import { Layout, notification, Icon } from 'antd'; import { ThemePicker } from './components/widget'; import { connectAlita } from 'redux-alita'; import './data/index' const { Content, Footer } = Layout; class App extends Component { state = { collapsed: false, title: '', }; componentWillMount() { const { setAlitaState } = this.props; const user = JSON.parse(localStorage.getItem('user')); // user && receiveData(user, 'auth'); user && setAlitaState({ stateName: 'auth', data: user }); // receiveData({a: 213}, 'auth'); // fetchData({funcName: 'admin', stateName: 'auth'}); this.getClientWidth(); window.onresize = () => { console.log('屏幕变化了'); this.getClientWidth(); }; } componentDidMount() { const openNotification = () => { notification.open({ message: '博主-yezihaohao', description: (

GitHub地址:{' '} https://github.com/yezihaohao

博客地址:{' '} https://yezihaohao.github.io/

), icon: , duration: 0, }); localStorage.setItem('isFirst', JSON.stringify(true)); }; const isFirst = JSON.parse(localStorage.getItem('isFirst')); !isFirst && openNotification(); } getClientWidth = () => { // 获取当前浏览器宽度并设置responsive管理响应式 const { setAlitaState } = this.props; const clientWidth = window.innerWidth; console.log(clientWidth); setAlitaState({ stateName: 'responsive', data: { isMobile: clientWidth <= 992 } }); // receiveData({isMobile: clientWidth <= 992}, 'responsive'); }; toggle = () => { this.setState({ collapsed: !this.state.collapsed, }); }; render() { const { title } = this.state; const { auth = { data: {} }, responsive = { data: {} } } = this.props; console.log(auth); return ( {!responsive.data.isMobile && } ); } } export default connectAlita(['auth', 'responsive'])(App);