diff --git a/public/react/src/redux/actions/actionTypes.js b/public/react/src/redux/actions/actionTypes.js index f6bc7f3b9..4850fc794 100644 --- a/public/react/src/redux/actions/actionTypes.js +++ b/public/react/src/redux/actions/actionTypes.js @@ -46,7 +46,8 @@ const types = { UPDATE_TEST_AND_VALIDATE: 'UPDATE_TEST_AND_VALIDATE', // 更新测试用例及验证值 UPDATE_OPEN_TESTCASE_INDEX: 'UPDATE_OPEN_TESTCASE_INDEX', // 更新测试用例索引 GET_COMMIT_RECORD_DETAIL_BY_ID: 'GET_COMMIT_RECORD_DETAIL_BY_ID', // 根据id号获取提交记录详情 - RESTORE_INITIAL_CODE: 'RESTORE_INITIAL_CODE' // 恢复初始代码 + RESTORE_INITIAL_CODE: 'RESTORE_INITIAL_CODE', // 恢复初始代码 + SAVE_USER_INFO: 'SAVE_USER_INFO', // 只在用户信息 } export default types; diff --git a/public/react/src/redux/actions/user.js b/public/react/src/redux/actions/user.js new file mode 100644 index 000000000..1b7c331c6 --- /dev/null +++ b/public/react/src/redux/actions/user.js @@ -0,0 +1,16 @@ +/* + * @Description: + * @Author: tangjiang + * @Github: + * @Date: 2019-12-06 15:09:22 + * @LastEditors: tangjiang + * @LastEditTime: 2019-12-06 15:15:00 + */ +import types from './actionTypes'; + +// 获取用户信息 +export default function getUserInfo () { + return (dispatch) => { + // 调用获取用户信息, 如果没有登录直接调用登录,成功后保存当前用户信息 + } +} \ No newline at end of file diff --git a/public/react/src/redux/reducers/index.js b/public/react/src/redux/reducers/index.js index 2f60bf8e3..620905459 100644 --- a/public/react/src/redux/reducers/index.js +++ b/public/react/src/redux/reducers/index.js @@ -12,10 +12,13 @@ import ojFormReducer from './ojFormReducer'; import ojListReducer from './ojListReducer'; import ojForUserReducer from './ojForUserReducer'; import commonReducer from './commonReducer'; +import userReducer from './userReducer'; + export default combineReducers({ testReducer, ojFormReducer, ojListReducer, ojForUserReducer, - commonReducer + commonReducer, + userReducer }); diff --git a/public/react/src/redux/reducers/userReducer.js b/public/react/src/redux/reducers/userReducer.js new file mode 100644 index 000000000..0e2718be9 --- /dev/null +++ b/public/react/src/redux/reducers/userReducer.js @@ -0,0 +1,31 @@ +/* + * @Description: 保存信息数据 + * @Author: tangjiang + * @Github: + * @Date: 2019-12-06 15:09:29 + * @LastEditors: tangjiang + * @LastEditTime: 2019-12-06 15:16:15 + */ +import types from "../actions/actionTypes"; + +const initialState = { + userInfo: {} // 当前登录用户信息 +}; + +const userReducer = (state = initialState, action) => { + switch (action.type) { + case types.SAVE_USER_INFO: + return { + userInfo: action.payload + } + default: + return { + ...state + } + } +} + +export default userReducer; +export { + userReducer +};