From 53de6e86f1ff91f8a535bb299898e579dbee0d86 Mon Sep 17 00:00:00 2001 From: dongrui <38676269+whDongRui@users.noreply.github.com> Date: Mon, 8 Oct 2018 15:20:50 +0800 Subject: [PATCH] fix: Modify header show condition (#464) --- src/components/Header/index.jsx | 7 ++++--- src/routes/renderRoute.js | 13 ++++++++++--- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/src/components/Header/index.jsx b/src/components/Header/index.jsx index 710227d2..9023a057 100644 --- a/src/components/Header/index.jsx +++ b/src/components/Header/index.jsx @@ -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; }; @@ -149,7 +150,7 @@ class Header extends Component {
- {isNormal && this.renderMenus()} + {isNormal && !isHome && this.renderMenus()} {this.renderMenuBtns()}
{needShowSearch && ( diff --git a/src/routes/renderRoute.js b/src/routes/renderRoute.js index 316ee698..f573ee1a 100644 --- a/src/routes/renderRoute.js +++ b/src/routes/renderRoute.js @@ -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 || {}; @@ -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 (