Browse Source

路由跳转名字

master
wenlele 2 years ago
parent
commit
c20d4ac18b
  1. 196
      web/client/src/layout/components/header/index.jsx
  2. 7
      web/client/src/sections/auth/containers/login.jsx

196
web/client/src/layout/components/header/index.jsx

@ -7,99 +7,91 @@ import { headerItems } from './contant';
import "./index.less";
const Header = (props) => {
const { dispatch, history, user, actions, socket, tochange } = props;
const { dispatch, history, user, actions, socket, tochange } = props;
return (
<>
<div id="top-slider">
<Nav
mode={"horizontal"}
onClick={({ itemKey }) => {
if (itemKey == "logout") {
dispatch(actions.auth.logout(user));
if (socket) {
socket.disconnect();
}
history.push(`/signin`);
}
}}
style={{
height: 48,
minWidth: 520,
background: '#1D2343',
backgroundSize: "100% 100%",
color: "white",
}}
header={{
logo: (
<div style={{ display: 'flex' }}>
<div style={{ marginLeft: 16, width: 24, height: 24 }}>
<img src="/assets/images/background/username.png" alt="" style={{ width: 24, marginRight: -10 }} />
</div>
<div style={{ fontFamily: 'YouSheBiaoTiHei', fontSize: 18, marginLeft: 12 }}>
数据中心
</div>
</div>
// <img
// src="/assets/images/install/long_logo.png"
// style={{ display: "inline-block", width: 200, height: 40, marginLeft: -24 }}
// />
),
// text: (
// <>
return (
<>
<div id="top-slider">
<Nav
mode={"horizontal"}
onClick={({ itemKey }) => {
if (itemKey == "logout") {
dispatch(actions.auth.logout(user));
if (socket) {
socket.disconnect();
}
history.push(`/signin`);
}
}}
style={{
height: 48,
minWidth: 520,
background: '#1D2343',
backgroundSize: "100% 100%",
color: "white",
}}
header={{
logo: (
<div style={{ display: 'flex' }}>
<div style={{ marginLeft: 16, width: 24, height: 24 }}>
<img src="/assets/images/background/username.png" alt="" style={{ width: 24, marginRight: -10 }} />
</div>
<div style={{ fontFamily: 'YouSheBiaoTiHei', fontSize: 18, marginLeft: 12 }}>
数据中心
</div>
</div>
// <img
// src="/assets/images/install/long_logo.png"
// style={{ display: "inline-block", width: 200, height: 40, marginLeft: -24 }}
// />
),
// text: (
// <>
// {/* <SplitButtonGroup style={{ marginLeft: 10 }} aria-label=""> */}
// <Button theme="solid" type="primary" style={{ width: 52, height: 24, background: '#005ABD' }}></Button>
// {/* <Dropdown onVisibleChange={(v) => { }} menu={{}} trigger="click" position="bottomRight"> */}
// <Button style={{ width: 16, height: 24, background: '#005ABD' }} theme="solid" type="primary" icon={<IconTreeTriangleDown />}></Button>
// {/* </Dropdown> */}
// {/* </SplitButtonGroup> */}
// </>
// ),
}}
footer={
<>
{headerItems.map((item, index) => {
if (item.hasOwnProperty('items')) {
return (
<Nav.Sub
key={index + 'a'}
itemKey={item.itemKey}
text={item.text}
dropdownStyle={{ color: '#F2F3F5' }}
>
{item.hasOwnProperty('items') && item.items.map((ite, idx) => (
<Nav.Item key={idx + 'd'} itemKey={ite.itemKey} text={ite.text} onClick={() => { tochange(ite); }} />
))}
</Nav.Sub>
)
}
else {
return (
<div key='console' style={{ display: 'inline-flex' }}>
<img src="/assets/images/background/console.png" style={{ width: 24, marginRight: -10 }} />
<Nav.Item key={index + 'a'} itemKey={item.itemKey} text={item.text} onClick={() => { tochange(item) }} />
</div>
// {/* <SplitButtonGroup style={{ marginLeft: 10 }} aria-label=""> */}
// <Button theme="solid" type="primary" style={{ width: 52, height: 24, background: '#005ABD' }}></Button>
// {/* <Dropdown onVisibleChange={(v) => { }} menu={{}} trigger="click" position="bottomRight"> */}
// <Button style={{ width: 16, height: 24, background: '#005ABD' }} theme="solid" type="primary" icon={<IconTreeTriangleDown />}></Button>
// {/* </Dropdown> */}
// {/* </SplitButtonGroup> */}
// </>
// ),
}}
footer={
<>
{headerItems.map((item, index) => {
if (item.hasOwnProperty('items')) {
return (
<Nav.Sub
key={index + 'a'}
itemKey={item.itemKey}
text={item.text}
dropdownStyle={{ color: '#F2F3F5' }}
>
{item.hasOwnProperty('items') && item.items.map((ite, idx) => (
<Nav.Item key={idx + 'd'} itemKey={ite.itemKey} text={ite.text} onClick={() => { tochange(ite); }} />
))}
</Nav.Sub>
)
}
else {
return (
<div key='console' style={{ display: 'inline-flex' }}>
<img src="/assets/images/background/console.png" style={{ width: 24, marginRight: -10 }} />
<Nav.Item key={index + 'a'} itemKey={item.itemKey} text={item.text} onClick={() => { tochange(item) }} />
</div>
)
}
})}
{/* <div style={{ display: 'flex', alignItems: 'center' }}>
<div style={{ marginLeft: 16, width: 24, height: 24 }}>
<img src="/assets/images/background/username.png" alt="" style={{ width: '100%', height: '100%' }} />
</div>
<div style={{ color: '#92CBFF', fontSize: 12, marginLeft: 10, cursor: "pointer" }} onClick={() => {
dispatch(actions.auth.logout(user));
if (socket) {
socket.disconnect();
}
history.push(`/signin`);
}}>
退出
</div>
</div> */}
)
}
})}
<div style={{ display: 'flex', alignItems: 'center' }}>
<div style={{ marginLeft: 16, width: 24, height: 24 }}>
<img src="/assets/images/background/username.png" alt="" style={{ width: '100%', height: '100%' }} />
</div>
<div style={{ color: '#92CBFF', fontSize: 12, marginLeft: 10, cursor: "pointer" }}>{user?.name}</div>
</div>
{/* <Nav.Sub
{/* <Nav.Sub
itemKey={"user"}
text={
<div
@ -145,21 +137,21 @@ const Header = (props) => {
退出
</div>
</Nav.Sub> */}
</>
}
/>
</div>
</>
);
</>
}
/>
</div>
</>
);
};
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);

7
web/client/src/sections/auth/containers/login.jsx

@ -8,7 +8,7 @@ import { IconLock, IconUser } from '@douyinfe/semi-icons';
import '../style.less'
const Login = props => {
const { dispatch, user, error, actions, apiRoot, isRequesting } = props
const { dispatch, user, error, actions, apiRoot, isRequesting,webPepUrl } = props
const form = useRef();
useEffect(() => {
@ -23,6 +23,8 @@ const Login = props => {
dispatch(push('/businessManagement/pmReport/reserveItemsReporting'));
localStorage.setItem('poms_open_sider', JSON.stringify(["pmReport"]))
localStorage.setItem('poms_selected_sider', JSON.stringify(["businessManagement"]))
}else{
window.location.href = `${webPepUrl}/signin`
}
}, [user])
@ -110,7 +112,8 @@ function mapStateToProps(state) {
error: auth.error,
actions: global.actions,
apiRoot: global.apiRoot,
isRequesting: auth.isRequesting
isRequesting: auth.isRequesting,
webPepUrl: global.webPepUrl,
}
}

Loading…
Cancel
Save