提交 f5c7fe5f authored 作者: 钟是志's avatar 钟是志

bug修改

上级 8319dde6
...@@ -14,10 +14,7 @@ function NavBarDiy ({ history, title, rightContent, onLeftClick }) { ...@@ -14,10 +14,7 @@ function NavBarDiy ({ history, title, rightContent, onLeftClick }) {
<NavBar <NavBar
mode="light" mode="light"
icon={<Icon type="left" />} icon={<Icon type="left" />}
onLeftClick={ onLeftClick ? onLeftClick : () => onLeftClick={ onLeftClick ? onLeftClick : () => history.goBack()}
{
window.history.back();
}}
rightContent={rightContent} rightContent={rightContent}
> >
<span> <span>
......
import BasicLayout from '..';
import renderer from 'react-test-renderer';
describe('Layout: BasicLayout', () => {
it('Render correctly', () => {
const wrapper = renderer.create(<BasicLayout />);
expect(wrapper.root.children.length).toBe(1);
const outerLayer = wrapper.root.children[0];
expect(outerLayer.type).toBe('div');
const title = outerLayer.children[0];
expect(title.type).toBe('h1');
expect(title.children[0]).toBe('Yay! Welcome to umi!');
});
});
.normal {
height: 100%;
background-color: #F4F4F4;
}
* {
box-sizing: border-box;
}
import React from 'react';
import styles from './index.css';
import { router, connect, } from 'dva';
import { getToken, setToken, } from '@/H5Public/utils/authority'
const routerWhiteList = [
"/login",
];
const { Redirect } = router;
let BasicLayout = ({ children, dispatch, location: { pathname }, }) => {
if (pathname === '/login') {
return <div>{children}</div>;
}
return <div className={styles.normal}>{children}</div>;
}
BasicLayout = connect()(BasicLayout);
export default (props) => {
const { location: { pathname, query: { token, returnUrl } }, children, } = props;
if (routerWhiteList.includes(pathname)) return children;
if (!!token || getToken()) {
if (!!token) {
setToken(token);
}
if (!!returnUrl) {
return <Redirect to={returnUrl}/>;
}
return <BasicLayout {...props}/>;
}
let loginPathname = '/login';
if (!!returnUrl) {
loginPathname = `${loginPathname}?returnUrl=${returnUrl}`;
}
return <Redirect to={loginPathname}/>;
}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论