Merge branch 'dev_aliyun' of https://bdgit.educoder.net/Hjqreturn/educoder into dev_item_bank

yslnewtiku
杨树林 5 years ago
commit b167585f9d

@ -4,7 +4,7 @@
* @Github: * @Github:
* @Date: 2019-12-17 17:32:55 * @Date: 2019-12-17 17:32:55
* @LastEditors : tangjiang * @LastEditors : tangjiang
* @LastEditTime : 2019-12-26 11:11:57 * @LastEditTime : 2019-12-26 18:43:21
*/ */
import './index.scss'; import './index.scss';
import React, { useState } from 'react'; import React, { useState } from 'react';
@ -69,7 +69,7 @@ function CommentForm (props) {
props.form.setFieldsValue({'comment': ''}); props.form.setFieldsValue({'comment': ''});
setCtx(''); setCtx('');
// const _html = formatDelta(content.ops); // const _html = formatDelta(content.ops);
console.log('保存的内容=====》》》》', content); // console.log('保存的内容=====》》》》', content);
onSubmit && onSubmit(JSON.stringify(content)); onSubmit && onSubmit(JSON.stringify(content));
} }
}); });

@ -4,7 +4,7 @@
* @Github: * @Github:
* @Date: 2019-12-17 17:35:17 * @Date: 2019-12-17 17:35:17
* @LastEditors : tangjiang * @LastEditors : tangjiang
* @LastEditTime : 2019-12-26 11:30:32 * @LastEditTime : 2019-12-26 20:00:56
*/ */
import './index.scss'; import './index.scss';
import 'quill/dist/quill.core.css'; // 核心样式 import 'quill/dist/quill.core.css'; // 核心样式
@ -36,6 +36,8 @@ function CommentItem ({
const [showItemCount, setShowItemCount] = useState(5); const [showItemCount, setShowItemCount] = useState(5);
// 箭头方向 // 箭头方向
const [arrow, setArrow] = useState(false); const [arrow, setArrow] = useState(false);
// 上传图片的ulr
const [url, setUrl] = useState('');
const { const {
author = {}, // 作者 author = {}, // 作者
@ -85,6 +87,10 @@ function CommentItem ({
); );
}; };
const handleShowUploadImage = (url) => {
console.log('==============>>>>>>>>>>>>',url);
setUrl(url);
}
// 评论内容 // 评论内容
const commentCtx = (ctx) => { const commentCtx = (ctx) => {
let _ctx = null; let _ctx = null;
@ -97,6 +103,7 @@ function CommentItem ({
<QuillForEditor <QuillForEditor
readOnly={true} readOnly={true}
value={_ctx} value={_ctx}
showUploadImage={handleShowUploadImage}
/> />
)}; )};
@ -181,6 +188,10 @@ function CommentItem ({
} }
} }
const handleClose = () => {
setUrl('');
}
return ( return (
<li className="comment_item_area"> <li className="comment_item_area">
{commentAvatar(author)} {commentAvatar(author)}
@ -225,11 +236,17 @@ function CommentItem ({
<div <div
style={{ display: showQuill ? 'block' : 'none'}} style={{ display: showQuill ? 'block' : 'none'}}
className="comment_item_quill"> className="comment_item_quill">
<CommentForm <CommentForm
onCancel={handleClickCancel} onCancel={handleClickCancel}
onSubmit={handleClickSubmit(id)} onSubmit={handleClickSubmit(id)}
/> />
</div> </div>
{/* 显示上传的图片信息 */}
<div className="show_upload_image" style={{ display: url ? 'block' : 'none'}}>
<Icon type="close" className="image_close" onClick={handleClose}/>
<img className="image_info" src={url} alt=""/>
</div>
</div> </div>
</li> </li>
); );

@ -87,6 +87,39 @@ $ml: 20px;
// .comment_item_quill{ // .comment_item_quill{
// // margin-top: 10px; // // margin-top: 10px;
// } // }
.show_upload_image{
position: fixed;
left: 0;
top: 0;
right: 0;
bottom: 0;
z-index: 1000;
&::before{
position: absolute;
height: 100%;
width:100%;
content: '';
background: #000;
opacity: .5;
}
.image_info{
position: absolute;
width: 80%;
height: 80%;
left: 10%;
top: 10%;
background: green;
}
.image_close{
position: absolute;
right: 20px;
top: 20px;
color: #fff;
cursor: pointer;
}
}
} }
.comment_icon_count{ .comment_icon_count{
cursor: pointer; cursor: pointer;

@ -4,7 +4,7 @@
* @Github: * @Github:
* @Date: 2019-12-16 15:50:45 * @Date: 2019-12-16 15:50:45
* @LastEditors : tangjiang * @LastEditors : tangjiang
* @LastEditTime : 2019-12-24 09:44:03 * @LastEditTime : 2019-12-27 08:57:37
*/ */
import Quill from "quill"; import Quill from "quill";
@ -15,25 +15,38 @@ export default class ImageBlot extends BlockEmbed {
static create(value) { static create(value) {
const node = super.create(); const node = super.create();
node.setAttribute('alt', value.alt); node.setAttribute('alt', value.alt);
node.setAttribute('src', value.url); node.setAttribute('src', value.url);
console.log('~~~~~~~~~~~', node, value);
node.addEventListener('click', function () {
value.onclick(value.url);
}, false);
if (value.width) { if (value.width) {
node.setAttribute('width', value.width); node.setAttribute('width', value.width);
} }
if (value.height) { if (value.height) {
node.setAttribute('height', value.height); node.setAttribute('height', value.height);
} }
if (value.id) {
node.setAttribute('id', value.id);
}
// 宽度和高度都不存在时, // 宽度和高度都不存在时,
if (!value.width && !value.height) { if (!value.width && !value.height) {
node.setAttribute('display', 'block'); // node.setAttribute('display', 'block');
node.setAttribute('width', '100%'); node.setAttribute('width', '100%');
} }
node.setAttribute('style', { cursor: 'pointer' });
// if (node.onclick) {
// console.log('image 有图片点击事件======》》》》》》');
// // node.setAttribute('onclick', node.onCLick);
// }
// 给图片添加点击事件 // 给图片添加点击事件
node.onclick = () => { // node.onclick = () => {
value.onClick && value.onClick(value.url); // value.onClick && value.onClick(value.url);
} // }
return node; return node;
} }
@ -45,7 +58,9 @@ export default class ImageBlot extends BlockEmbed {
onclick: node.onclick, onclick: node.onclick,
width: node.width, width: node.width,
height: node.height, height: node.height,
display: node.getAttribute('display') display: node.getAttribute('display'),
id: node.id,
style: node.style
}; };
} }
} }

@ -4,7 +4,7 @@
* @Github: * @Github:
* @Date: 2019-12-18 08:49:30 * @Date: 2019-12-18 08:49:30
* @LastEditors : tangjiang * @LastEditors : tangjiang
* @LastEditTime : 2019-12-26 10:22:26 * @LastEditTime : 2019-12-26 19:36:00
*/ */
import './index.scss'; import './index.scss';
import 'quill/dist/quill.core.css'; // 核心样式 import 'quill/dist/quill.core.css'; // 核心样式
@ -116,9 +116,22 @@ function QuillForEditor ({
// 设置值 // 设置值
useEffect(() => { useEffect(() => {
if (!quill) return if (!quill) return
// debugger;
const previous = quill.getContents() const previous = quill.getContents()
const current = value
if (value && value.hasOwnProperty('ops')) {
console.log(value.ops);
const ops = value.ops || [];
ops.forEach((item, i) => {
if (item.insert['image']) {
item.insert['image'] = Object.assign({}, item.insert['image'], {style: { cursor: 'pointer' }, onclick: (url) => showUploadImage(url)});
}
});
}
const current = value
console.log('+++++', current);
if (!deepEqual(previous, current)) { if (!deepEqual(previous, current)) {
setSelection(quill.getSelection()) setSelection(quill.getSelection())
if (typeof value === 'string') { if (typeof value === 'string') {

@ -4,11 +4,11 @@
* @Github: * @Github:
* @Date: 2019-11-27 16:02:36 * @Date: 2019-11-27 16:02:36
* @LastEditors : tangjiang * @LastEditors : tangjiang
* @LastEditTime : 2019-12-26 15:17:28 * @LastEditTime : 2019-12-27 09:32:34
*/ */
import './index.scss'; import './index.scss';
import React, { useState, useRef, useEffect } from 'react'; import React, { useState, useRef, useEffect } from 'react';
import { Tabs, Button, Icon } from 'antd'; import { Tabs, Button, Icon, notification } from 'antd';
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import InitTabCtx from '../initTabCtx'; import InitTabCtx from '../initTabCtx';
import ExecResult from '../execResult'; import ExecResult from '../execResult';
@ -18,6 +18,7 @@ const { TabPane } = Tabs;
const ControlSetting = (props) => { const ControlSetting = (props) => {
const { const {
hack,
inputValue, inputValue,
loading, loading,
submitLoading, submitLoading,
@ -57,6 +58,13 @@ const ControlSetting = (props) => {
// 调试代码 // 调试代码
const handleTestCode = (e) => { const handleTestCode = (e) => {
if (!hack.code) {
notification.warning({
message: '提示',
description: '代码块内容不能为空'
});
return;
}
// console.log(formRef.current.handleTestCodeFormSubmit); // console.log(formRef.current.handleTestCodeFormSubmit);
// 调出控制台界面 // 调出控制台界面
setShowTextResult(true); setShowTextResult(true);
@ -137,8 +145,9 @@ const ControlSetting = (props) => {
const mapStateToProps = (state) => { const mapStateToProps = (state) => {
const {commonReducer, ojForUserReducer} = state; const {commonReducer, ojForUserReducer} = state;
const {loading, excuteState, submitLoading, showOrHideControl } = commonReducer; const {loading, excuteState, submitLoading, showOrHideControl } = commonReducer;
const { commitTestRecordDetail } = ojForUserReducer; const { commitTestRecordDetail, hack } = ojForUserReducer;
return { return {
hack,
loading, loading,
submitLoading, submitLoading,
excuteState, excuteState,

@ -3,8 +3,8 @@
* @Author: tangjiang * @Author: tangjiang
* @Github: * @Github:
* @Date: 2019-11-27 19:46:14 * @Date: 2019-11-27 19:46:14
* @LastEditors: tangjiang * @LastEditors : tangjiang
* @LastEditTime: 2019-12-19 10:47:05 * @LastEditTime : 2019-12-26 20:07:35
*/ */
import './index.scss'; import './index.scss';
import React, { useState, useEffect, useRef, useImperativeHandle, forwardRef } from 'react'; import React, { useState, useEffect, useRef, useImperativeHandle, forwardRef } from 'react';
@ -26,7 +26,7 @@ function InitTabCtx (props, ref) {
const { inputValue, onDebuggerCode } = props; const { inputValue, onDebuggerCode } = props;
console.log('default value', inputValue); // console.log('default value', inputValue);
useImperativeHandle(ref, () => ({ useImperativeHandle(ref, () => ({
handleTestCodeFormSubmit: (cb) => { handleTestCodeFormSubmit: (cb) => {
// console.log('父组件调用我啦~~~~~~~~~'); // console.log('父组件调用我啦~~~~~~~~~');
@ -34,9 +34,9 @@ function InitTabCtx (props, ref) {
} }
})); }));
useEffect(() => { // useEffect(() => {
console.log('初始值: ========', props); // console.log('初始值: ========', props);
}, [props]); // }, [props]);
// 渲染文本提示信息 // 渲染文本提示信息
const renderText = () => (<span className={'ctx_default'}>请在这里添加测试用例点击调试代码时将从这里读取输入来测试你的代码...</span>); const renderText = () => (<span className={'ctx_default'}>请在这里添加测试用例点击调试代码时将从这里读取输入来测试你的代码...</span>);

@ -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-26 15:19:34 * @LastEditTime : 2019-12-27 09:22:08
*/ */
import './index.scss'; import './index.scss';
import React, { useState, useRef, useEffect } from 'react'; import React, { useState, useRef, useEffect } from 'react';
@ -53,9 +53,7 @@ function MyMonacoEditor (props, ref) {
const editorRef = useRef(null); const editorRef = useRef(null);
useEffect(() => { useEffect(() => {
if (props.code) { setEditCode(props.code || '');
setEditCode(props.code);
}
}, [props]); }, [props]);
useEffect(() => { useEffect(() => {
@ -125,9 +123,9 @@ function MyMonacoEditor (props, ref) {
} }
} }
const renderRestore = identifier ? ( // const renderRestore = identifier ? (
<MyIcon type="iconzaicizairu" /> // <MyIcon type="iconzaicizairu" />
) : ''; // ) : '';
// lex_has_save ${hadCodeUpdate} ? : '' // lex_has_save ${hadCodeUpdate} ? : ''
const _classnames = hadCodeUpdate ? `flex_strict flex_has_save` : 'flex_strict'; const _classnames = hadCodeUpdate ? `flex_strict flex_has_save` : 'flex_strict';

@ -75,11 +75,11 @@ class InitTabCtx extends PureComponent {
handleTestCodeFormSubmit = (cb) => { handleTestCodeFormSubmit = (cb) => {
const {form, debuggerCode} = this.props; const {form, debuggerCode} = this.props;
console.log(debuggerCode); // console.log(debuggerCode);
form.validateFields((err, values) => { form.validateFields((err, values) => {
if (!err) { // 表单验证通过时,调用测试接口 if (!err) { // 表单验证通过时,调用测试接口
cb && cb(); // 调用回调函数,切换 tab cb && cb(); // 调用回调函数,切换 tab
console.log('表单值:', values); // console.log('表单值:', values);
debuggerCode(values); debuggerCode(values);
} }
}); });

@ -1,6 +1,7 @@
@import '../split_pane_resizer.scss'; @import '../split_pane_resizer.scss';
.record_detail_area{ .record_detail_area{
background: #fff;
.record_detail_ctx{ .record_detail_ctx{
padding: 0 20px; padding: 0 20px;
.detail_ctx_header{ .detail_ctx_header{
@ -39,6 +40,9 @@
} }
.result_error_area{ .result_error_area{
margin-top: 15px; margin-top: 15px;
background: rgba(250,250,250,1);
color: #E51C24;
border-radius: 3px;
} }
} }
} }

@ -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-26 17:56:51 * @LastEditTime : 2019-12-27 09:23:15
*/ */
import React, { useState, useEffect } from 'react'; import React, { useState, useEffect } from 'react';
import {connect} from 'react-redux'; import {connect} from 'react-redux';
@ -39,10 +39,12 @@ const RightPane = (props) => {
changeLoadingState changeLoadingState
} = props; } = props;
const [editorCode, setEditorCode] = useState(''); 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);
let initFlag = true; // const [code, setCode] = useState(editor_code || hack.code);
// let initFlag = true;
useEffect(() => { useEffect(() => {
if (editor_code) { if (editor_code) {
setEditorCode(editor_code); setEditorCode(editor_code);
@ -61,24 +63,18 @@ const RightPane = (props) => {
let timer = null; // 定时器 let timer = null; // 定时器
// 代码块内容变化时 // 代码块内容变化时
const handleCodeChange = (code) => { const handleCodeChange = (value) => {
// 保存用户提交的代码块 saveUserInputCode(value);
setEditorCode(code); setEditorCode(value);
// 第一次回填代码内容时不更新;
if (initFlag) {
initFlag = false;
return;
}
if (!timer) { if (!timer) {
timer = setInterval(() => { timer = setInterval(function () {
clearInterval(timer); clearInterval(timer);
timer = null; timer = null;
saveUserCodeForInterval && saveUserCodeForInterval(identifier, code); saveUserCodeForInterval(identifier);
}, 3000); }, 3000);
} }
// 保存用户代码块
saveUserInputCode(code);
} }
// 代码调试 // 代码调试
const handleDebuggerCode = (value) => { const handleDebuggerCode = (value) => {
// 调用保存代码块接口,成功后,调用调试接口 // 调用保存代码块接口,成功后,调用调试接口

@ -360,11 +360,11 @@ class Challengesjupyter extends Component {
let id=this.props.match.params.shixunId; let id=this.props.match.params.shixunId;
let that=this; let that=this;
Modal.confirm({ Modal.confirm({
title: '重置实训', title: '重置环境',
content: ( content: (
<p style={{ lineHeight: '24px' }}> <p style={{ lineHeight: '24px' }}>
你在本文件中修改的内容将丢失,<br /> 你在本文件中修改的内容将丢失,<br />
是否确定重新加载初始代码 是否确定重置环境
</p> </p>
), ),
okText: '确定', okText: '确定',
@ -430,9 +430,14 @@ class Challengesjupyter extends Component {
` `
.ant-notification{ .ant-notification{
position: fixed; position: fixed !important;
z-index: 3000; z-index: 3000 !important;
} }
.ant-modal-wrap {
position: fixed !important;
z-index: 3000 !important;
margin-top: 100px !important;
}
` `
} }
</style> </style>

@ -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-26 18:32:08 * @LastEditTime : 2019-12-27 09:28:38
*/ */
import types from "./actionTypes"; import types from "./actionTypes";
import { Base64 } from 'js-base64'; import { Base64 } from 'js-base64';
@ -108,25 +108,31 @@ export const getUserProgramDetail = (identifier, type) => {
} }
export const saveUserCodeForInterval = (identifier, code) => { export const saveUserCodeForInterval = (identifier, code) => {
return (dispatch) => { return (dispatch, getState) => {
const { userCode } = getState().ojForUserReducer;
dispatch({ dispatch({
type: types.AUTO_UPDATE_CODE, type: types.AUTO_UPDATE_CODE,
payload: true payload: true
}); });
console.log('+++', userCode);
fetchUpdateCode(identifier, { fetchUpdateCode(identifier, {
code: Base64.encode(code) code: userCode
}).then(res => { }).then(res => {
if (res.data.status === 401) { if (res.data.status === 401) {
return; return;
}; };
dispatch({
type: types.RESTORE_INITIAL_CODE,
payload: userCode
});
setTimeout(() => { setTimeout(() => {
dispatch({ dispatch({
type: types.AUTO_UPDATE_CODE, type: types.AUTO_UPDATE_CODE,
payload: false payload: false
}) })
}, 1000); }, 1000);
console.log('代码保存成功', res); // console.log('代码保存成功', res);
}).catch(() => { }).catch(() => {
dispatch({ dispatch({
type: types.AUTO_UPDATE_CODE, type: types.AUTO_UPDATE_CODE,

@ -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-26 18:34:56 * @LastEditTime : 2019-12-27 09:18:02
*/ */
import types from "../actions/actionTypes"; import types from "../actions/actionTypes";
import { Base64 } from 'js-base64'; import { Base64 } from 'js-base64';
@ -94,11 +94,10 @@ const ojForUserReducer = (state = initialState, action) => {
} }
case types.SAVE_USER_CODE: case types.SAVE_USER_CODE:
let curCode = Base64.encode(action.payload); let curCode = Base64.encode(action.payload);
return { return {
...state, ...state,
userCode: curCode, userCode: curCode,
isUpdateCode: true isUpdateCode: true,
} }
case types.IS_UPDATE_CODE: case types.IS_UPDATE_CODE:
return { return {
@ -133,11 +132,13 @@ const ojForUserReducer = (state = initialState, action) => {
let restoreCode = action.payload let restoreCode = action.payload
if (restoreCode) { if (restoreCode) {
curHack['code'] = Base64.decode(restoreCode); curHack['code'] = Base64.decode(restoreCode);
} else {
curHack['code'] = '';
} }
console.log('当前的代码内容:', curHack); console.log(curHack);
return { return {
...state, ...state,
hack: Object.assign({}, curHack) hack: Object.assign({}, state.hack, curHack)
} }
case types.SAVE_HACK_IDENTIFIER: case types.SAVE_HACK_IDENTIFIER:
return { return {

Loading…
Cancel
Save