yapi/client/reducer/modules/menu.js

29 lines
496 B
JavaScript
Raw Normal View History

2017-08-07 19:34:34 +08:00
// Actions
const CHANGE_MENU_ITEM = 'yapi/menu/CHANGE_MENU_ITEM';
2017-07-20 21:30:35 +08:00
2017-08-07 19:34:34 +08:00
// Reducer
2017-07-20 21:30:35 +08:00
const initialState = {
2017-07-25 17:56:04 +08:00
curKey: '/'+window.location.hash.split("/")[1]
2017-07-20 21:30:35 +08:00
}
export default (state = initialState, action) => {
switch (action.type) {
case CHANGE_MENU_ITEM: {
return {
...state,
curKey: action.data
};
}
default:
return state;
}
}
2017-08-07 19:34:34 +08:00
// Action Creators
export function changeMenuItem(curKey) {
return {
type: CHANGE_MENU_ITEM,
data: curKey
}
}