import React, { useState, useEffect } from 'react'; import { connect } from 'react-redux'; import Weather from './public/weather'; const Header = ({ dispatch, actions, user, module, setModule, history }) => { const [tabs, setTabs] = useState([ { title: '视频监控', key: 'video' }, { title: '基础信息', key: 'basis' }, { title: '能耗监测', key: 'capacity' }, { title: '电排远控', key: 'electrical' }, { title: '实时监测', key: 'realTime' }, ]) useEffect(() => { const tabKey = sessionStorage.getItem('tabKey'); if (tabKey) { setTabs([ { title: '视频监控', key: 'video' }, { title: '能耗监测', key: 'capacity' }, { title: '电排远控', key: 'electrical' }, { title: '实时监测', key: 'realTime' }, ]) }; }, []) return
{user?.name}
{ dispatch(actions.auth.logout(user)); history.push(`/signin`); }}>退出
{tabs.map(v => { return
setModule(v.key)}>{v.title}
})}
} function mapStateToProps(state) { const { auth, global } = state; return { user: auth.user, actions: global.actions, clientHeight: global.clientHeight, } } export default connect(mapStateToProps)(Header);