update editor code update

dev_new_shixunsrepository
tangjiang 5 years ago
parent f0432f4e0e
commit ceeabea7a3

@ -4,7 +4,7 @@
* @Github: * @Github:
* @Date: 2019-11-27 15:02:52 * @Date: 2019-11-27 15:02:52
* @LastEditors : tangjiang * @LastEditors : tangjiang
* @LastEditTime : 2019-12-27 20:49:46 * @LastEditTime : 2020-01-02 13:59:38
*/ */
import './index.scss'; import './index.scss';
import React, { useState, useRef, useEffect } from 'react'; import React, { useState, useRef, useEffect } from 'react';

@ -4,7 +4,7 @@
* @Github: * @Github:
* @Date: 2019-12-04 08:36:21 * @Date: 2019-12-04 08:36:21
* @LastEditors : tangjiang * @LastEditors : tangjiang
* @LastEditTime : 2019-12-27 21:18:39 * @LastEditTime : 2020-01-02 13:48:02
*/ */
import './index.scss'; import './index.scss';
import React, { useState, useEffect } from 'react'; import React, { useState, useEffect } from 'react';
@ -57,7 +57,9 @@ function RecordDetail (props) {
const handleReturn = (identifier) => { const handleReturn = (identifier) => {
if (identifier) { if (identifier) {
saveEditorCodeForDetail(''); saveEditorCodeForDetail('');
setTimeout(() => {
props.history.push(`/myproblems/${identifier}`); props.history.push(`/myproblems/${identifier}`);
}, 300);
} }
} }

@ -4,7 +4,7 @@
* @Github: * @Github:
* @Date: 2019-11-23 11:33:41 * @Date: 2019-11-23 11:33:41
* @LastEditors : tangjiang * @LastEditors : tangjiang
* @LastEditTime : 2019-12-27 16:03:04 * @LastEditTime : 2020-01-02 13:51:22
// */ // */
import './index.scss'; import './index.scss';
import React, { useState, useEffect, useMemo } from 'react'; import React, { useState, useEffect, useMemo } from 'react';
@ -51,8 +51,6 @@ const LeftPane = (props) => {
comment: (<Comment />) comment: (<Comment />)
}; };
console.log('======>>>>>>>', props);
useEffect(() => { useEffect(() => {
setDefaultActiveKey(userCodeTab); setDefaultActiveKey(userCodeTab);
}, [userCodeTab]) }, [userCodeTab])

@ -4,7 +4,7 @@
* @Github: * @Github:
* @Date: 2019-11-27 14:59:51 * @Date: 2019-11-27 14:59:51
* @LastEditors : tangjiang * @LastEditors : tangjiang
* @LastEditTime : 2019-12-27 19:23:46 * @LastEditTime : 2020-01-02 14:23:43
*/ */
import React, { useState, useEffect } from 'react'; import React, { useState, useEffect } from 'react';
import {connect} from 'react-redux'; import {connect} from 'react-redux';
@ -39,7 +39,7 @@ const RightPane = (props) => {
changeLoadingState changeLoadingState
} = props; } = props;
const [editorCode, setEditorCode] = useState(editor_code || hack.code); // const [editorCode, setEditorCode] = useState(editor_code || hack.code);
const [noteClazz, setNoteClazz] = useState('editor_nodte_area'); const [noteClazz, setNoteClazz] = useState('editor_nodte_area');
const [noteCount] = useState(5000); const [noteCount] = useState(5000);
// const [code, setCode] = useState(editor_code || hack.code); // const [code, setCode] = useState(editor_code || hack.code);
@ -65,8 +65,9 @@ const RightPane = (props) => {
let timer = null; // 定时器 let timer = null; // 定时器
// 代码块内容变化时 // 代码块内容变化时
const handleCodeChange = (value) => { const handleCodeChange = (value) => {
// console.log('编辑器代码 ======》》》》》》》》》++++++++++', value);
saveUserInputCode(value); saveUserInputCode(value);
setEditorCode(value); // setEditorCode(value);
if (!timer) { if (!timer) {
timer = setInterval(function () { timer = setInterval(function () {
clearInterval(timer); clearInterval(timer);
@ -116,6 +117,7 @@ const RightPane = (props) => {
const { getFieldDecorator } = props.form; const { getFieldDecorator } = props.form;
return ( return (
<div className={'right_pane_code_wrap'}> <div className={'right_pane_code_wrap'}>
<MyMonacoEditor <MyMonacoEditor
notice={notice} notice={notice}
identifier={identifier} identifier={identifier}

@ -4,7 +4,7 @@
* @Github: * @Github:
* @Date: 2019-11-27 13:42:11 * @Date: 2019-11-27 13:42:11
* @LastEditors : tangjiang * @LastEditors : tangjiang
* @LastEditTime : 2019-12-27 11:06:09 * @LastEditTime : 2020-01-02 14:17:49
*/ */
import types from "./actionTypes"; import types from "./actionTypes";
import { Base64 } from 'js-base64'; import { Base64 } from 'js-base64';
@ -116,16 +116,15 @@ export const saveUserCodeForInterval = (identifier, code) => {
}); });
// console.log('+++', userCode); // console.log('+++', userCode);
fetchUpdateCode(identifier, { fetchUpdateCode(identifier, {
code: userCode code: Base64.encode(userCode)
}).then(res => { }).then(res => {
if (res.data.status === 401) { if (res.data.status === 401) {
return; return;
}; };
dispatch({ // dispatch({
type: types.RESTORE_INITIAL_CODE, // type: types.RESTORE_INITIAL_CODE,
payload: userCode // payload: userCode
}); // });
setTimeout(() => { setTimeout(() => {
dispatch({ dispatch({
type: types.AUTO_UPDATE_CODE, type: types.AUTO_UPDATE_CODE,
@ -342,7 +341,7 @@ export const getUserCommitRecord = (identifier) => {
export const getUserCommitRecordDetail = (identifier) => { export const getUserCommitRecordDetail = (identifier) => {
return (dispatch) => { return (dispatch) => {
fetchUserCommitRecordDetail(identifier).then(res => { fetchUserCommitRecordDetail(identifier).then(res => {
console.log('提交记录详情======》》》》', res); // console.log('提交记录详情======》》》》', res);
const { data } = res; const { data } = res;
if (data.status === 401) return; if (data.status === 401) return;
dispatch({ dispatch({

@ -4,7 +4,7 @@
* @Github: * @Github:
* @Date: 2019-11-27 13:41:48 * @Date: 2019-11-27 13:41:48
* @LastEditors : tangjiang * @LastEditors : tangjiang
* @LastEditTime : 2019-12-27 21:28:28 * @LastEditTime : 2020-01-02 14:24:09
*/ */
import types from "../actions/actionTypes"; import types from "../actions/actionTypes";
import { Base64 } from 'js-base64'; import { Base64 } from 'js-base64';
@ -94,10 +94,11 @@ const ojForUserReducer = (state = initialState, action) => {
pages: Object.assign({}, state.pages, { total: records_count }) pages: Object.assign({}, state.pages, { total: records_count })
} }
case types.SAVE_USER_CODE: case types.SAVE_USER_CODE:
let curCode = Base64.encode(action.payload); // console.log('save_user_code: ', action.payload);
// let curCode = Base64.encode(action.payload);
return { return {
...state, ...state,
userCode: curCode, userCode: action.payload,
isUpdateCode: true, isUpdateCode: true,
} }
case types.IS_UPDATE_CODE: case types.IS_UPDATE_CODE:
@ -136,7 +137,6 @@ const ojForUserReducer = (state = initialState, action) => {
} else { } else {
curHack['code'] = ''; curHack['code'] = '';
} }
console.log(curHack);
return { return {
...state, ...state,
hack: Object.assign({}, state.hack, curHack), hack: Object.assign({}, state.hack, curHack),

Loading…
Cancel
Save