Skip to content

Commit

Permalink
fix(docs): 优化模块网站体验
Browse files Browse the repository at this point in the history
  • Loading branch information
ShanaMaid committed Jul 4, 2018
1 parent 682b0b7 commit b0f0e90
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 26 deletions.
2 changes: 1 addition & 1 deletion components/Backtop/assist.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export const backTop = (durations: number, callback: () => void | undefined) => {
export const backTop = (durations: number, callback?: () => void | undefined) => {
let dom: HTMLElement;
if (document.documentElement.scrollTop) {
dom = document.documentElement;
Expand Down
56 changes: 31 additions & 25 deletions docs/pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,27 @@ import { Component } from 'react';
import { Switch, Route, Redirect } from 'react-router-dom';
import { Link } from 'react-router-dom';
import {Menu, BackTop} from '../../components/';
import { backTop } from '../../components/BackTop/assist';
import './index.less';
import menuObj from './menu';
import { MenuItem } from '../../components/Menu/MenuItem';
import { RouteComponentProps } from 'react-router';
import Routes from './routes';


export interface IProps extends RouteComponentProps<{name: string}>{

export interface IProps extends RouteComponentProps<{name: string}> {
}

const SubMenu = Menu.SubMenu;
const MenuItemGroup = Menu.ItemGroup;

export default class Components extends Component<IProps> {
pushHistory = (url: string) => {
this.props.history.push('/components/' + url)
this.props.history.push('/components/' + url);
backTop(300);
}

render() {
const preCls = 'wrapper'
const preCls = 'wrapper';
const current = this.props.match.params.name;
return (
<div>
Expand All @@ -39,24 +39,30 @@ export default class Components extends Component<IProps> {
defaultActiveKey={current}
defaultOpenKeys={['components']}
>
<Menu.Item keyId="yoshino" onClick={this.pushHistory.bind(this, 'yoshino')}>Yoshino</Menu.Item>
<Menu.Item keyId="start" onClick={this.pushHistory.bind(this, 'start')}>快速开始</Menu.Item>
<Menu.Item keyId="logs" onClick={this.pushHistory.bind(this, 'logs')}>更新日志</Menu.Item>
<Menu.Item keyId="faq" onClick={this.pushHistory.bind(this, 'faq')}>FAQ</Menu.Item>
<SubMenu title="组件" keyId="components">
<Menu.Item keyId='yoshino' onClick={this.pushHistory.bind(this, 'yoshino')}>Yoshino</Menu.Item>
<Menu.Item keyId='start' onClick={this.pushHistory.bind(this, 'start')}>快速开始</Menu.Item>
<Menu.Item keyId='logs' onClick={this.pushHistory.bind(this, 'logs')}>更新日志</Menu.Item>
<Menu.Item keyId='faq' onClick={this.pushHistory.bind(this, 'faq')}>FAQ</Menu.Item>
<SubMenu title='组件' keyId='components'>
{
menuObj.map((item) => {
menuObj.map((menu) => {
return (
<MenuItemGroup title={item.name} keyId={item.keyId} key={item.keyId}>
<MenuItemGroup title={menu.name} keyId={menu.keyId} key={menu.keyId}>
{
item.children.map((item) => {
menu.children.map((item) => {
return (
<MenuItem key={item.keyId} keyId={item.keyId} onClick={this.pushHistory.bind(this, item.keyId)}>{item.name}</MenuItem>
)
<MenuItem
key={item.keyId}
keyId={item.keyId}
onClick={this.pushHistory.bind(this, item.keyId)}
>
{item.name}
</MenuItem>
);
})
}
</MenuItemGroup>
)
);
})
}
</SubMenu>
Expand All @@ -68,19 +74,19 @@ export default class Components extends Component<IProps> {
Routes.map((item, key) => {
return (
<Route {...item} path={`${item.path}`} key={key} exact/>
)
);
})
}
<Route render={()=> {
return <Redirect to="/components/"/>
}}/>
<Route
render={() => {
return <Redirect to='/components/'/>;
}}
/>
</Switch>
</div>
</div>
<div className={`${preCls}-footer`}>

</div>
<div className={`${preCls}-footer`}/>
</div>
)
);
}
};
}

0 comments on commit b0f0e90

Please sign in to comment.