update 整改reducer
This commit is contained in:
@@ -1,52 +0,0 @@
|
||||
import { combineReducers } from 'redux'
|
||||
|
||||
const user = (state = {}, action) => {
|
||||
// 写入各种action对应的操作
|
||||
switch (action.type) {
|
||||
case 'SET_USER_ACCOUNT':
|
||||
const _state = { ...state, ...action.user }
|
||||
return _state
|
||||
default:
|
||||
return state
|
||||
}
|
||||
}
|
||||
|
||||
const layout = (state = {
|
||||
siderCollapsed: false
|
||||
}, action) => {
|
||||
switch (action.type) {
|
||||
// 打开窗口
|
||||
case 'OPEN_WINDOW':
|
||||
return state
|
||||
// 关闭窗口
|
||||
case 'CLOSE_WINDOW':
|
||||
return state
|
||||
// 重新加载窗口
|
||||
case 'RELOAD_WINDOW':
|
||||
return state
|
||||
// 侧边收起状态
|
||||
case 'TOGGLE_COLLAPSED':
|
||||
const _state = { ...state, siderCollapsed: action.siderCollapsed }
|
||||
return _state
|
||||
default:
|
||||
return state
|
||||
}
|
||||
}
|
||||
|
||||
const dicData = (state = {}, action) => {
|
||||
switch (action.type) {
|
||||
case 'ADD_DIC_DATA':
|
||||
const _state = { ...state, ...action.value }
|
||||
return _state
|
||||
default:
|
||||
return state
|
||||
}
|
||||
}
|
||||
|
||||
const combine = combineReducers({
|
||||
user,
|
||||
layout,
|
||||
dicData
|
||||
})
|
||||
|
||||
export default combine
|
||||
11
web-react/src/store/reducer/dict-data.js
Normal file
11
web-react/src/store/reducer/dict-data.js
Normal file
@@ -0,0 +1,11 @@
|
||||
const dictData = (state = {}, action) => {
|
||||
switch (action.type) {
|
||||
case 'ADD_DICT_DATA':
|
||||
const _state = { ...state, ...action.value }
|
||||
return _state
|
||||
default:
|
||||
return state
|
||||
}
|
||||
}
|
||||
|
||||
export default dictData
|
||||
12
web-react/src/store/reducer/index.js
Normal file
12
web-react/src/store/reducer/index.js
Normal file
@@ -0,0 +1,12 @@
|
||||
import { combineReducers } from 'redux'
|
||||
import user from './user'
|
||||
import layout from './layout'
|
||||
import dictData from './dict-data'
|
||||
|
||||
const combine = combineReducers({
|
||||
user,
|
||||
layout,
|
||||
dictData
|
||||
})
|
||||
|
||||
export default combine
|
||||
23
web-react/src/store/reducer/layout.js
Normal file
23
web-react/src/store/reducer/layout.js
Normal file
@@ -0,0 +1,23 @@
|
||||
const layout = (state = {
|
||||
siderCollapsed: false
|
||||
}, action) => {
|
||||
switch (action.type) {
|
||||
// 打开窗口
|
||||
case 'OPEN_WINDOW':
|
||||
return state
|
||||
// 关闭窗口
|
||||
case 'CLOSE_WINDOW':
|
||||
return state
|
||||
// 重新加载窗口
|
||||
case 'RELOAD_WINDOW':
|
||||
return state
|
||||
// 侧边收起状态
|
||||
case 'TOGGLE_COLLAPSED':
|
||||
const _state = { ...state, siderCollapsed: action.siderCollapsed }
|
||||
return _state
|
||||
default:
|
||||
return state
|
||||
}
|
||||
}
|
||||
|
||||
export default layout
|
||||
12
web-react/src/store/reducer/user.js
Normal file
12
web-react/src/store/reducer/user.js
Normal file
@@ -0,0 +1,12 @@
|
||||
const user = (state = {}, action) => {
|
||||
// 写入各种action对应的操作
|
||||
switch (action.type) {
|
||||
case 'SET_USER_ACCOUNT':
|
||||
const _state = { ...state, ...action.user }
|
||||
return _state
|
||||
default:
|
||||
return state
|
||||
}
|
||||
}
|
||||
|
||||
export default user
|
||||
Reference in New Issue
Block a user