Skip to content
This repository was archived by the owner on May 7, 2022. It is now read-only.

Commit 8088b30

Browse files
author
yongyue.huang
committed
finish
1 parent 3befb9f commit 8088b30

File tree

9 files changed

+13
-84
lines changed

9 files changed

+13
-84
lines changed

src/actions/search.js

Lines changed: 0 additions & 4 deletions
This file was deleted.

src/components/BaseLayout/index.js

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@ import { Layout, Menu, Icon, Row, Col, Avatar } from 'antd'
55
import './index.less'
66
import { bindActionCreators } from 'redux'
77
import { connect } from 'react-redux'
8-
import {setGlobalLoading} from 'actions/global'
8+
import {setGlobalLoading, checkIsLogin} from 'actions/global'
99

1010
const SubMenu = Menu.SubMenu
1111
const { Header, Sider, Content } = Layout
1212

1313

1414
@connect(
1515
state => state.getIn(['global']),
16-
dispatch => bindActionCreators({ setGlobalLoading }, dispatch)
16+
dispatch => bindActionCreators({ setGlobalLoading, checkIsLogin }, dispatch)
1717
)
1818
class BaseLayout extends React.Component {
1919
state = {
@@ -379,8 +379,11 @@ class BaseLayout extends React.Component {
379379
this.props.history.push('/login')
380380
}
381381
}
382+
onLogout = () => {
383+
this.props.checkIsLogin(false)
384+
}
382385
componentDidMount () {
383-
this.redirectRoute()
386+
this.redirectRoute()
384387
this.props.setGlobalLoading(true)
385388
}
386389
render () {
@@ -391,7 +394,7 @@ class BaseLayout extends React.Component {
391394
return (
392395
<Layout className="base-layout">
393396
<Sider>
394-
<Menu
397+
<Menu
395398
theme={menuData.theme}
396399
mode={menuData.mode}
397400
defaultOpenKeys={[menuData.defaultOpenKeys]}
@@ -404,8 +407,8 @@ class BaseLayout extends React.Component {
404407
{
405408
item.subtitle.map(second => {
406409
return (
407-
<Menu.Item
408-
key={second.link}
410+
<Menu.Item
411+
key={second.link}
409412
onClick={this.getCurrentMenu}
410413
>
411414
<NavLink to={second.link}>
@@ -428,7 +431,7 @@ class BaseLayout extends React.Component {
428431
<Layout>
429432
<Header className="base-header">
430433
<span className="header-tag">{currentMenu && `算法 /`} {currentMenu}</span>
431-
<NavLink to="/login"><Avatar size="large" icon="user" /></NavLink>
434+
<NavLink to="/login" onClick={this.onLogout}><Avatar size="large" icon="user" /></NavLink>
432435
</Header>
433436
<Content className="base-content">
434437
{

src/index.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import { createStore, applyMiddleware, compose } from 'redux'
55
import { Provider } from 'react-redux'
66
import { connectRouter, routerMiddleware, ConnectedRouter } from 'connected-react-router/immutable'
77
import Immutable from 'immutable'
8-
// import persistState from 'redux-localstorage'
98
import thunk from 'redux-thunk'
109
import App from './App'
1110
import rootReducer from './reducers/index'
@@ -25,7 +24,6 @@ const store = createStore(
2524
connectRouter(history)(rootReducer),
2625
initialState,
2726
composeEnhancer(
28-
//persistState(/*paths, config*/), //数据持久化,暂时没有调通,备用状态
2927
applyMiddleware(
3028
routerMiddleware(history),
3129
thunk

src/reducers/global.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1+
let isLogin = sessionStorage.getItem('isLogin')
12
const initState = {
23
globalLoading: false, // 全局loading
3-
isLogin: !!sessionStorage.getItem('isLogin') // 登录状态
4+
isLogin: !!isLogin ? (isLogin === 'true' ? true : false) : false // 登录状态
45
}
56

67
export const global = (state = initState, action) => {
@@ -11,6 +12,7 @@ export const global = (state = initState, action) => {
1112
globalLoading: action.globalLoading
1213
}
1314
case "CHECK_IS_LOGIN":
15+
console.log(11111)
1416
sessionStorage.setItem('isLogin', action.isLogin)
1517
return {
1618
...state,

src/utils/persistState/createSlicer.js

Whitespace-only changes.

src/utils/persistState/getSubset.js

Whitespace-only changes.

src/utils/persistState/persistState.js

Lines changed: 0 additions & 70 deletions
This file was deleted.

src/utils/persistState/util/mergeState.js

Whitespace-only changes.

src/utils/persistState/util/typeOf.js

Whitespace-only changes.

0 commit comments

Comments
 (0)