From 2a55f240b50a4610f2f229e33c4b3abca7a567c1 Mon Sep 17 00:00:00 2001 From: harry Date: Sun, 8 Mar 2020 12:48:45 +0800 Subject: [PATCH] =?UTF-8?q?fix=20c++=E8=AF=AD=E6=B3=95=E9=AB=98=E4=BA=AE?= =?UTF-8?q?=20=E4=BB=A3=E7=A0=81=E4=B8=8D=E8=87=AA=E5=8A=A8=E6=9B=B4?= =?UTF-8?q?=E6=96=B0bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/myMonacoEditor/index.js | 21 ++++--------------- .../newOrEditTask/leftpane/editorTab/index.js | 2 +- .../developer/studentStudy/rightpane/index.js | 8 +++++-- public/react/src/redux/actions/ojForUser.js | 4 +--- 4 files changed, 12 insertions(+), 23 deletions(-) diff --git a/public/react/src/modules/developer/components/myMonacoEditor/index.js b/public/react/src/modules/developer/components/myMonacoEditor/index.js index 383c4dd63..c0e036332 100644 --- a/public/react/src/modules/developer/components/myMonacoEditor/index.js +++ b/public/react/src/modules/developer/components/myMonacoEditor/index.js @@ -47,8 +47,6 @@ function MyMonacoEditor(props, ref) { return fromStore('oj_theme') || 'dark'; }); const [height, setHeight] = useState('calc(100% - 56px)'); - const editorRef = useRef(null); - console.log(language, code, '-------========----------') useEffect(() => { setHeight(showOrHideControl ? 'calc(100% - 378px)' : 'calc(100% - 56px)'); @@ -71,21 +69,10 @@ function MyMonacoEditor(props, ref) { setTheme(value); } - // 文本框内容变化时,记录文本框内容 - const handleEditorChange = (_, monaco) => { - editorRef.current = monaco; // 获取当前monaco实例 - } - useEffect(() => { - if (editorRef.current) { - editorRef.current.onDidChangeModelContent(e => { // 监听编辑器内容的变化 - const val = editorRef.current.getValue(); - onCodeChange(val); - }); - } - }, [ - editorRef.current - ]) + function onChangeHandler(ev, value) { + onCodeChange(value); + } // 配置编辑器属性 const editorOptions = { @@ -159,7 +146,7 @@ function MyMonacoEditor(props, ref) { value={code || ''} options={editorOptions} theme={theme} // dark || light - editorDidMount={handleEditorChange} + onChange={onChangeHandler} /> diff --git a/public/react/src/modules/developer/newOrEditTask/leftpane/editorTab/index.js b/public/react/src/modules/developer/newOrEditTask/leftpane/editorTab/index.js index bbee6f858..612f1104e 100644 --- a/public/react/src/modules/developer/newOrEditTask/leftpane/editorTab/index.js +++ b/public/react/src/modules/developer/newOrEditTask/leftpane/editorTab/index.js @@ -23,7 +23,7 @@ const { Option } = Select; const maps = { language: [ { title: 'C', key: 'C' }, - { title: 'C++', key: 'C++' }, + { title: 'C++', key: 'cpp' }, { title: 'Python', key: 'Python' }, { title: 'Java', key: 'Java' } ], diff --git a/public/react/src/modules/developer/studentStudy/rightpane/index.js b/public/react/src/modules/developer/studentStudy/rightpane/index.js index 09263d16c..62fc56783 100644 --- a/public/react/src/modules/developer/studentStudy/rightpane/index.js +++ b/public/react/src/modules/developer/studentStudy/rightpane/index.js @@ -51,7 +51,7 @@ const RightPane = (props) => { timer = setInterval(function () { clearInterval(timer); timer = null; - saveUserCodeForInterval(identifier); + saveUserCodeForInterval(identifier, value); }, 5000); } } @@ -91,13 +91,17 @@ const RightPane = (props) => { }); } const { getFieldDecorator } = props.form; + let language = hack.language + if (language === 'C++') { + language = 'cpp' + } return (
{ export const saveUserCodeForInterval = (identifier, code) => { return (dispatch, getState) => { - const { userCode } = getState().ojForUserReducer; dispatch({ type: types.AUTO_UPDATE_CODE, payload: true }); fetchUpdateCode(identifier, { - code: Base64.encode(userCode) + code: Base64.encode(code) }).then(res => { if (res.data.status === 401) { return; @@ -135,7 +134,6 @@ export const saveUserCodeForInterval = (identifier, code) => { * @param {*} type 测评类型 debug | submit */ export const updateCode = (identifier, inputValue, type) => { - console.log(1111); return (dispatch, getState) => { const { userCode, isUpdateCode } = getState().ojForUserReducer; if (isUpdateCode) {