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] 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); }