You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

64 lines
2.2 KiB

import React from 'react'
import {Layout, Breadcrumb, Select} from 'antd';
import Header from 'views/header';
import Slider from 'views/slider';
import ContentMain from 'components/contentMain';
import { withRouter } from 'react-router-dom'
import {findTitleByKey} from "./views/slider";
const { Content, Footer, Sider } = Layout;
class App extends React.Component {
state = {
collapsed: false,
breadcrumb: []
};
onCollapse = (collapsed: boolean) => {
this.setState({ collapsed });
};
changeCollapse (value: boolean) {
this.setState({collapsed: value})
}
componentDidMount() {
// @ts-ignore
this.props.history.listen(path=>{
console.log("全局路由监听" + path.pathname)
var tag = findTitleByKey(path.pathname.slice(1));
console.log(tag)
if (tag && tag.length > 0) {
this.setState({ breadcrumb: tag });
}
})
}
render() {
const { collapsed, breadcrumb } = this.state;
return (
<Layout style={{ minHeight: '100vh' }}>
<Sider theme={'light'} style={{ background: '#fff' }} trigger={null} collapsible collapsed={collapsed} onCollapse={this.onCollapse}>
<Slider collapsed={collapsed} />
</Sider>
<Layout className="site-layout">
<Header changeCollapse={this.changeCollapse.bind(this)} />
<Content className={collapsed === true ? 'noLeft' : 'left'} style={{ position: 'absolute', top: 70, right: 0, bottom: 0 }}>
<Breadcrumb style={{ margin: '0 16px' }}>
{breadcrumb.map((item, index) => (
<Breadcrumb.Item key={index}>{item}</Breadcrumb.Item>
))}
</Breadcrumb>
<ContentMain />
</Content>
<Footer className={collapsed === true ? 'noLeft footer' : 'left footer'} style={{ position: 'absolute', right: 0, bottom: 0 }}></Footer>
</Layout>
</Layout>
)
}
}
// @ts-ignore
export default withRouter(App);