update tip info

chromesetting
tangjiang 5 years ago
parent cab666e9a5
commit b227563447

@ -4,7 +4,7 @@
* @Github: * @Github:
* @Date: 2019-11-23 10:53:19 * @Date: 2019-11-23 10:53:19
* @LastEditors: tangjiang * @LastEditors: tangjiang
* @LastEditTime: 2019-12-13 16:15:45 * @LastEditTime: 2019-12-13 16:46:31
*/ */
import './index.scss'; import './index.scss';
import React, { useEffect, useState } from 'react'; import React, { useEffect, useState } from 'react';
@ -25,13 +25,14 @@ function StudentStudy (props) {
const { const {
userInfo, userInfo,
hack_identifier hack_identifier,
user_program_identifier,
restoreInitialCode
} = props; } = props;
// 是否更新 // 是否更新
const [isUpdate, setIsUpdate] = useState(true); const [isUpdate, setIsUpdate] = useState(true);
useEffect(() => {
const { const {
match: { params }, match: { params },
getUserProgramDetail, getUserProgramDetail,
@ -39,6 +40,8 @@ function StudentStudy (props) {
} = props; } = props;
let { id } = params; let { id } = params;
useEffect(() => {
// 保存当前的id // 保存当前的id
saveUserProgramIdentifier(id); saveUserProgramIdentifier(id);
// startProgramQuestion(id); // startProgramQuestion(id);
@ -60,7 +63,7 @@ function StudentStudy (props) {
okText: '立即更新', okText: '立即更新',
cancelText: '稍后再说', cancelText: '稍后再说',
onOk () { onOk () {
restoreInitialCode(id, '更新成功');
} }
}); });
} }
@ -126,9 +129,10 @@ function StudentStudy (props) {
const mapStateToProps = (state) => { const mapStateToProps = (state) => {
const { userInfo } = state.userReducer; const { userInfo } = state.userReducer;
const { hack_identifier } = state.ojForUserReducer; const { hack_identifier, user_program_identifier } = state.ojForUserReducer;
return { return {
userInfo, userInfo,
user_program_identifier,
hack_identifier hack_identifier
}; };
}; };
@ -139,7 +143,9 @@ const mapDispatchToProps = (dispatch) => ({
// 调用编程题详情 // 调用编程题详情
getUserProgramDetail: (id) => dispatch(actions.getUserProgramDetail(id)), getUserProgramDetail: (id) => dispatch(actions.getUserProgramDetail(id)),
saveUserProgramIdentifier: (id) => dispatch(actions.saveUserProgramIdentifier(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( export default withRouter(connect(

@ -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-10 19:00:30 * @LastEditTime: 2019-12-13 16:50:40
*/ */
import React, { useState, useEffect } from 'react'; import React, { useState, useEffect } from 'react';
import {connect} from 'react-redux'; import {connect} from 'react-redux';
@ -66,7 +66,7 @@ const RightPane = (props) => {
} }
// 恢复初始代码 // 恢复初始代码
const handleRestoreInitialCode = () => { const handleRestoreInitialCode = () => {
restoreInitialCode(identifier); restoreInitialCode(identifier, '恢复初始代码成功');
} }
return ( return (
@ -110,7 +110,7 @@ const mapDispatchToProps = (dispatch) => ({
// 保存用户代码至后台 // 保存用户代码至后台
saveUserCodeForInterval: (identifier, code) => dispatch(actions.saveUserCodeForInterval(identifier, code)), 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( export default connect(

@ -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-10 19:05:36 * @LastEditTime: 2019-12-13 16:49:42
*/ */
import types from "./actionTypes"; import types from "./actionTypes";
import { Base64 } from 'js-base64'; import { Base64 } from 'js-base64';
@ -19,6 +19,7 @@ import {
fetchUserCodeSubmit, fetchUserCodeSubmit,
fetchRestoreInitialCode fetchRestoreInitialCode
} from "../../services/ojService"; } from "../../services/ojService";
import { notification } from "antd";
// 进入编程页面时,首先调用开启编程题接口 // 进入编程页面时,首先调用开启编程题接口
export const startProgramQuestion = (id, props) => { 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) => { return (dispatch) => {
fetchRestoreInitialCode(identifier).then(res => { fetchRestoreInitialCode(identifier).then(res => {
if (res.data.status === 401) return; if (res.data.status === 401) return;
console.log('恢复初始代码====》》》》', res); // console.log('恢复初始代码====》》》》', res);
const {status, data} = res; const {status, data} = res;
if (status === 200) { if (status === 200) {
dispatch({ dispatch({
type: types.RESTORE_INITIAL_CODE, type: types.RESTORE_INITIAL_CODE,
payload: data.code payload: data.code
}) });
notification.success({
message: '提示',
description: msg
});
} }
}); });
} }

@ -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-13 10:46:15 * @LastEditTime: 2019-12-13 16:56:22
*/ */
import types from './actionTypes'; import types from './actionTypes';
import CONST from '../../constants'; import CONST from '../../constants';
@ -251,7 +251,11 @@ export const validateOjForm = (props, type) => {
// 提示发布信息 // 提示发布信息
publishTask(identifier).then(res => { publishTask(identifier).then(res => {
if (res.data.status === 0) { if (res.data.status === 0) {
message.success('发布成功!'); // message.success('发布成功!');
notification.success({
message: '提示',
description: '发布成功!'
});
linkToDev(dispatch, props); linkToDev(dispatch, props);
} }
dispatch({ dispatch({
@ -269,7 +273,11 @@ export const validateOjForm = (props, type) => {
fetchPostOjForm(paramsObj).then(res => { fetchPostOjForm(paramsObj).then(res => {
if (res.status === 200) { // 保存成功后,重新跳转至列表页 if (res.status === 200) { // 保存成功后,重新跳转至列表页
if (res.data.status === 0) { 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); linkToDev(dispatch, props);
} }
dispatch({ dispatch({
@ -299,7 +307,11 @@ export const handleClickCancelPublish = (props, identifier) => {
if (res.status = 200) { if (res.status = 200) {
const { data} = res; const { data} = res;
if (data.status === 0) { if (data.status === 0) {
message.success('撤销发布成功!'); // message.success('撤销发布成功!');
notification.success({
message: '提示',
description: '撤销发布成功!'
});
linkToDev(dispatch, props); linkToDev(dispatch, props);
} }
} }

Loading…
Cancel
Save