|
|
@ -4,82 +4,85 @@ import { connect } from "react-redux"; |
|
|
|
import { Nav, Avatar, Dropdown } from "@douyinfe/semi-ui"; |
|
|
|
|
|
|
|
const Header = (props) => { |
|
|
|
const { dispatch, history, user, actions, socket } = props; |
|
|
|
const { dispatch, history, user, actions, socket } = props; |
|
|
|
|
|
|
|
return ( |
|
|
|
<> |
|
|
|
<Nav |
|
|
|
mode={"horizontal"} |
|
|
|
onClick={({ itemKey }) => { |
|
|
|
if (itemKey == "logout") { |
|
|
|
dispatch(actions.auth.logout()); |
|
|
|
if (socket) { |
|
|
|
socket.disconnect(); |
|
|
|
} |
|
|
|
history.push(`/signin`); |
|
|
|
} |
|
|
|
}} |
|
|
|
style={{ |
|
|
|
height: 60, |
|
|
|
minWidth: 520, |
|
|
|
background: "url(/assets/images/background/header.png)", |
|
|
|
backgroundSize: "100% 100%", |
|
|
|
color: "white", |
|
|
|
}} |
|
|
|
header={{ |
|
|
|
logo: ( |
|
|
|
<img |
|
|
|
src="/assets/images/background/logo.png" |
|
|
|
style={{ display: "inline-block", width: 280, height: 52}} |
|
|
|
/> |
|
|
|
), |
|
|
|
text: "", |
|
|
|
}} |
|
|
|
footer={ |
|
|
|
<Nav.Sub |
|
|
|
itemKey={"user"} |
|
|
|
text={ |
|
|
|
<div |
|
|
|
return ( |
|
|
|
<> |
|
|
|
<Nav |
|
|
|
mode={"horizontal"} |
|
|
|
onClick={({ itemKey }) => { |
|
|
|
if (itemKey == "logout") { |
|
|
|
dispatch(actions.auth.logout()); |
|
|
|
if (socket) { |
|
|
|
socket.disconnect(); |
|
|
|
} |
|
|
|
history.push(`/signin`); |
|
|
|
} |
|
|
|
}} |
|
|
|
style={{ |
|
|
|
marginLeft: 20, |
|
|
|
display: "inline-block", |
|
|
|
color: "white", |
|
|
|
height: 60, |
|
|
|
minWidth: 520, |
|
|
|
background: `url(${__webpack_public_path__}assets/images/background/header.png)`, |
|
|
|
backgroundSize: "100% 100%", |
|
|
|
color: "white", |
|
|
|
}} |
|
|
|
> |
|
|
|
<img |
|
|
|
src="/assets/images/background/notice.png" |
|
|
|
style={{ |
|
|
|
display: "inline-block", |
|
|
|
width: 18, |
|
|
|
height: 18, |
|
|
|
position: "relative", |
|
|
|
top: 6, |
|
|
|
left: -10, |
|
|
|
}} |
|
|
|
/> |
|
|
|
header={{ |
|
|
|
logo: ( |
|
|
|
<img |
|
|
|
src={`/assets/images/background/logo.png`} |
|
|
|
style={{ display: "inline-block", width: 280, height: 52 }} |
|
|
|
/> |
|
|
|
), |
|
|
|
text: "", |
|
|
|
}} |
|
|
|
footer={ |
|
|
|
<Nav.Sub |
|
|
|
itemKey={"user"} |
|
|
|
dropdownStyle={{ |
|
|
|
position: 'relative' |
|
|
|
}} |
|
|
|
text={ |
|
|
|
<div |
|
|
|
style={{ |
|
|
|
marginLeft: 20, |
|
|
|
display: "inline-block", |
|
|
|
color: "white", |
|
|
|
}} |
|
|
|
> |
|
|
|
<img |
|
|
|
src={`/assets/images/background/notice.png`} |
|
|
|
style={{ |
|
|
|
display: "inline-block", |
|
|
|
width: 18, |
|
|
|
height: 18, |
|
|
|
position: "relative", |
|
|
|
top: 6, |
|
|
|
left: -10, |
|
|
|
}} |
|
|
|
/> |
|
|
|
|
|
|
|
<Avatar size="small" color="light-blue" style={{ margin: 4 }}> |
|
|
|
<img src="/assets/images/avatar/6.png" /> |
|
|
|
</Avatar> |
|
|
|
{user && user.namePresent} |
|
|
|
</div> |
|
|
|
} |
|
|
|
> |
|
|
|
<Nav.Item itemKey={"logout"} text={"退出"} /> |
|
|
|
</Nav.Sub> |
|
|
|
} |
|
|
|
/> |
|
|
|
</> |
|
|
|
); |
|
|
|
<Avatar size="small" color="light-blue" style={{ margin: 4 }}> |
|
|
|
<img src="/assets/images/avatar/6.png" /> |
|
|
|
</Avatar> |
|
|
|
{user && user.namePresent} |
|
|
|
</div> |
|
|
|
} |
|
|
|
> |
|
|
|
<Nav.Item itemKey={"logout"} text={"退出"} /> |
|
|
|
</Nav.Sub> |
|
|
|
} |
|
|
|
/> |
|
|
|
</> |
|
|
|
); |
|
|
|
}; |
|
|
|
|
|
|
|
function mapStateToProps(state) { |
|
|
|
const { global, auth, webSocket } = state; |
|
|
|
return { |
|
|
|
actions: global.actions, |
|
|
|
user: auth.user, |
|
|
|
socket: webSocket.socket, |
|
|
|
}; |
|
|
|
function mapStateToProps (state) { |
|
|
|
const { global, auth, webSocket } = state; |
|
|
|
return { |
|
|
|
actions: global.actions, |
|
|
|
user: auth.user, |
|
|
|
socket: webSocket.socket, |
|
|
|
}; |
|
|
|
} |
|
|
|
|
|
|
|
export default connect(mapStateToProps)(Header); |
|
|
|