From cab666e9a5b5ae38d5e653f4c112d8597c6107cc Mon Sep 17 00:00:00 2001 From: tangjiang <465264938@qq.com> Date: Fri, 13 Dec 2019 16:19:09 +0800 Subject: [PATCH 1/6] update --- .../components/myMonacoEditor/index.js | 4 ++-- .../modules/developer/studentStudy/index.js | 24 ++----------------- 2 files changed, 4 insertions(+), 24 deletions(-) diff --git a/public/react/src/modules/developer/components/myMonacoEditor/index.js b/public/react/src/modules/developer/components/myMonacoEditor/index.js index 85fee0efa..60f54ee0a 100644 --- a/public/react/src/modules/developer/components/myMonacoEditor/index.js +++ b/public/react/src/modules/developer/components/myMonacoEditor/index.js @@ -4,11 +4,11 @@ * @Github: * @Date: 2019-11-27 15:02:52 * @LastEditors: tangjiang - * @LastEditTime: 2019-12-10 09:20:42 + * @LastEditTime: 2019-12-13 16:16:56 */ import './index.scss'; import React, { useState, useRef, useEffect } from 'react'; -import { Icon, Drawer, Modal } from 'antd'; +import { Drawer, Modal } from 'antd'; import { fromStore } from 'educoder'; import { connect } from 'react-redux'; import MonacoEditor from '@monaco-editor/react'; diff --git a/public/react/src/modules/developer/studentStudy/index.js b/public/react/src/modules/developer/studentStudy/index.js index 923017ffa..89e18223e 100644 --- a/public/react/src/modules/developer/studentStudy/index.js +++ b/public/react/src/modules/developer/studentStudy/index.js @@ -4,7 +4,7 @@ * @Github: * @Date: 2019-11-23 10:53:19 * @LastEditors: tangjiang - * @LastEditTime: 2019-12-12 19:08:24 + * @LastEditTime: 2019-12-13 16:15:45 */ import './index.scss'; import React, { useEffect, useState } from 'react'; @@ -46,7 +46,6 @@ function StudentStudy (props) { }, []); useEffect(() => { - console.log('=======>>>>>>>>'); const { hack = {} } = props; if (!hack.modify_code && isUpdate) { // 代码更改,提示是否需要更新代码 setIsUpdate(false); @@ -61,30 +60,11 @@ function StudentStudy (props) { okText: '立即更新', cancelText: '稍后再说', onOk () { - console.log('更新代码....'); + } }); } }, [props]); - // useEffect(() => { - // const {hack} = props; - // if (!hack.modify_code) { // 代码更改,提示是否需要更新代码 - // Modal.confirm({ - // title: '提示', - // content: ( - //

- // 代码文件有更新啦
- // 还未提交的代码,请自行保存 - //

- // ), - // okText: '立即更新', - // cancelText: '稍后再说', - // onOk () { - // console.log('更新代码....'); - // } - // }); - // } - // }, [props]); const _hack_id = hack_identifier || fromStore('hack_identifier'); From b227563447e0de86d8f283b48bf51b59dabe19e7 Mon Sep 17 00:00:00 2001 From: tangjiang <465264938@qq.com> Date: Fri, 13 Dec 2019 16:57:15 +0800 Subject: [PATCH 2/6] update tip info --- .../modules/developer/studentStudy/index.js | 32 +++++++++++-------- .../developer/studentStudy/rightpane/index.js | 6 ++-- public/react/src/redux/actions/ojForUser.js | 13 +++++--- public/react/src/redux/actions/ojForm.js | 20 +++++++++--- 4 files changed, 47 insertions(+), 24 deletions(-) diff --git a/public/react/src/modules/developer/studentStudy/index.js b/public/react/src/modules/developer/studentStudy/index.js index 89e18223e..f6f21f8fe 100644 --- a/public/react/src/modules/developer/studentStudy/index.js +++ b/public/react/src/modules/developer/studentStudy/index.js @@ -4,7 +4,7 @@ * @Github: * @Date: 2019-11-23 10:53:19 * @LastEditors: tangjiang - * @LastEditTime: 2019-12-13 16:15:45 + * @LastEditTime: 2019-12-13 16:46:31 */ import './index.scss'; import React, { useEffect, useState } from 'react'; @@ -25,20 +25,23 @@ function StudentStudy (props) { const { userInfo, - hack_identifier + hack_identifier, + user_program_identifier, + restoreInitialCode } = props; // 是否更新 const [isUpdate, setIsUpdate] = useState(true); - useEffect(() => { - const { - match: { params }, - getUserProgramDetail, - saveUserProgramIdentifier - } = props; + const { + match: { params }, + getUserProgramDetail, + saveUserProgramIdentifier + } = props; - let { id } = params; + let { id } = params; + + useEffect(() => { // 保存当前的id saveUserProgramIdentifier(id); // startProgramQuestion(id); @@ -60,7 +63,7 @@ function StudentStudy (props) { okText: '立即更新', cancelText: '稍后再说', onOk () { - + restoreInitialCode(id, '更新成功'); } }); } @@ -126,11 +129,12 @@ function StudentStudy (props) { const mapStateToProps = (state) => { const { userInfo } = state.userReducer; - const { hack_identifier } = state.ojForUserReducer; + const { hack_identifier, user_program_identifier } = state.ojForUserReducer; return { userInfo, + user_program_identifier, hack_identifier - }; + }; }; const mapDispatchToProps = (dispatch) => ({ @@ -139,7 +143,9 @@ const mapDispatchToProps = (dispatch) => ({ // 调用编程题详情 getUserProgramDetail: (id) => dispatch(actions.getUserProgramDetail(id)), saveUserProgramIdentifier: (id) => dispatch(actions.saveUserProgramIdentifier(id)), - saveEditorCodeForDetail: (code) => dispatch(actions.saveEditorCodeForDetail(code)) + saveEditorCodeForDetail: (code) => dispatch(actions.saveEditorCodeForDetail(code)), + // 恢复初始代码 + restoreInitialCode: (identifier, msg) => dispatch(actions.restoreInitialCode(identifier, msg)), }); export default withRouter(connect( diff --git a/public/react/src/modules/developer/studentStudy/rightpane/index.js b/public/react/src/modules/developer/studentStudy/rightpane/index.js index 39d42f749..669a8a693 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-10 19:00:30 + * @LastEditTime: 2019-12-13 16:50:40 */ import React, { useState, useEffect } from 'react'; import {connect} from 'react-redux'; @@ -66,7 +66,7 @@ const RightPane = (props) => { } // 恢复初始代码 const handleRestoreInitialCode = () => { - restoreInitialCode(identifier); + restoreInitialCode(identifier, '恢复初始代码成功'); } return ( @@ -110,7 +110,7 @@ const mapDispatchToProps = (dispatch) => ({ // 保存用户代码至后台 saveUserCodeForInterval: (identifier, code) => dispatch(actions.saveUserCodeForInterval(identifier, code)), // 恢复初始代码 - restoreInitialCode: (identifier) => dispatch(actions.restoreInitialCode(identifier)), + restoreInitialCode: (identifier, msg) => dispatch(actions.restoreInitialCode(identifier, msg)), }); export default connect( diff --git a/public/react/src/redux/actions/ojForUser.js b/public/react/src/redux/actions/ojForUser.js index e3480a435..79e2045d6 100644 --- a/public/react/src/redux/actions/ojForUser.js +++ b/public/react/src/redux/actions/ojForUser.js @@ -4,7 +4,7 @@ * @Github: * @Date: 2019-11-27 13:42:11 * @LastEditors: tangjiang - * @LastEditTime: 2019-12-10 19:05:36 + * @LastEditTime: 2019-12-13 16:49:42 */ import types from "./actionTypes"; import { Base64 } from 'js-base64'; @@ -19,6 +19,7 @@ import { fetchUserCodeSubmit, fetchRestoreInitialCode } from "../../services/ojService"; +import { notification } from "antd"; // 进入编程页面时,首先调用开启编程题接口 export const startProgramQuestion = (id, props) => { @@ -384,17 +385,21 @@ export const submitUserCode = (identifier, inputValue, type) => { } // 恢复初始代码 -export const restoreInitialCode = (identifier) => { +export const restoreInitialCode = (identifier, msg) => { return (dispatch) => { 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 - }) + }); + notification.success({ + message: '提示', + description: msg + }); } }); } diff --git a/public/react/src/redux/actions/ojForm.js b/public/react/src/redux/actions/ojForm.js index b7fbd6e80..3eaac9023 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-13 10:46:15 + * @LastEditTime: 2019-12-13 16:56:22 */ import types from './actionTypes'; import CONST from '../../constants'; @@ -251,7 +251,11 @@ export const validateOjForm = (props, type) => { // 提示发布信息 publishTask(identifier).then(res => { if (res.data.status === 0) { - message.success('发布成功!'); + // message.success('发布成功!'); + notification.success({ + message: '提示', + description: '发布成功!' + }); linkToDev(dispatch, props); } dispatch({ @@ -269,7 +273,11 @@ export const validateOjForm = (props, type) => { fetchPostOjForm(paramsObj).then(res => { if (res.status === 200) { // 保存成功后,重新跳转至列表页 if (res.data.status === 0) { - message.success(paramsObj['submitType'] === 'update' ? '更新成功' : '保存成功'); + // message.success(paramsObj['submitType'] === 'update' ? '更新成功' : '保存成功'); + notification.success({ + message: '提示', + description: paramsObj['submitType'] === 'update' ? '更新成功' : '保存成功' + }); linkToDev(dispatch, props); } dispatch({ @@ -299,7 +307,11 @@ export const handleClickCancelPublish = (props, identifier) => { if (res.status = 200) { const { data} = res; if (data.status === 0) { - message.success('撤销发布成功!'); + // message.success('撤销发布成功!'); + notification.success({ + message: '提示', + description: '撤销发布成功!' + }); linkToDev(dispatch, props); } } From b740dddc9cdc048a56e1ab9458186a2893fd9fed Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Fri, 13 Dec 2019 17:03:07 +0800 Subject: [PATCH 3/6] 1 --- app/controllers/hack_user_lastest_codes_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/hack_user_lastest_codes_controller.rb b/app/controllers/hack_user_lastest_codes_controller.rb index b7ec6fb8e..814d16d51 100644 --- a/app/controllers/hack_user_lastest_codes_controller.rb +++ b/app/controllers/hack_user_lastest_codes_controller.rb @@ -23,7 +23,7 @@ class HackUserLastestCodesController < ApplicationController # 同步代码 def sync_code - @my_hack.update_attributes(code: @hack.code, modify_time: @hack.modify_time) + @my_hack.update_attributes(code: @hack.code, modify_time: Time.now) end # 调试代码 From 87e74dc839a48f414a930188ce7709682993b173 Mon Sep 17 00:00:00 2001 From: tangjiang <465264938@qq.com> Date: Fri, 13 Dec 2019 17:20:07 +0800 Subject: [PATCH 4/6] restore code --- .../modules/developer/studentStudy/index.js | 20 +++++++++---------- public/react/src/services/ojService.js | 13 ++++++------ 2 files changed, 17 insertions(+), 16 deletions(-) diff --git a/public/react/src/modules/developer/studentStudy/index.js b/public/react/src/modules/developer/studentStudy/index.js index f6f21f8fe..e4b296a20 100644 --- a/public/react/src/modules/developer/studentStudy/index.js +++ b/public/react/src/modules/developer/studentStudy/index.js @@ -4,7 +4,7 @@ * @Github: * @Date: 2019-11-23 10:53:19 * @LastEditors: tangjiang - * @LastEditTime: 2019-12-13 16:46:31 + * @LastEditTime: 2019-12-13 17:19:15 */ import './index.scss'; import React, { useEffect, useState } from 'react'; @@ -23,15 +23,14 @@ import { withRouter } from 'react-router'; function StudentStudy (props) { + const [hasUpdate, setHasUpdate] = useState(true); const { + // hack, userInfo, hack_identifier, - user_program_identifier, + // user_program_identifier, restoreInitialCode } = props; - - // 是否更新 - const [isUpdate, setIsUpdate] = useState(true); const { match: { params }, @@ -50,8 +49,8 @@ function StudentStudy (props) { useEffect(() => { const { hack = {} } = props; - if (!hack.modify_code && isUpdate) { // 代码更改,提示是否需要更新代码 - setIsUpdate(false); + if (hack.modify_code && hasUpdate) { // 代码更改,提示是否需要更新代码 + setHasUpdate(false); Modal.confirm({ title: '提示', content: ( @@ -67,7 +66,7 @@ function StudentStudy (props) { } }); } - }, [props]); + }, [props, hasUpdate, setHasUpdate]); const _hack_id = hack_identifier || fromStore('hack_identifier'); @@ -93,7 +92,7 @@ function StudentStudy (props) { */}
- 乘积最大序列 + 乘积最大序列 {hasUpdate}
{/* to={`/problems/${_hack_id}/edit`} */} @@ -129,8 +128,9 @@ function StudentStudy (props) { const mapStateToProps = (state) => { const { userInfo } = state.userReducer; - const { hack_identifier, user_program_identifier } = state.ojForUserReducer; + const { hack_identifier, user_program_identifier, hack } = state.ojForUserReducer; return { + hack, userInfo, user_program_identifier, hack_identifier diff --git a/public/react/src/services/ojService.js b/public/react/src/services/ojService.js index 9700f7031..e13b66397 100644 --- a/public/react/src/services/ojService.js +++ b/public/react/src/services/ojService.js @@ -4,7 +4,7 @@ * @Github: * @Date: 2019-11-20 10:55:38 * @LastEditors: tangjiang - * @LastEditTime: 2019-12-13 10:09:12 + * @LastEditTime: 2019-12-13 17:03:47 */ import axios from 'axios'; @@ -84,10 +84,10 @@ export async function fetchUserCommitRecordDetail (identifier) { } // 恢复初始代码 -export async function restoreInitialCode (identifier) { - const url = `/myproblems/${identifier}/restore_initial_code.json`; - return axios.get(url); -} +// export async function restoreInitialCode (identifier) { +// const url = `/myproblems/${identifier}/restore_initial_code.json`; +// return axios.get(url); +// } // 发布任务 export async function publishTask (identifier) { @@ -115,7 +115,8 @@ export async function fetchUserCodeSubmit (identifier) { // 恢复初始代码 export async function fetchRestoreInitialCode (identifier) { - const url = `/myproblems/${identifier}/restore_initial_code.json`; + // const url = `/myproblems/${identifier}/restore_initial_code.json`; + const url = `/myproblems/${identifier}/sync_code.json`; return axios.post(url); } From 42d4207f05ab3991b8e77008153f59a4a7b0fd37 Mon Sep 17 00:00:00 2001 From: tangjiang <465264938@qq.com> Date: Fri, 13 Dec 2019 17:42:00 +0800 Subject: [PATCH 5/6] update style --- .../modules/developer/components/controlSetting/index.js | 4 ++-- .../modules/developer/components/controlSetting/index.scss | 4 +++- .../src/modules/developer/components/initTabCtx/index.js | 3 ++- .../src/modules/developer/components/initTabCtx/index.scss | 7 +++++++ .../modules/developer/components/myMonacoEditor/index.scss | 4 +++- 5 files changed, 17 insertions(+), 5 deletions(-) diff --git a/public/react/src/modules/developer/components/controlSetting/index.js b/public/react/src/modules/developer/components/controlSetting/index.js index 690bbad36..587e1bee9 100644 --- a/public/react/src/modules/developer/components/controlSetting/index.js +++ b/public/react/src/modules/developer/components/controlSetting/index.js @@ -4,7 +4,7 @@ * @Github: * @Date: 2019-11-27 16:02:36 * @LastEditors: tangjiang - * @LastEditTime: 2019-12-10 09:30:27 + * @LastEditTime: 2019-12-13 17:32:33 */ import './index.scss'; import React, { useState, useRef } from 'react'; @@ -84,7 +84,7 @@ const ControlSetting = (props) => { diff --git a/public/react/src/modules/developer/components/controlSetting/index.scss b/public/react/src/modules/developer/components/controlSetting/index.scss index 4a2c221c1..97838ce5c 100644 --- a/public/react/src/modules/developer/components/controlSetting/index.scss +++ b/public/react/src/modules/developer/components/controlSetting/index.scss @@ -2,6 +2,7 @@ position: absolute; bottom: 0; width: 100%; + background:rgba(30,30,30,1); // height: 56px; .control_tab{ position: absolute; @@ -51,7 +52,8 @@ height: 56px; padding-right: 30px; padding-left: 10px; - background: #000; + // background: #000; + background:rgba(48,48,48,1); } .setting_drawer{ diff --git a/public/react/src/modules/developer/components/initTabCtx/index.js b/public/react/src/modules/developer/components/initTabCtx/index.js index 19f4230b1..3834a3e11 100644 --- a/public/react/src/modules/developer/components/initTabCtx/index.js +++ b/public/react/src/modules/developer/components/initTabCtx/index.js @@ -4,7 +4,7 @@ * @Github: * @Date: 2019-11-27 19:46:14 * @LastEditors: tangjiang - * @LastEditTime: 2019-12-10 09:31:00 + * @LastEditTime: 2019-12-13 17:38:42 */ import './index.scss'; import React, { useState, useEffect, useRef, useImperativeHandle, forwardRef } from 'react'; @@ -50,6 +50,7 @@ function InitTabCtx (props, ref) { ], initialValue: inputValue })(