diff --git a/public/react/src/redux/actions/actionTypes.js b/public/react/src/redux/actions/actionTypes.js index 9ba1d58cf..53d62003b 100644 --- a/public/react/src/redux/actions/actionTypes.js +++ b/public/react/src/redux/actions/actionTypes.js @@ -36,6 +36,7 @@ const types = { DEBUGGER_CODE: 'DEBUGGER_CODE', // 调试代码 GET_COURSE_QUESTION: 'GET_COURSE_QUESTION', // 获取编辑题 CHANGE_KNOWLEDGES: 'CHANGE_KNOWLEDGES', // 保存所选择的知识点 + SET_OJ_INITIAL_VALUE: 'SET_OJ_INITIAL_VALUE', // 设置初始值 // study SAVE_USER_PROGRAM_ID: 'SAVE_USER_PROGRAM_ID',// 保存用户编程题id值 USER_PROGRAM_DETAIL: 'USER_PROGRAM_DETAIL', // 用户编程题详情 diff --git a/public/react/src/redux/actions/index.js b/public/react/src/redux/actions/index.js index 897923f94..efce336c9 100644 --- a/public/react/src/redux/actions/index.js +++ b/public/react/src/redux/actions/index.js @@ -35,7 +35,8 @@ import { updateOpenTestCaseIndex, handleClickCancelPublish, getQuestion, - saveKnowledge + saveKnowledge, + setOjInitialValue } from './ojForm'; import { @@ -123,6 +124,7 @@ export default { handleClickCancelPublish, getQuestion, saveKnowledge, + setOjInitialValue, // addTestCase, deleteTestCase, diff --git a/public/react/src/redux/actions/ojForm.js b/public/react/src/redux/actions/ojForm.js index 539798ff4..6d2da50a3 100644 --- a/public/react/src/redux/actions/ojForm.js +++ b/public/react/src/redux/actions/ojForm.js @@ -4,7 +4,7 @@ * @Github: * @Date: 2019-11-20 16:35:46 * @LastEditors : tangjiang - * @LastEditTime : 2020-01-02 17:38:12 + * @LastEditTime : 2020-01-03 16:40:54 */ import types from './actionTypes'; import CONST from '../../constants'; @@ -694,3 +694,19 @@ export const saveKnowledge = (values) => { payload: values } } + +/** + * 新增时跳转到OJ时带的默认参数: + * @param {}} params + * { + * difficult: '', // 难易度 + * sub_discipline_id: '' // 课程方向 + * tag_discipline_id: [] 知识点 + * } + */ +export const setOjInitialValue = (params) => { + return { + type: types.SET_OJ_INITIAL_VALUE, + payload: params + } +} diff --git a/public/react/src/redux/reducers/ojFormReducer.js b/public/react/src/redux/reducers/ojFormReducer.js index d604a6156..95236b821 100644 --- a/public/react/src/redux/reducers/ojFormReducer.js +++ b/public/react/src/redux/reducers/ojFormReducer.js @@ -4,7 +4,7 @@ * @Github: * @Date: 2019-11-20 16:40:32 * @LastEditors : tangjiang - * @LastEditTime : 2020-01-02 17:36:40 + * @LastEditTime : 2020-01-03 16:39:09 */ import { Base64 } from 'js-base64'; import types from '../actions/actionTypes'; @@ -348,6 +348,13 @@ const ojFormReducer = (state = initialState, action) => { knowledges: action.payload } } + case types.SET_OJ_INITIAL_VALUE: + const _p = action.payload; + return { + ...state, + ojForm: Object.assign({}, state.ojForm, {difficult: _p.difficult, sub_discipline_id: _p.sub_discipline_id}), + tag_discipline_id: _p.tag_discipline_id || [] + } default: return state; }