Skip to content

Commit

Permalink
fix: Modify header show condition (#464)
Browse files Browse the repository at this point in the history
  • Loading branch information
whDongRui authored Oct 8, 2018
1 parent eb56624 commit 53de6e8
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
7 changes: 4 additions & 3 deletions src/components/Header/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@ class Header extends Component {
};

onSearch = async value => {
const { appStore } = this.props;
this.props.history.push('/store/search/' + value);
const { appStore, history, isHome } = this.props;
const pushUrl = isHome ? `/apps/search/${value}` : `/store/search/${value}`;
this.props.history.push(pushUrl);
await appStore.fetchAll({ search_word: value });
appStore.homeApps = appStore.apps;
};
Expand Down Expand Up @@ -149,7 +150,7 @@ class Header extends Component {
<div className={styles.wrapper}>
<Logo className={styles.logo} url={logoUrl} />
<div className={styles.menuOuter}>
{isNormal && this.renderMenus()}
{isNormal && !isHome && this.renderMenus()}
{this.renderMenuBtns()}
</div>
{needShowSearch && (
Expand Down
13 changes: 10 additions & 3 deletions src/routes/renderRoute.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,15 @@ import { getCookie, setCookie } from '../utils';

const renderRoute = (match, route, store) => {
if (route.path === 'login') {
setCookie('user', '', -1);
setCookie('role', '', -1);
const names = [
'access_token',
'token_type',
'access_token_home',
'refresh_token',
'user',
'role'
];
names.forEach(name => setCookie(name, '', -1));
}

const user = store.user || {};
Expand All @@ -29,7 +36,7 @@ const renderRoute = (match, route, store) => {
const component = withRouter(route.component);

if (route.path !== '/login') {
const isHome = route.path === '/' || route.path === '/apps/:appId';
const isHome = route.path === '/' || route.path.startsWith('/apps/');

return (
<Fragment>
Expand Down

0 comments on commit 53de6e8

Please sign in to comment.