From da11a9079f1c154b2688153e762713350a5a9075 Mon Sep 17 00:00:00 2001
From: tangjiang <465264938@qq.com>
Date: Fri, 27 Dec 2019 20:06:01 +0800
Subject: [PATCH 1/9] update code not show
---
.../components/myMonacoEditor/index2.js | 48 +++++++++++++++++++
.../newOrEditTask/rightpane/index.js | 10 ++--
.../developer/studentStudy/rightpane/index.js | 19 ++++----
public/react/src/redux/actions/ojForm.js | 14 +++---
.../src/redux/reducers/ojForUserReducer.js | 4 +-
.../react/src/redux/reducers/ojFormReducer.js | 6 ++-
6 files changed, 78 insertions(+), 23 deletions(-)
create mode 100644 public/react/src/modules/developer/components/myMonacoEditor/index2.js
diff --git a/public/react/src/modules/developer/components/myMonacoEditor/index2.js b/public/react/src/modules/developer/components/myMonacoEditor/index2.js
new file mode 100644
index 000000000..097fa2975
--- /dev/null
+++ b/public/react/src/modules/developer/components/myMonacoEditor/index2.js
@@ -0,0 +1,48 @@
+/*
+ * @Description:
+ * @Author: tangjiang
+ * @Github:
+ * @Date: 2019-12-27 19:18:09
+ * @LastEditors: tangjiang
+ * @LastEditTime: 2019-12-27 19:19:23
+ */
+import React, { useState } from 'react';
+import Editor from "@monaco-editor/react";
+
+function App() {
+ const [theme, setTheme] = useState("light");
+ const [language, setLanguage] = useState("javascript");
+ const [isEditorReady, setIsEditorReady] = useState(false);
+
+ function handleEditorDidMount() {
+ setIsEditorReady(true);
+ }
+
+ function toggleTheme() {
+ setTheme(theme === "light" ? "dark" : "light");
+ }
+
+ function toggleLanguage() {
+ setLanguage(language === "javascript" ? "python" : "javascript");
+ }
+
+ return (
+
+
+
+
+
+
+
+ );
+}
\ No newline at end of file
diff --git a/public/react/src/modules/developer/newOrEditTask/rightpane/index.js b/public/react/src/modules/developer/newOrEditTask/rightpane/index.js
index 16533c624..d42089d7f 100644
--- a/public/react/src/modules/developer/newOrEditTask/rightpane/index.js
+++ b/public/react/src/modules/developer/newOrEditTask/rightpane/index.js
@@ -4,10 +4,10 @@
* @Github:
* @Date: 2019-12-01 10:18:35
* @LastEditors : tangjiang
- * @LastEditTime : 2019-12-27 10:17:07
+ * @LastEditTime : 2019-12-27 19:33:50
*/
import './index.scss';
-import React from 'react';
+import React, { useState, useEffect } from 'react';
import { connect } from 'react-redux';
import MyMonacoEditor from '../../components/myMonacoEditor';
// import ControlSetting from '../../components/controlSetting';
@@ -18,6 +18,7 @@ function RightPane (props, ref) {
const {
// identifier,
code,
+ showCode,
language,
// onSubmitForm,
saveOjFormCode
@@ -46,7 +47,7 @@ function RightPane (props, ref) {
{/* {
- const { ojForm, testCases, code, identifier } = state.ojFormReducer;
+ const { ojForm, testCases, code, identifier, showCode } = state.ojFormReducer;
return {
code,
+ showCode,
identifier,
language: ojForm.language,
input: (testCases[0] && testCases[0].input) || '',
diff --git a/public/react/src/modules/developer/studentStudy/rightpane/index.js b/public/react/src/modules/developer/studentStudy/rightpane/index.js
index 8f4ac2533..ed500fb3a 100644
--- a/public/react/src/modules/developer/studentStudy/rightpane/index.js
+++ b/public/react/src/modules/developer/studentStudy/rightpane/index.js
@@ -4,7 +4,7 @@
* @Github:
* @Date: 2019-11-27 14:59:51
* @LastEditors : tangjiang
- * @LastEditTime : 2019-12-27 10:28:41
+ * @LastEditTime : 2019-12-27 19:23:46
*/
import React, { useState, useEffect } from 'react';
import {connect} from 'react-redux';
@@ -45,13 +45,14 @@ const RightPane = (props) => {
// const [code, setCode] = useState(editor_code || hack.code);
// let initFlag = true;
- useEffect(() => {
- if (editor_code) {
- setEditorCode(editor_code);
- } else {
- setEditorCode(hack.code);
- }
- }, [hack, editor_code]);
+ // useEffect(() => {
+ // if (editor_code) {
+ // setEditorCode(editor_code);
+ // } else {
+ // setEditorCode(hack.code);
+ // }
+ // }, [hack, editor_code]);
+
const handleSubmitForm = () => {
// 提交时, 先调用提交接口,提交成功后,循环调用测评接口
@@ -119,7 +120,7 @@ const RightPane = (props) => {
notice={notice}
identifier={identifier}
language={hack.language}
- code={editorCode}
+ code={editor_code || hack.code}
hadCodeUpdate={hadCodeUpdate}
onCodeChange={handleCodeChange}
onUpdateNotice={handleUpdateNotice}
diff --git a/public/react/src/redux/actions/ojForm.js b/public/react/src/redux/actions/ojForm.js
index 094257f42..4e9173a3e 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 : 2019-12-27 18:50:22
+ * @LastEditTime : 2019-12-27 20:03:12
*/
import types from './actionTypes';
import CONST from '../../constants';
@@ -286,20 +286,22 @@ export const validateOjForm = (props, type, cb) => {
} else if (type === 'challenge') {
cb && cb();
} else {
+ const {identifier} = res.data;
+ // if (paramsObj['submitType'] === 'add' && identifier) {
+ // dispatch(validateOjForm(props, 'update'));
+ // props.history.push(`/problems/${identifier}/edit`);
+ // return;
+ // };
// message.success(paramsObj['submitType'] === 'update' ? '更新成功' : '保存成功');
notification.success({
message: '提示',
description: paramsObj['submitType'] === 'update' ? '更新成功' : '保存成功'
});
- const {identifier} = res.data;
// 保存成功后的identifier
identifier && dispatch({
type: types.SAVE_OJ_FORM_ID,
payload: identifier
});
- if (paramsObj['submitType'] === 'add' && identifier) {
- props.history.push(`/problems/${identifier}/edit`)
- };
}
// 保存或更新后,调用start接口
// linkToDev(dispatch, props);
@@ -502,7 +504,7 @@ export const deleteTestCase = (obj) => {
export const getOJFormById = (id) => {
return (dispatch) => {
fetchGetOjById(id).then(res => {
- console.log('获取OJ表单信息成功: ', res);
+ // console.log('获取OJ表单信息成功: ', res);
dispatch({
type: types.SAVE_EDIT_OJ_FORM_AND_TEST_CASE,
payload: res.data
diff --git a/public/react/src/redux/reducers/ojForUserReducer.js b/public/react/src/redux/reducers/ojForUserReducer.js
index cbf0a04f3..e95adf0ec 100644
--- a/public/react/src/redux/reducers/ojForUserReducer.js
+++ b/public/react/src/redux/reducers/ojForUserReducer.js
@@ -4,7 +4,7 @@
* @Github:
* @Date: 2019-11-27 13:41:48
* @LastEditors : tangjiang
- * @LastEditTime : 2019-12-27 16:52:30
+ * @LastEditTime : 2019-12-27 19:56:06
*/
import types from "../actions/actionTypes";
import { Base64 } from 'js-base64';
@@ -179,7 +179,7 @@ const ojForUserReducer = (state = initialState, action) => {
commitTestRecordDetail: {}, // 调试代码执行结果
commitRecordDetail: {}, // 提交成功后记录提交的详情
commitRecord: [], // 提交记录
- userCode: '', // 保存当前用户输入的代码
+ // userCode: '', // 保存当前用户输入的代码
isUpdateCode: false, // 是否更新了代码内容
userCodeTab: 'task', // 学员测评tab位置: task | record | comment
userTestInput: '', // 用户自定义输入值
diff --git a/public/react/src/redux/reducers/ojFormReducer.js b/public/react/src/redux/reducers/ojFormReducer.js
index b214eb3bc..952919aca 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 : 2019-12-27 10:35:06
+ * @LastEditTime : 2019-12-27 20:00:26
*/
import { Base64 } from 'js-base64';
import types from '../actions/actionTypes';
@@ -61,6 +61,7 @@ const init = {
position: 1, // TODO 每次加载信息时同步指定positio值
score: 200, // 分值: 选择难易度后自动计算分值 200 | 500 | 1000
code: '', // 提交的代码
+ showCode: '', // 编辑器显示的代码
identifier: '', // OJ表单id
loading: false, // 僵尸loading标志
testCodeStatus: 'default', // 调试代码状态 default(默认值) | loading(加载中) | loaded(加载完成) | userCase(用户自定义测试用例) | finish(测试完成)
@@ -216,7 +217,8 @@ const ojFormReducer = (state = initialState, action) => {
testCases: curTestCases,
testCasesValidate: curTcValidates,
testCodeStatus: hack_sets.length > 0 ? 'userCase' : 'default',
- isPublish: status
+ isPublish: status,
+ showCode: cbcode
}
case types.CHANGE_PUBLISH_VALUE:
return {
From fbf226979661d376d579d3676b5b6268bbbd01f2 Mon Sep 17 00:00:00 2001
From: daiao <358551898@qq.com>
Date: Fri, 27 Dec 2019 20:08:20 +0800
Subject: [PATCH 2/9] 1
---
app/views/hack_user_lastest_codes/show.json.jbuilder | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/app/views/hack_user_lastest_codes/show.json.jbuilder b/app/views/hack_user_lastest_codes/show.json.jbuilder
index a158d074f..f866b3151 100644
--- a/app/views/hack_user_lastest_codes/show.json.jbuilder
+++ b/app/views/hack_user_lastest_codes/show.json.jbuilder
@@ -2,6 +2,7 @@ json.hack do
json.(@hack, :id, :name, :difficult, :time_limit, :description, :score, :identifier, :status, :praises_count)
json.language @hack.language
json.username @hack.user.real_name
+ json.user_path "/users/#{@hack.user.login}"
json.code @my_hack.code
json.pass_count @hack.pass_num
json.submit_count @hack.submit_num
@@ -19,5 +20,4 @@ json.user do
json.partial! 'users/user', user: current_user
json.hack_manager @hack.manager?(current_user)
json.admin current_user.admin_or_business?
-
end
\ No newline at end of file
From 8ad24ce770583204ca4ae5802f5049b9bf931718 Mon Sep 17 00:00:00 2001
From: daiao <358551898@qq.com>
Date: Fri, 27 Dec 2019 20:08:32 +0800
Subject: [PATCH 3/9] =?UTF-8?q?=E9=93=BE=E6=8E=A5?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/views/hack_user_lastest_codes/show.json.jbuilder | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/app/views/hack_user_lastest_codes/show.json.jbuilder b/app/views/hack_user_lastest_codes/show.json.jbuilder
index f866b3151..04b066aa0 100644
--- a/app/views/hack_user_lastest_codes/show.json.jbuilder
+++ b/app/views/hack_user_lastest_codes/show.json.jbuilder
@@ -1,8 +1,8 @@
json.hack do
json.(@hack, :id, :name, :difficult, :time_limit, :description, :score, :identifier, :status, :praises_count)
json.language @hack.language
- json.username @hack.user.real_name
- json.user_path "/users/#{@hack.user.login}"
+ json.username @hack.user&.real_name
+ json.user_path "/users/#{@hack.user&.login}"
json.code @my_hack.code
json.pass_count @hack.pass_num
json.submit_count @hack.submit_num
From f1a9828ca52d27cfeb2eebaf2792335b1fc17fe6 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E6=9D=A8=E6=A0=91=E6=9E=97?= <904079904@qq.com>
Date: Fri, 27 Dec 2019 20:13:29 +0800
Subject: [PATCH 4/9] =?UTF-8?q?=E8=B0=83=E6=95=B4?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../src/modules/courses/coursesDetail/CoursesBanner.js | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/public/react/src/modules/courses/coursesDetail/CoursesBanner.js b/public/react/src/modules/courses/coursesDetail/CoursesBanner.js
index 03d0816a3..8a71e36e6 100644
--- a/public/react/src/modules/courses/coursesDetail/CoursesBanner.js
+++ b/public/react/src/modules/courses/coursesDetail/CoursesBanner.js
@@ -722,10 +722,12 @@ class CoursesBanner extends Component {
color: rgba(255,255,255,0.3) !important;
}
.ant-tooltip-inner{
- background:#99CCFF !important;
+
+background:rgba(204,204,204,0.2) !important;
}
.ant-tooltip-arrow::before{
- background:#99CCFF !important;
+
+background:rgba(204,204,204,0.2) !important;
}
.antsoancss{
color: #fff;
From 30a5d8bec51b09ecff2faa61a8461a2c82a0cb37 Mon Sep 17 00:00:00 2001
From: tangjiang <465264938@qq.com>
Date: Fri, 27 Dec 2019 20:16:47 +0800
Subject: [PATCH 5/9] update code not show
---
public/react/src/redux/actions/ojForm.js | 13 +++++++------
1 file changed, 7 insertions(+), 6 deletions(-)
diff --git a/public/react/src/redux/actions/ojForm.js b/public/react/src/redux/actions/ojForm.js
index 4e9173a3e..d15bdce39 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 : 2019-12-27 20:03:12
+ * @LastEditTime : 2019-12-27 20:13:01
*/
import types from './actionTypes';
import CONST from '../../constants';
@@ -287,11 +287,7 @@ export const validateOjForm = (props, type, cb) => {
cb && cb();
} else {
const {identifier} = res.data;
- // if (paramsObj['submitType'] === 'add' && identifier) {
- // dispatch(validateOjForm(props, 'update'));
- // props.history.push(`/problems/${identifier}/edit`);
- // return;
- // };
+
// message.success(paramsObj['submitType'] === 'update' ? '更新成功' : '保存成功');
notification.success({
message: '提示',
@@ -302,6 +298,11 @@ export const validateOjForm = (props, type, cb) => {
type: types.SAVE_OJ_FORM_ID,
payload: identifier
});
+ // 保存成功后,调用编辑接口并改变路
+ if (paramsObj['submitType'] === 'add' && identifier) {
+ dispatch(getOJFormById(identifier));
+ props.history.push(`/problems/${identifier}/edit`);
+ };
}
// 保存或更新后,调用start接口
// linkToDev(dispatch, props);
From 0a0bd8c8ce8429af2d7489af17c5cd4e4c69570c Mon Sep 17 00:00:00 2001
From: tangjiang <465264938@qq.com>
Date: Fri, 27 Dec 2019 20:24:05 +0800
Subject: [PATCH 6/9] change link to url
---
.../developer/studentStudy/leftpane/taskDescription/index.js | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/public/react/src/modules/developer/studentStudy/leftpane/taskDescription/index.js b/public/react/src/modules/developer/studentStudy/leftpane/taskDescription/index.js
index ebc42b9a4..348f68d27 100644
--- a/public/react/src/modules/developer/studentStudy/leftpane/taskDescription/index.js
+++ b/public/react/src/modules/developer/studentStudy/leftpane/taskDescription/index.js
@@ -4,7 +4,7 @@
* @Github:
* @Date: 2019-11-27 09:49:30
* @LastEditors : tangjiang
- * @LastEditTime : 2019-12-27 18:42:59
+ * @LastEditTime : 2019-12-27 20:22:55
*/
import '../index.scss';
import React from 'react';
@@ -37,7 +37,7 @@ const TaskDescription = (props) => {
出题者:
- {username}
+ {username}
From f1b19b20928584c60aa1c0764f5cda4e98b8734e Mon Sep 17 00:00:00 2001
From: jingquan huang
Date: Fri, 27 Dec 2019 20:26:11 +0800
Subject: [PATCH 7/9] add log
---
app/controllers/concerns/laboratory_helper.rb | 1 +
1 file changed, 1 insertion(+)
diff --git a/app/controllers/concerns/laboratory_helper.rb b/app/controllers/concerns/laboratory_helper.rb
index e03273d68..cd22dfe5d 100644
--- a/app/controllers/concerns/laboratory_helper.rb
+++ b/app/controllers/concerns/laboratory_helper.rb
@@ -11,6 +11,7 @@ module LaboratoryHelper
def current_laboratory
@_current_laboratory ||= (Laboratory.find_by_subdomain(request.subdomain) || Laboratory.find(1))
+ Rails.logger.info("current_laboratory is ######{@_current_laboratory}, domain is #{request.subdomains}")
end
def default_laboratory
From 14d05d10a6245025920a0769452e6e5d83856ee7 Mon Sep 17 00:00:00 2001
From: jingquan huang
Date: Fri, 27 Dec 2019 20:29:08 +0800
Subject: [PATCH 8/9] log
---
app/controllers/concerns/laboratory_helper.rb | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/app/controllers/concerns/laboratory_helper.rb b/app/controllers/concerns/laboratory_helper.rb
index cd22dfe5d..cc48581ac 100644
--- a/app/controllers/concerns/laboratory_helper.rb
+++ b/app/controllers/concerns/laboratory_helper.rb
@@ -11,7 +11,7 @@ module LaboratoryHelper
def current_laboratory
@_current_laboratory ||= (Laboratory.find_by_subdomain(request.subdomain) || Laboratory.find(1))
- Rails.logger.info("current_laboratory is ######{@_current_laboratory}, domain is #{request.subdomains}")
+ Rails.logger.info("current_laboratory is ######{@_current_laboratory.try(:identifier)}, domain is #{request.subdomain}")
end
def default_laboratory
From 896840cac384c82168f4e33fbd3a1e878a552dfb Mon Sep 17 00:00:00 2001
From: jingquan huang
Date: Fri, 27 Dec 2019 20:32:20 +0800
Subject: [PATCH 9/9] log
---
app/controllers/concerns/laboratory_helper.rb | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/app/controllers/concerns/laboratory_helper.rb b/app/controllers/concerns/laboratory_helper.rb
index cc48581ac..8044ce67c 100644
--- a/app/controllers/concerns/laboratory_helper.rb
+++ b/app/controllers/concerns/laboratory_helper.rb
@@ -11,7 +11,7 @@ module LaboratoryHelper
def current_laboratory
@_current_laboratory ||= (Laboratory.find_by_subdomain(request.subdomain) || Laboratory.find(1))
- Rails.logger.info("current_laboratory is ######{@_current_laboratory.try(:identifier)}, domain is #{request.subdomain}")
+ # Rails.logger.info("current_laboratory is ######{@_current_laboratory.try(:identifier)}, domain is #{request.subdomain}")
end
def default_laboratory