Skip to content

Commit

Permalink
6. Add layout
Browse files Browse the repository at this point in the history
  • Loading branch information
sorrycc committed Feb 22, 2018
1 parent ee9ccba commit 2c76347
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 0 deletions.
30 changes: 30 additions & 0 deletions src/layouts/Header.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { Menu, Icon } from 'antd';
import Link from 'umi/link';

function Header({ location }) {
return (
<Menu
selectedKeys={[location.pathname]}
mode="horizontal"
theme="dark"
>
<Menu.Item key="/">
<Link to="/"><Icon type="home" />Home</Link>
</Menu.Item>
<Menu.Item key="/users">
<Link to="/users"><Icon type="bars" />Users</Link>
</Menu.Item>
<Menu.Item key="/umi">
<a href="https://github.com/umijs/umi" target="_blank">umi</a>
</Menu.Item>
<Menu.Item key="/dva">
<a href="https://github.com/dvajs/dva" target="_blank">dva</a>
</Menu.Item>
<Menu.Item key="/404">

This comment has been minimized.

Copy link
@wzono

wzono Jul 21, 2018

这个404无法匹配到,pathname 是下面的那个路径,没有选中效果

This comment has been minimized.

Copy link
@yuanguandong

yuanguandong Dec 31, 2018

<Link to="/page-you-dont-know"><Icon type="frown-circle" />404</Link>
</Menu.Item>
</Menu>
);
}

export default Header;
15 changes: 15 additions & 0 deletions src/layouts/index.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
.normal {
display: flex;
flex-direction: column;
height: 100%;
}

.content {
flex: 1;
display: flex;
}

.main {
padding: 0 8px;
flex: 1 0 auto;
}
19 changes: 19 additions & 0 deletions src/layouts/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import React from 'react';
import styles from './index.css';
import Header from './Header';
import withRouter from 'umi/withRouter';

function Layout({ children, location }) {
return (
<div className={styles.normal}>
<Header location={location} />
<div className={styles.content}>
<div className={styles.main}>
{children}
</div>
</div>
</div>
);
}

export default withRouter(Layout);

0 comments on commit 2c76347

Please sign in to comment.