修改预览与编辑器内容

dev_daiao
tangjiang 5 years ago
parent f5291f9fee
commit d5296fe5c3

@ -81,6 +81,7 @@
<!--需要去build js配置--> <!--需要去build js配置-->
<link rel="stylesheet" type="text/css" href="/css/iconfont.css"> <link rel="stylesheet" type="text/css" href="/css/iconfont.css">
<link rel="stylesheet" type="text/css" href="https://cdn.bootcss.com/quill/1.3.7/quill.core.min.css">
<style> <style>
/*<!--去除浏览器点击操作后有蓝色的底块-->*/ /*<!--去除浏览器点击操作后有蓝色的底块-->*/
-moz-user-select: none; -moz-user-select: none;
@ -187,6 +188,6 @@
<!-- <script type="text/javascript" src="https://testeduplus2.educoder.net/assets/kindeditor/kindeditor.js"></script> <!-- <script type="text/javascript" src="https://testeduplus2.educoder.net/assets/kindeditor/kindeditor.js"></script>
<script type="text/javascript" src="/js/create_kindeditor.js"></script> <script type="text/javascript" src="/js/create_kindeditor.js"></script>
<script type="text/javascript" src="https://testeduplus2.educoder.net/javascripts/educoder/edu_application.js"></script> --> <script type="text/javascript" src="https://testeduplus2.educoder.net/javascripts/educoder/edu_application.js"></script> -->
<script type="text/javascript" src="https://cdn.bootcss.com/quill/1.3.7/quill.core.min.js"></script>
</body> </body>
</html> </html>

@ -671,14 +671,12 @@ class App extends Component {
(props)=>(<Ecs {...this.props} {...props} {...this.state}></Ecs>) (props)=>(<Ecs {...this.props} {...props} {...this.state}></Ecs>)
}/> }/>
<Route path="/problems/new/:id?" component={NewOrEditTask} <Route path="/problems/new/:id?"
// render={ render={
// (props) => { (props) => {
// debugger; return (<NewOrEditTask {...this.props} {...props} {...this.state} />)
// console.log(this.props, props, this.state); }
// return (<NewOrEditTask {...this.props} {...props} {...this.state} />) }
// }
// }
/> />
<Route <Route
path="/problems/:id/edit" path="/problems/:id/edit"

@ -10,7 +10,6 @@ broadcastChannelOnmessage('refreshPage', () => {
}) })
function locationurl(list){ function locationurl(list){
debugger
if (window.location.port === "3007") { if (window.location.port === "3007") {
} else { } else {

@ -180,6 +180,7 @@ class DeveloperHome extends React.PureComponent {
// 是否是我的,如果是我的 显示编辑按钮 // 是否是我的,如果是我的 显示编辑按钮
const { isMySource } = this.props; const { isMySource } = this.props;
console.log(this.props);
if (isMySource) { if (isMySource) {
this.handleFilterSearch({come_from: 'mine'}); this.handleFilterSearch({come_from: 'mine'});
let _columns = this.columns.concat([this.options]); let _columns = this.columns.concat([this.options]);

@ -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-04 11:36:16 * @LastEditTime: 2019-12-05 10:17:04
*/ */
import './index.scss'; import './index.scss';
import React, { useState, useRef, useEffect } from 'react'; import React, { useState, useRef, useEffect } from 'react';
@ -21,13 +21,13 @@ function MyMonacoEditor (props, ref) {
const { const {
language, language,
code,
identifier, identifier,
showOrHideControl, showOrHideControl,
// saveUserInputCode, // saveUserInputCode,
onCodeChange, onCodeChange,
onRestoreInitialCode onRestoreInitialCode
} = props; } = props;
const [showDrawer, setShowDrawer] = useState(false); // 控制配置滑框 const [showDrawer, setShowDrawer] = useState(false); // 控制配置滑框
const [editCode, setEditCode] = useState(''); const [editCode, setEditCode] = useState('');
// const [curLang, setCurLang] = useState('C'); // const [curLang, setCurLang] = useState('C');
@ -36,10 +36,10 @@ function MyMonacoEditor (props, ref) {
const editorRef = useRef(null); const editorRef = useRef(null);
useEffect(() => { useEffect(() => {
if (code) { if (props.code) {
setEditCode(code); setEditCode(props.code);
} }
}, [code]); }, [props]);
useEffect(() => { useEffect(() => {
setHeight(showOrHideControl ? 'calc(100% - 382px)' : 'calc(100% - 112px)'); setHeight(showOrHideControl ? 'calc(100% - 382px)' : 'calc(100% - 112px)');
@ -81,7 +81,6 @@ function MyMonacoEditor (props, ref) {
// 恢复初始代码 // 恢复初始代码
const handleRestoreCode = () => { const handleRestoreCode = () => {
console.log('点击了恢复初始代码');
Modal.confirm({ Modal.confirm({
content: '确定要恢复代码吗?', content: '确定要恢复代码吗?',
okText: '确定', okText: '确定',

@ -58,6 +58,7 @@
} }
.dropdonw-style{ .dropdonw-style{
margin-right: 50px; margin-right: 50px;
cursor: pointer;
.dropdown-span{ .dropdown-span{
cursor: pointer; cursor: pointer;
margin-right: 10px; margin-right: 10px;

@ -4,7 +4,7 @@
* @Github: * @Github:
* @Date: 2019-11-20 10:35:40 * @Date: 2019-11-20 10:35:40
* @LastEditors: tangjiang * @LastEditors: tangjiang
* @LastEditTime: 2019-12-04 15:49:37 * @LastEditTime: 2019-12-04 19:56:43
*/ */
import 'quill/dist/quill.core.css'; import 'quill/dist/quill.core.css';
import 'quill/dist/quill.bubble.css'; import 'quill/dist/quill.bubble.css';
@ -25,9 +25,9 @@ const { Option } = Select;
const maps = { const maps = {
language: [ language: [
{ title: 'C', key: 'C' }, { title: 'C', key: 'C' },
{ title: 'C++', key: 'C++' }, // { title: 'C++', key: 'C++' },
{ title: 'Python', key: 'Python' }, // { title: 'Python', key: 'Python' },
{ title: 'Java', key: 'Java' } // { title: 'Java', key: 'Java' }
], ],
difficult: [ difficult: [
{ title: '简单', key: '1' }, { title: '简单', key: '1' },
@ -219,6 +219,16 @@ class EditTab extends React.Component {
this.scrollToBottom(); this.scrollToBottom();
} }
const quillConfig = [
[{ header: [1, 2, 3, 4, 5, 6, false] }],
['bold', 'italic', 'underline', 'strike'], // 切换按钮
['blockquote', 'code-block'], // 代码块
[{ 'list': 'ordered' }, { 'list': 'bullet' }], // 列表
[{ 'script': 'sub'}, { 'script': 'super' }],
[{ 'color': [] }, { 'background': [] }], // 字体颜色与背景色
['formula', 'image', 'video'], // 数学公式、图片、视频
['clean'], // 清除格式
];
return ( return (
<div className={'editor_area'} id="textCase"> <div className={'editor_area'} id="textCase">
<Form className={'editor_form'}> <Form className={'editor_form'}>
@ -260,6 +270,7 @@ class EditTab extends React.Component {
placeholder="请输入描述信息" placeholder="请输入描述信息"
onEditorChange={this.handleChangeDescription} onEditorChange={this.handleChangeDescription}
htmlCtx={ojForm.description} htmlCtx={ojForm.description}
options={quillConfig}
/> />
</FormItem> </FormItem>
<FormItem <FormItem

@ -4,43 +4,74 @@
* @Github: * @Github:
* @Date: 2019-11-24 10:09:55 * @Date: 2019-11-24 10:09:55
* @LastEditors: tangjiang * @LastEditors: tangjiang
* @LastEditTime: 2019-11-27 19:30:51 * @LastEditTime: 2019-12-04 23:38:37
*/ */
import './index.scss'; import './index.scss';
import React, { useEffect, useState } from 'react'; import React, { useEffect, useState, useRef } from 'react';
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import {Empty} from 'antd'; import {Empty} from 'antd';
import QuillEditor from '../../../quillEditor'; // import QuillEditor from '../../../quillEditor';
const Quill = window.Quill;
const PrevTab = (props) => { const PrevTab = (props) => {
// const { } = props; const {
const [desc, setDesc] = useState(''); description
} = props;
useEffect(() => { const prevRef = useRef(null);
setDesc(props.description); const [desc, setDesc] = useState('');
}, [props.description]); const [renderCtx, setRenderCtx] = useState(() => {
return function () {
return '';
}
});
const renderHtml = () => { // 空内容
if (!desc) { const renderTxt = () => (
return ( <div className='no_result'>
<div className={'no_result'}>
<Empty /> <Empty />
</div> </div>
); );
} else { // 渲染内容
return ( const renderQuill = () => (
<div className={'render_html'} dangerouslySetInnerHTML={{ __html: desc }}></div> <div
) id="quill_editor"
style = {{ height: '100%', width: '100%'}}
ref={prevRef}>
</div>
);
useEffect(() => {
setDesc(description);
}, [description]);
useEffect(() => {
if (description) {
setRenderCtx(() => renderQuill);
let count = 0;
let timer = setInterval(() => {
count++;
if (count >= 10 || prevRef.current) {
clearInterval(timer);
timer = null;
if (prevRef.current) {
const quillEditor = new Quill(prevRef.current, {
readOnly: true,
theme: 'bubble'
});
quillEditor.container.firstChild.innerHTML = description;
} }
} }
}, 50);
} else {
setRenderCtx(() => renderTxt);
}
}, [description]);
return ( return (
<div className={`prev_area`}> <div className={`prev_area`}>
{/* {renderHtml()} */} {renderCtx()}
{/* <div dangerouslySetInnerHTML={{ __html: desc }}></div> */}
<QuillEditor
style={{ height: 'calc(100% - 45px)', overflowY: 'auto' }}
options={[]}
readOnly={true}
htmlCtx={props.description}/>
</div> </div>
) )

@ -9,3 +9,9 @@
.render_html{ .render_html{
padding: 20px 30px; padding: 20px 30px;
} }
.prev_area{
// padding: 0 30px;
padding-left: 20px;
height: calc(100vh - 110px);
}

@ -4,12 +4,12 @@
* @Github: * @Github:
* @Date: 2019-11-25 09:46:03 * @Date: 2019-11-25 09:46:03
* @LastEditors: tangjiang * @LastEditors: tangjiang
* @LastEditTime: 2019-12-02 16:34:29 * @LastEditTime: 2019-12-04 23:09:38
*/ */
import 'quill/dist/quill.core.css'; // import 'quill/dist/quill.core.css';
import 'quill/dist/quill.bubble.css'; // import 'quill/dist/quill.bubble.css';
import 'quill/dist/quill.snow.css'; // import 'quill/dist/quill.snow.css';
import 'katex/dist/katex.css'; // import 'katex/dist/katex.css';
import './index.scss'; import './index.scss';
import React from 'react'; import React from 'react';
import katex from 'katex'; import katex from 'katex';
@ -17,7 +17,7 @@ const Quill = require('quill');
// 将katex挂载到window上 // 将katex挂载到window上
window.katex = katex; window.katex = katex;
window.Quill = Quill; window.Quill = Quill;
// const Quill = window.Quill;
// 指定 Quill 默认配置项 // 指定 Quill 默认配置项
const defaultOptions = [ const defaultOptions = [
[{ header: [1, 2, 3, 4, 5, 6, false] }], // 自定义标题大小 [{ header: [1, 2, 3, 4, 5, 6, false] }], // 自定义标题大小
@ -61,7 +61,7 @@ class QuillEditor extends React.Component {
componentDidMount () { componentDidMount () {
const { options, placeholder = '', readOnly = false } = this.props; const { options, placeholder = '', readOnly = false } = this.props;
let { quillEditor } = this.state; let { quillEditor } = this.state;
console.log(placeholder); // console.log(placeholder);
const renderOptions = options || defaultOptions; const renderOptions = options || defaultOptions;
const editorOption = { const editorOption = {
@ -83,11 +83,10 @@ class QuillEditor extends React.Component {
this.timer = setInterval(() => { this.timer = setInterval(() => {
count++; count++;
if (count >= 10 || this.props.htmlCtx) { if (count >= 10 || this.props.htmlCtx) {
quillEditor.container.firstChild.innerHTML = this.props.htmlCtx; quillEditor.container.firstChild.innerHTML = this.props.htmlCtx || '';
clearInterval(this.timer); clearInterval(this.timer);
this.timer = null; this.timer = null;
} }
// console.log('定时器====>>>>>', count);
}, 50); }, 50);
// quillEditor.setText('<p>aaa</p>'); // quillEditor.setText('<p>aaa</p>');

@ -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-04 10:36:06 * @LastEditTime: 2019-12-05 13:52:04
*/ */
import './index.scss'; import './index.scss';
import React, { useState, useEffect } from 'react'; import React, { useState, useEffect } from 'react';
@ -25,19 +25,22 @@ function RecordDetail (props) {
match: { params }, match: { params },
mygetHelmetapi = {}, mygetHelmetapi = {},
recordDetail, recordDetail,
identifier,
getUserCommitRecordDetail getUserCommitRecordDetail
} = props; } = props;
const identifier = params.id; const id = params.id;
const [detail, setDetail] = useState({}); const [detail, setDetail] = useState({});
useEffect(() => { useEffect(() => {
// 根据id获取记录详情 // 根据id获取记录详情
getUserCommitRecordDetail(identifier, 'detail'); console.log('提交记录详情', recordDetail);
getUserCommitRecordDetail(id, 'detail');
}, []); }, []);
useEffect(() => { useEffect(() => {
setDetail(recordDetail); setDetail(recordDetail);
}, [recordDetail]); }, [recordDetail]);
return ( return (
<div className="record_detail_area"> <div className="record_detail_area">
@ -53,7 +56,7 @@ function RecordDetail (props) {
</div> </div>
<div className={'study_quit'}> <div className={'study_quit'}>
<Button> <Button>
<Link to="/myproblems">返回该题</Link> <Link to={`/myproblems/${identifier}`}>返回该题</Link>
</Button> </Button>
</div> </div>
</div> </div>
@ -67,7 +70,7 @@ function RecordDetail (props) {
</span> </span>
<span className="status_label"> <span className="status_label">
提交时间: <span className="status_label_sub"> 提交时间: <span className="status_label_sub">
{/* moment(detail.) */} {moment(detail.created_at).format('YYYY-MM-DD HH:mm')}
</span> </span>
</span> </span>
<span className="status_label"> <span className="status_label">
@ -85,9 +88,10 @@ function RecordDetail (props) {
<MonacoEditor <MonacoEditor
height="100%" height="100%"
width="100%" width="100%"
language={'c'} language={(detail.language && detail.language.toLowerCase()) || ''}
value={'// init code'} value={detail.code || ''}
theme="dark" theme="dark"
readOnly={true}
/> />
</div> </div>
</div> </div>
@ -96,8 +100,9 @@ function RecordDetail (props) {
} }
const mapStateToProps = (state) => { const mapStateToProps = (state) => {
const {recordDetail} = state.ojForUserReducer; const {recordDetail, user_program_identifier} = state.ojForUserReducer;
return { return {
identifier: user_program_identifier,
recordDetail recordDetail
} }
} }

@ -16,6 +16,7 @@
top: 14px; top: 14px;
} }
.detail_ctx_status{ .detail_ctx_status{
height: 18px;
line-height: 18px; line-height: 18px;
.status_label{ .status_label{
color: rgba(153,153,153,1); color: rgba(153,153,153,1);
@ -33,7 +34,11 @@
} }
.result_code_area{ .result_code_area{
height: 500px; // height: 500px;
height: calc(100vh - 360px);
}
.result_error_area{
margin-top: 15px;
} }
} }
} }

@ -4,7 +4,7 @@
* @Github: * @Github:
* @Date: 2019-11-27 09:49:33 * @Date: 2019-11-27 09:49:33
* @LastEditors: tangjiang * @LastEditors: tangjiang
* @LastEditTime: 2019-12-04 10:37:33 * @LastEditTime: 2019-12-05 10:38:49
*/ */
import './index.scss'; import './index.scss';
import React, { useState, useEffect } from 'react'; import React, { useState, useEffect } from 'react';
@ -32,7 +32,11 @@ const columns = [
{ {
title: '提交结果', title: '提交结果',
dataIndex: 'status', dataIndex: 'status',
render: (value) => (<span style={{ color: value === 0 ? '#28BD8B' : '#E6262E'}}>{reviewResult[value]}</span>) render: (value, record) => (
<Link to={`/myproblems/record_detail/${record.id}`}>
<span style={{ color: value === 0 ? '#28BD8B' : '#E6262E'}}>{reviewResult[value]}</span>
</Link>
)
}, },
{ {
title: '执行用时', title: '执行用时',
@ -84,6 +88,7 @@ const CommitRecord = (props) => {
// 渲染提交记录详情 // 渲染提交记录详情
const renderRecordDetail = () => { const renderRecordDetail = () => {
const { const {
id,
error_line, error_line,
error_msg, error_msg,
execute_memory, execute_memory,
@ -110,7 +115,7 @@ const CommitRecord = (props) => {
</span> </span>
</p> </p>
<p className={'show_detail'}> <p className={'show_detail'}>
<Link to={`/myproblems/record_detail/${identifier}`}> <Link to={`/myproblems/record_detail/${id}`}>
显示详情 <Icon type="right" className={'icon_style'}/> 显示详情 <Icon type="right" className={'icon_style'}/>
</Link> </Link>
</p> </p>

@ -4,9 +4,9 @@
* @Github: * @Github:
* @Date: 2019-11-27 14:59:51 * @Date: 2019-11-27 14:59:51
* @LastEditors: tangjiang * @LastEditors: tangjiang
* @LastEditTime: 2019-12-04 10:57:49 * @LastEditTime: 2019-12-05 10:15:25
*/ */
import React from 'react'; import React, { useState, useEffect } from 'react';
import {connect} from 'react-redux'; import {connect} from 'react-redux';
import MyMonacoEditor from '../../components/myMonacoEditor'; import MyMonacoEditor from '../../components/myMonacoEditor';
import ControlSetting from '../../components/controlSetting'; import ControlSetting from '../../components/controlSetting';
@ -19,18 +19,25 @@ const RightPane = (props) => {
submitInput, submitInput,
submitUserCode, submitUserCode,
input, input,
hack,
updateCode, updateCode,
saveUserInputCode, saveUserInputCode,
restoreInitialCode restoreInitialCode
} = props; } = props;
const [editorCode, setEditorCode] = useState('');
useEffect(() => {
setEditorCode(hack.code);
}, [hack]);
const handleSubmitForm = () => { const handleSubmitForm = () => {
console.log('提交了表单内容');
// 提交时, 先调用提交接口,提交成功后,循环调用测评接口 // 提交时, 先调用提交接口,提交成功后,循环调用测评接口
submitUserCode(identifier, submitInput, 'submit'); submitUserCode(identifier, submitInput, 'submit');
// // 提交时,先调用评测接口, 评测通过后才调用保存接口 // // 提交时,先调用评测接口, 评测通过后才调用保存接口
// updateCode(identifier, submitInput, 'submit'); // updateCode(identifier, submitInput, 'submit');
} }
// 代码块内容变化时 // 代码块内容变化时
const handleCodeChange = (code) => { const handleCodeChange = (code) => {
// 保存用户提交的代码块 // 保存用户提交的代码块
@ -52,8 +59,8 @@ const RightPane = (props) => {
<div className={'right_pane_code_wrap'}> <div className={'right_pane_code_wrap'}>
<MyMonacoEditor <MyMonacoEditor
identifier={identifier} identifier={identifier}
language={props.language} language={hack.language}
code={props.code} code={editorCode}
onCodeChange={handleCodeChange} onCodeChange={handleCodeChange}
onRestoreInitialCode={handleRestoreInitialCode} onRestoreInitialCode={handleRestoreInitialCode}
/> />
@ -69,10 +76,9 @@ const RightPane = (props) => {
const mapStateToProps = (state) => { const mapStateToProps = (state) => {
const {user_program_identifier, hack, userTestInput} = state.ojForUserReducer; const {user_program_identifier, hack, userTestInput} = state.ojForUserReducer;
const { language, code } = hack; // const { language, code } = hack;
return { return {
language, hack,
code,
input: userTestInput, input: userTestInput,
submitInput: hack.input, submitInput: hack.input,
identifier: user_program_identifier identifier: user_program_identifier

@ -469,6 +469,7 @@ class LoginDialog extends Component {
autologin:isGoingValue autologin:isGoingValue
} }
).then((response) => { ).then((response) => {
debugger;
if(response===undefined){ if(response===undefined){
return return
} }

@ -37,6 +37,11 @@ class VNCContainer extends Component {
} }
} }
shouldComponentUpdate () {
return false;
}
getSecondDrawerWidth = () => { getSecondDrawerWidth = () => {
return $('#game_right_contents').width() - firstDrawerWidth return $('#game_right_contents').width() - firstDrawerWidth
} }

@ -47,7 +47,7 @@ const five_min = 5 * 60 * 1000;
倒计时为0时出现重启按钮 倒计时为0时出现重启按钮
*/ */
const isSSHInIframe = false; const isSSHInIframe = false;
class WebSSHTimer extends Component { class WebSSHTimer extends React.PureComponent {
constructor(props) { constructor(props) {
super(props) super(props)
@ -63,6 +63,7 @@ class WebSSHTimer extends Component {
} }
init() { init() {
console.log('调用定时器开始: =========>>>>>>>>>>>>');
// 20分钟倒计时 // 20分钟倒计时
this.timeRemain = 20 * 60 * 1000; this.timeRemain = 20 * 60 * 1000;
this.startTimeRemain = 0 this.startTimeRemain = 0
@ -85,7 +86,6 @@ class WebSSHTimer extends Component {
return; return;
} }
let _timeRemain = this.timeRemain; let _timeRemain = this.timeRemain;
$('.webSSHTimer').html(moment(_timeRemain).format('mm:ss')) $('.webSSHTimer').html(moment(_timeRemain).format('mm:ss'))
_timeRemain -= 1000 _timeRemain -= 1000
this.timeRemain = _timeRemain; this.timeRemain = _timeRemain;
@ -165,6 +165,7 @@ class WebSSHTimer extends Component {
}) })
} }
componentDidUpdate(prevProps, prevState, snapshot) { componentDidUpdate(prevProps, prevState, snapshot) {
console.log('======',prevProps, this.state, this.startTimeRemain);
// 仅初始化一次 // 仅初始化一次
if (prevProps.showTimerProp === false && this.props.showTimerProp === true) { if (prevProps.showTimerProp === false && this.props.showTimerProp === true) {
if (this.intervalHandler) { if (this.intervalHandler) {
@ -320,7 +321,7 @@ class WebSSHTimer extends Component {
{ this.props.showTimerProp === true && showTimer === true && { this.props.showTimerProp === true && showTimer === true &&
<Popconfirm <Popconfirm
title={<span><p>实验环境将恢复到初始状态</p><p>?</p></span>} title={<React.Fragment><p>实验环境将恢复到初始状态</p><p>?</p></React.Fragment>}
placement="bottom" placement="bottom"
onConfirm={this.resetSsh} okText="确定" cancelText="取消"> onConfirm={this.resetSsh} okText="确定" cancelText="取消">

@ -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-04 15:50:54 * @LastEditTime: 2019-12-05 10:44:17
*/ */
import types from "./actionTypes"; import types from "./actionTypes";
import { Base64 } from 'js-base64'; import { Base64 } from 'js-base64';
@ -32,9 +32,18 @@ export const startProgramQuestion = (id, props) => {
payload: identifier payload: identifier
}); });
// 跳转至开启编程 // 跳转至开启编程
debugger; if (identifier) {
props.history.push(`/myproblems/${identifier}`); // let data = Object.assign({}, props);
// Redirect.to // const path = {
// pathname: `/myproblems/${identifier}`,
// state: data
// }
// console.log(path);
// props.history.push(`/myproblems/${identifier}`);
props.history.push({
pathname: `/myproblems/${identifier}`,
});
}
} }
}) })
} }
@ -55,6 +64,7 @@ export const getUserProgramDetail = (identifier, type) => {
fetchUserProgramDetail(identifier).then(res => { fetchUserProgramDetail(identifier).then(res => {
const { status, data = {} } = res; const { status, data = {} } = res;
if (status === 200) { if (status === 200) {
if (data.status === 401) return;
if (!type) { if (!type) {
dispatch({ dispatch({
type: types.USER_PROGRAM_DETAIL, type: types.USER_PROGRAM_DETAIL,
@ -86,6 +96,13 @@ export const updateCode = (identifier, inputValue, type) => {
}).then(res => { }).then(res => {
// 是否更新了代码, 目的是当代码没有更新时不调用更新代码接口,目录没有实现 // 是否更新了代码, 目的是当代码没有更新时不调用更新代码接口,目录没有实现
// TODO 需要优化 // TODO 需要优化
if (res.data.status === 401) {
dispatch({ // 改变 loading 值
type: types.LOADING_STATUS,
payload: false
});
return;
};
dispatch({ dispatch({
type: types.IS_UPDATE_CODE, type: types.IS_UPDATE_CODE,
flag: false flag: false
@ -132,7 +149,13 @@ export const debuggerCode = (identifier,value, type) => {
* @param {*} count 执行次数 * @param {*} count 执行次数
* @param {*} timer 定时器 * @param {*} timer 定时器
*/ */
if (res.data.status === 401) {
dispatch({ // 改变 loading 值
type: types.LOADING_STATUS,
payload: false
});
return;
};
function getCodeSubmit (intervalTime, finalTime, count, timer){ function getCodeSubmit (intervalTime, finalTime, count, timer){
const excuteTime = (count++) * intervalTime; // 当前执行时间 const excuteTime = (count++) * intervalTime; // 当前执行时间
fetchCodeSubmit(identifier, { mode: type }).then(res => { fetchCodeSubmit(identifier, { mode: type }).then(res => {
@ -241,6 +264,10 @@ export const getUserCommitRecordDetail = (identifier) => {
return (dispatch) => { return (dispatch) => {
fetchUserCommitRecordDetail(identifier).then(res => { fetchUserCommitRecordDetail(identifier).then(res => {
console.log('提交记录详情======》》》》', res); console.log('提交记录详情======》》》》', res);
dispatch({
type: types.GET_COMMIT_RECORD_DETAIL_BY_ID,
payload: res.data
})
}); });
} }
} }
@ -280,6 +307,13 @@ export const submitUserCode = (identifier, inputValue, type) => {
fetchUserCodeSubmit(identifier).then(res => { fetchUserCodeSubmit(identifier).then(res => {
// console.log('用户提交代码成功======》》》》》', res); // console.log('用户提交代码成功======》》》》》', res);
if (res.status === 200) { if (res.status === 200) {
if (res.data.status === 401) {
dispatch({
type: types.SUBMIT_LOADING_STATUS,
payload: false
});
return;
};
dispatch(debuggerCode(identifier, inputValue, type || 'submit')); dispatch(debuggerCode(identifier, inputValue, type || 'submit'));
} }
}).catch(() => { }).catch(() => {
@ -295,6 +329,13 @@ export const submitUserCode = (identifier, inputValue, type) => {
}).then(res => { }).then(res => {
// 是否更新了代码, 目的是当代码没有更新时不调用更新代码接口,目录没有实现 // 是否更新了代码, 目的是当代码没有更新时不调用更新代码接口,目录没有实现
// TODO 需要优化 // TODO 需要优化
if (res.data.status === 401) {
dispatch({
type: types.SUBMIT_LOADING_STATUS,
payload: false
});
return;
};
dispatch({ dispatch({
type: types.IS_UPDATE_CODE, type: types.IS_UPDATE_CODE,
flag: false flag: false
@ -312,10 +353,19 @@ export const submitUserCode = (identifier, inputValue, type) => {
} }
} }
// 恢复初始代码
export const restoreInitialCode = (identifier) => { export const restoreInitialCode = (identifier) => {
return (dispatch) => { return (dispatch) => {
fetchRestoreInitialCode(identifier).then(res => { fetchRestoreInitialCode(identifier).then(res => {
if (res.data.status === 401) return;
console.log('恢复初始代码====》》》》', res); console.log('恢复初始代码====》》》》', res);
const {status, data} = res;
if (status === 200) {
dispatch({
type: types.RESTORE_INITIAL_CODE,
payload: data.code
})
}
}); });
} }
} }

@ -4,7 +4,7 @@
* @Github: * @Github:
* @Date: 2019-11-20 16:35:46 * @Date: 2019-11-20 16:35:46
* @LastEditors: tangjiang * @LastEditors: tangjiang
* @LastEditTime: 2019-12-02 19:22:58 * @LastEditTime: 2019-12-05 08:47:50
*/ */
import types from './actionTypes'; import types from './actionTypes';
import CONST from '../../constants'; import CONST from '../../constants';
@ -83,7 +83,7 @@ const payloadInfo = (key, value, errMsg, validateInfo) => ({
export const validateOjForm = (props, type) => { export const validateOjForm = (props, type) => {
return (dispatch, getState) => { return (dispatch, getState) => {
const {ojForm, testCases, identifier, code } = getState().ojFormReducer; const {ojForm, testCases, identifier, code } = getState().ojFormReducer;
console.log('code', code); // console.log('code', code);
let keys = Object.keys(ojForm); let keys = Object.keys(ojForm);
// 循环判断每个字段是否为空 // 循环判断每个字段是否为空
let hasSuccess = true; let hasSuccess = true;
@ -125,13 +125,13 @@ export const validateOjForm = (props, type) => {
}); });
} }
if (!code) { // if (!code) {
hasSuccess = false; // hasSuccess = false;
notification['error']({ // notification['error']({
message: '必填', // message: '必填',
description: '代码块内容必须输入!' // description: '代码块内容必须输入!'
}); // });
} // }
// 更改测试用例验证结果 // 更改测试用例验证结果
dispatch({ dispatch({
type: types.UPDATE_TEST_AND_VALIDATE, type: types.UPDATE_TEST_AND_VALIDATE,
@ -219,8 +219,9 @@ export const validateOjForm = (props, type) => {
if (res.status === 200) { // 保存成功后,重新跳转至列表页 if (res.status === 200) { // 保存成功后,重新跳转至列表页
const {identifier} = res.data const {identifier} = res.data
if (type === 'publish') { // 存在发布时,直接调用发布接口 if (type === 'publish') { // 存在发布时,直接调用发布接口
identifier && publishTask(identifier).then(res => { if (identifier) {
if (res.status === 200) { publishTask(identifier).then(res => {
if (res.data.status === 0) {
message.success('发布成功!'); message.success('发布成功!');
linkToDev(); linkToDev();
} }
@ -235,8 +236,16 @@ export const validateOjForm = (props, type) => {
}); });
}); });
} else { } else {
dispatch({
type: types.PUBLISH_LOADING_STATUS,
payload: false
});
}
} else {
if (res.data.identifier) {
message.success('保存成功!'); message.success('保存成功!');
linkToDev(); linkToDev();
}
dispatch({ dispatch({
type: types.SUBMIT_LOADING_STATUS, type: types.SUBMIT_LOADING_STATUS,
payload: false payload: false

@ -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-04 09:02:30 * @LastEditTime: 2019-12-05 13:37:17
*/ */
import types from "../actions/actionTypes"; import types from "../actions/actionTypes";
import { Base64 } from 'js-base64'; import { Base64 } from 'js-base64';
@ -23,6 +23,7 @@ const initialState = {
}; };
const ojForUserReducer = (state = initialState, action) => { const ojForUserReducer = (state = initialState, action) => {
let tempDetail = null;
switch (action.type) { switch (action.type) {
case types.SAVE_USER_PROGRAM_ID: case types.SAVE_USER_PROGRAM_ID:
return { return {
@ -80,9 +81,33 @@ const ojForUserReducer = (state = initialState, action) => {
userCodeTab: action.payload userCodeTab: action.payload
} }
case types.GET_COMMIT_RECORD_DETAIL_BY_ID: case types.GET_COMMIT_RECORD_DETAIL_BY_ID:
tempDetail = action.payload;
if (tempDetail['error_msg']) {
tempDetail['error_msg'] = Base64.decode(tempDetail['error_msg']);
}
if (tempDetail['expected_output']) {
tempDetail['expected_output'] = Base64.decode(tempDetail['expected_output']);
}
if (tempDetail['output']) {
tempDetail['output'] = Base64.decode(tempDetail['output']);
}
if (tempDetail['code']) {
tempDetail['code'] = Base64.decode(tempDetail['code']);
}
return {
...state,
recordDetail: tempDetail
}
case types.RESTORE_INITIAL_CODE:
const curHack = state.hack;
let restoreCode = action.payload
if (restoreCode) {
curHack['code'] = Base64.decode(restoreCode);
}
console.log('当前的代码内容:', curHack);
return { return {
...state, ...state,
recordDetail: action.payload hack: Object.assign({}, curHack)
} }
default: default:
return state; return state;

@ -4,7 +4,7 @@
* @Github: * @Github:
* @Date: 2019-11-20 16:40:32 * @Date: 2019-11-20 16:40:32
* @LastEditors: tangjiang * @LastEditors: tangjiang
* @LastEditTime: 2019-12-04 15:36:26 * @LastEditTime: 2019-12-05 09:35:29
*/ */
import { Base64 } from 'js-base64'; import { Base64 } from 'js-base64';
import types from '../actions/actionTypes'; import types from '../actions/actionTypes';
@ -262,12 +262,18 @@ const ojFormReducer = (state = initialState, action) => {
} }
case types.UPDATE_TEST_AND_VALIDATE: // 保存或更新测试用例值 case types.UPDATE_TEST_AND_VALIDATE: // 保存或更新测试用例值
const tempValitate = action.payload.testCaseValidate; const tempValitate = action.payload.testCaseValidate;
const openColArrs = [];
const curOjTestCaseValidate = state.testCasesValidate.map((tc, i) => { const curOjTestCaseValidate = state.testCasesValidate.map((tc, i) => {
if (tempValitate[i].input.errMsg || tempValitate[i].output.errMsg) {
openColArrs.push(i);
}
return Object.assign({}, tc, tempValitate[i]); return Object.assign({}, tc, tempValitate[i]);
}); });
// console.log('+++++++++++', openColArrs);
return { return {
...state, ...state,
testCasesValidate: [...curOjTestCaseValidate] testCasesValidate: [...curOjTestCaseValidate],
openTestCodeIndex: openColArrs
} }
case types.UPDATE_OPEN_TESTCASE_INDEX: case types.UPDATE_OPEN_TESTCASE_INDEX:
const tempArr = []; const tempArr = [];

@ -4,7 +4,7 @@
* @Github: * @Github:
* @Date: 2019-11-20 10:55:38 * @Date: 2019-11-20 10:55:38
* @LastEditors: tangjiang * @LastEditors: tangjiang
* @LastEditTime: 2019-12-04 10:53:41 * @LastEditTime: 2019-12-04 18:05:10
*/ */
import axios from 'axios'; import axios from 'axios';
@ -73,7 +73,6 @@ export async function fetchUserCommitRecord (identifier) {
// 获取提交记录详情 // 获取提交记录详情
export async function fetchUserCommitRecordDetail (identifier) { export async function fetchUserCommitRecordDetail (identifier) {
const url = `/myproblems/record_detail.json`; const url = `/myproblems/record_detail.json`;
debugger;
const params = {id: identifier}; const params = {id: identifier};
return axios.get(url, {params}); return axios.get(url, {params});
} }

Loading…
Cancel
Save