列表页添加权限

dev_forge
tangjiang 5 years ago
parent 1130b010c1
commit 6b4fbb60d5

@ -311,6 +311,11 @@ const StudentStudy = Loadable({
loader: () => import('./modules/developer/studentStudy'), loader: () => import('./modules/developer/studentStudy'),
loading: Loading loading: Loading
}); });
// 提交记录详情
const RecordDetail = Loadable({
loader: () => import('./modules/developer/recordDetail'),
loading: Loading
});
// //个人竞赛报名 // //个人竞赛报名
// const PersonalCompetit = Loadable({ // const PersonalCompetit = Loadable({
// loader: () => import('./modules/competition/personal/PersonalCompetit.js'), // loader: () => import('./modules/competition/personal/PersonalCompetit.js'),
@ -666,17 +671,33 @@ class App extends Component {
(props)=>(<Ecs {...this.props} {...props} {...this.state}></Ecs>) (props)=>(<Ecs {...this.props} {...props} {...this.state}></Ecs>)
}/> }/>
<Route path="/problems/new/:id?" component={NewOrEditTask} /> <Route path="/problems/new/:id?" component={NewOrEditTask}
// render={
// (props) => {
// debugger;
// console.log(this.props, props, this.state);
// return (<NewOrEditTask {...this.props} {...props} {...this.state} />)
// }
// }
/>
<Route <Route
path="/problems/:id/edit" path="/problems/:id/edit"
render={ render={
(props) => (<NewOrEditTask {...props} />) (props) => (<NewOrEditTask {...this.props} {...props} {...this.state} />)
} /> } />
<Route path="/myproblems/record_detail/:id"
render={
(props) => (<RecordDetail {...this.props} {...props} {...this.state} />)
}
/>
<Route path="/myproblems/:id" <Route path="/myproblems/:id"
render={ render={
(props) => (<StudentStudy {...this.props} {...props} {...this.state} />) (props) => (<StudentStudy {...this.props} {...props} {...this.state} />)
} /> } />
<Route path="/problems" component={Developer}/> <Route path="/problems"
render={
(props) => (<Developer {...this.props} {...props} {...this.state} />)
}/>
<Route exact path="/" <Route exact path="/"
// component={ShixunsHome} // component={ShixunsHome}

@ -108,8 +108,8 @@ class DeveloperHome extends React.PureComponent {
width: 100, width: 100,
render: (text, record) => ( render: (text, record) => (
<span> <span>
<Button type="primary"> <Button type="primary" onClick={() => this.handleClickEditor(record.identifier)}>编辑
<Link to={`/problems/${record.identifier}/edit`}>编辑</Link> {/* <Link to={`/problems/${record.identifier}/edit`}></Link> */}
</Button> </Button>
</span> </span>
), ),
@ -179,6 +179,7 @@ class DeveloperHome extends React.PureComponent {
componentDidMount() { componentDidMount() {
// 是否是我的,如果是我的 显示编辑按钮 // 是否是我的,如果是我的 显示编辑按钮
const { isMySource } = this.props; const { isMySource } = this.props;
if (isMySource) { if (isMySource) {
this.handleFilterSearch({come_from: 'mine'}); this.handleFilterSearch({come_from: 'mine'});
let _columns = this.columns.concat([this.options]); let _columns = this.columns.concat([this.options]);
@ -197,6 +198,31 @@ class DeveloperHome extends React.PureComponent {
}); });
} }
// 是否登录
isLogin = (url) => {
if(this.props.checkIfLogin()===false){
this.props.showLoginDialog()
return false;
}
return true;
}
// 新建
handleClickNew = () => {
if (this.isLogin()) {
// this.props.history.push('/problems/new');
window.location.href = '/problems/new'
}
// window.location.href = '/problems/new';
}
// 编辑
handleClickEditor = (identifier) => {
if (this.isLogin()) {
this.props.history.push(`/problems/${identifier}/edit`)
}
}
// table条件变化时
handleTableChange = (pagination, filters, sorter) => { handleTableChange = (pagination, filters, sorter) => {
const {field, order} = sorter; const {field, order} = sorter;
const {current, pageSize} = pagination; const {current, pageSize} = pagination;
@ -208,7 +234,7 @@ class DeveloperHome extends React.PureComponent {
}); });
this.props.changePaginationInfo(pagination); this.props.changePaginationInfo(pagination);
}; };
// 获取接口数据
fetchData = () => { fetchData = () => {
this.props.fetchOJList(this.state.searchParams); this.props.fetchOJList(this.state.searchParams);
}; };
@ -245,7 +271,9 @@ class DeveloperHome extends React.PureComponent {
this.setState({ this.setState({
searchParams: searchParams searchParams: searchParams
}, () => { }, () => {
this.fetchData(); if (this.isLogin()) {
this.fetchData();
}
}); });
} }
@ -343,10 +371,16 @@ class DeveloperHome extends React.PureComponent {
// 点击name // 点击name
handleNameClick = (record) => { handleNameClick = (record) => {
console.log('name has click', record); // console.log('name has click', record);
// 先调用start接口获取返回的 identifier, 再跳转到开启编辑 // 先调用start接口获取返回的 identifier, 再跳转到开启编辑
this.props.startProgramQuestion(record.identifier, this.props); if (this.isLogin()) {
this.props.startProgramQuestion(record.identifier, this.props);
}
} }
// if(this.props.checkIfLogin()===false){
// this.props.showLoginDialog()
// return
// }
render () { render () {
// const { testReducer, handleClick } = this.props; // const { testReducer, handleClick } = this.props;
@ -388,8 +422,8 @@ class DeveloperHome extends React.PureComponent {
<MultipTags type="warning" text="中等" numb={medium_count} style={{ marginRight: '20px' }}/> <MultipTags type="warning" text="中等" numb={medium_count} style={{ marginRight: '20px' }}/>
<MultipTags type="error" text="困难" numb={diff_count}/> <MultipTags type="error" text="困难" numb={diff_count}/>
</div> </div>
<Button type="primary"> <Button type="primary" onClick={this.handleClickNew}>新建
<Link to="/problems/new">新建</Link> {/* <Link to="/problems/new">新建</Link> */}
</Button> </Button>
</div> </div>
</div> </div>

@ -4,7 +4,7 @@
* @Github: * @Github:
* @Date: 2019-11-25 17:50:33 * @Date: 2019-11-25 17:50:33
* @LastEditors: tangjiang * @LastEditors: tangjiang
* @LastEditTime: 2019-11-27 14:40:36 * @LastEditTime: 2019-12-04 11:26:02
*/ */
import React from 'react'; import React from 'react';
import { Select } from 'antd'; import { Select } from 'antd';
@ -18,9 +18,10 @@ const SettingDrawer = (props) => {
*/ */
const {title, type = 'label', content = [] } = props; const {title, type = 'label', content = [] } = props;
const handleFontSize = (value) => { const handleFontSize = (e) => {
const {onChangeFontSize} = props; const {onChangeFontSize} = props;
// console.log('fong size change: ', value); const value = e.target.value;
console.log('fong size change: ', value);
onChangeFontSize && onChangeFontSize(value); onChangeFontSize && onChangeFontSize(value);
} }
@ -39,16 +40,16 @@ const SettingDrawer = (props) => {
} else if (Array.isArray(value)) { } else if (Array.isArray(value)) {
if (type === 'select') { if (type === 'select') {
const child = ctx.value.map((opt, i) => ( const child = ctx.value.map((opt, i) => (
<Option key={opt.key || `${opt.value}`} value={opt.value}> <option key={`key_${i}` || `${opt.value}`} value={opt.value}>
{opt.text} {opt.text}
</Option> </option>
)); ));
renderResult = ( renderResult = (
<div className={'setting_desc'} key={`sel_${index}`}> <div className={'setting_desc'} key={`sel_${index}`}>
<span className={'flex_item'}>{ctx.text}</span> <span className={'flex_item'}>{ctx.text}</span>
<Select className={'flex_item'} style={{ width: '100px'}} onChange={handleFontSize}> <select style={{ width: '100px'}} onChange={handleFontSize}>
{child} {child}
</Select> </select>
</div> </div>
); );
} }

@ -4,11 +4,11 @@
* @Github: * @Github:
* @Date: 2019-11-27 15:02:52 * @Date: 2019-11-27 15:02:52
* @LastEditors: tangjiang * @LastEditors: tangjiang
* @LastEditTime: 2019-12-03 09:29:54 * @LastEditTime: 2019-12-04 11:36:16
*/ */
import './index.scss'; import './index.scss';
import React, { useState, useRef, useEffect } from 'react'; import React, { useState, useRef, useEffect } from 'react';
import { Icon, Drawer } from 'antd'; import { Icon, Drawer, Modal } from 'antd';
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import MonacoEditor from '@monaco-editor/react'; import MonacoEditor from '@monaco-editor/react';
import SettingDrawer from '../../components/monacoSetting'; import SettingDrawer from '../../components/monacoSetting';
@ -22,9 +22,11 @@ function MyMonacoEditor (props, ref) {
const { const {
language, language,
code, code,
identifier,
showOrHideControl, showOrHideControl,
// saveUserInputCode, // saveUserInputCode,
onCodeChange onCodeChange,
onRestoreInitialCode
} = props; } = props;
const [showDrawer, setShowDrawer] = useState(false); // 控制配置滑框 const [showDrawer, setShowDrawer] = useState(false); // 控制配置滑框
const [editCode, setEditCode] = useState(''); const [editCode, setEditCode] = useState('');
@ -77,11 +79,25 @@ function MyMonacoEditor (props, ref) {
fontSize: `${fontSize}px` fontSize: `${fontSize}px`
} }
// 恢复初始代码
const handleRestoreCode = () => {
console.log('点击了恢复初始代码');
Modal.confirm({
content: '确定要恢复代码吗?',
okText: '确定',
cancelText: '取消',
onOk () {
onRestoreInitialCode && onRestoreInitialCode();
}
})
}
return ( return (
<React.Fragment> <React.Fragment>
<div className={"monaco_editor_area"}> <div className={"monaco_editor_area"}>
<div className="code_title"> <div className="code_title">
<span>已保存</span> <span className='flex_strict'>{identifier ? '已保存' : ''}</span>
<span onClick={handleRestoreCode} className="flex_normal">{identifier ? '恢复初始代码' : ''}</span>
<Icon className={'code-icon'} type="setting" onClick={handleShowDrawer}/> <Icon className={'code-icon'} type="setting" onClick={handleShowDrawer}/>
</div> </div>
<MonacoEditor <MonacoEditor

@ -3,11 +3,19 @@
.code_title{ .code_title{
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: space-between; // justify-content: space-between;
background: #000; background: #000;
color: #fff; color: #fff;
height: 56px; height: 56px;
padding: 0 30px; padding: 0 30px;
.flex_strict{
flex: 1;
}
.flex_normal{
color: #E51C24;
cursor: pointer;
margin-right: 30px;
}
.code-icon{ .code-icon{
cursor: pointer; cursor: pointer;
} }

@ -9,9 +9,9 @@ import React from 'react';
import { TPMIndexHOC } from '../tpm/TPMIndexHOC'; import { TPMIndexHOC } from '../tpm/TPMIndexHOC';
import DeveloperHome from './DeveloperHome'; import DeveloperHome from './DeveloperHome';
const App = () => { const App = (props) => {
return ( return (
<DeveloperHome /> <DeveloperHome {...props}/>
); );
} }

@ -6,10 +6,10 @@
* @Last Modified time: 2019-11-19 23:23:41 * @Last Modified time: 2019-11-19 23:23:41
*/ */
import './index.scss'; import './index.scss';
import React, { useState, useEffect, useRef } from 'react'; import React, { useEffect } from 'react';
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import SplitPane from 'react-split-pane';// import { Form } from 'antd'; import SplitPane from 'react-split-pane';// import { Form } from 'antd';
import { Button, Icon, notification } from 'antd'; import { Button, Icon } from 'antd';
import { Link } from 'react-router-dom'; import { Link } from 'react-router-dom';
import LeftPane from './leftpane'; import LeftPane from './leftpane';
import RightPane from './rightpane'; import RightPane from './rightpane';
@ -20,18 +20,19 @@ const NewOrEditTask = (props) => {
const { const {
publishLoading, publishLoading,
handlePublish, handlePublish,
testCases = [], // testCases = [],
// ojTestCaseValidate = [], // ojTestCaseValidate = [],
changeSubmitLoadingStatus, // changeSubmitLoadingStatus,
changePublishLoadingStatus, changePublishLoadingStatus,
updateTestAndValidate, // updateTestAndValidate,
identifier, identifier,
} = props; } = props;
const leftRef = useRef(null); // console.log('props =====>>>>', props);
const rightRef = useRef(null); // const leftRef = useRef(null);
// const rightRef = useRef(null);
const [formDate, setFormData] = useState({}); // const [formDate, setFormData] = useState({});
// const isNullOrUndefiendOrZero = (value) => { // const isNullOrUndefiendOrZero = (value) => {
// if ([undefined, null, ''].includes(value)) { // if ([undefined, null, ''].includes(value)) {

@ -0,0 +1,112 @@
/*
* @Description: 提交记录详情
* @Author: tangjiang
* @Github:
* @Date: 2019-12-04 08:36:21
* @LastEditors: tangjiang
* @LastEditTime: 2019-12-04 10:36:06
*/
import './index.scss';
import React, { useState, useEffect } from 'react';
import { Button } from 'antd';
import moment from 'moment';
import ErrorResult from '../components/errorResult';
import { Link } from 'react-router-dom';
import MonacoEditor from '@monaco-editor/react';
import { connect } from 'react-redux';
import { getImageUrl } from 'educoder';
import actions from '../../../redux/actions';
import CONST from '../../../constants';
const {reviewResult} = CONST;
function RecordDetail (props) {
const {
match: { params },
mygetHelmetapi = {},
recordDetail,
getUserCommitRecordDetail
} = props;
const identifier = params.id;
const [detail, setDetail] = useState({});
useEffect(() => {
// 根据id获取记录详情
getUserCommitRecordDetail(identifier, 'detail');
}, []);
useEffect(() => {
setDetail(recordDetail);
}, [recordDetail]);
return (
<div className="record_detail_area">
<div className="record_detail_header">
<div className="avator_nicker">
<img alt="用户头像" className={'student_img'} src={getImageUrl((mygetHelmetapi && mygetHelmetapi.nav_logo_url) || 'images/educoder/headNavLogo.png?1526520218')} />
<span className={'student_nicker'}>
{(mygetHelmetapi &&mygetHelmetapi.name) || ''}
</span>
</div>
<div className={'study_name'}>
<span>{detail.name || 'test'}</span>
</div>
<div className={'study_quit'}>
<Button>
<Link to="/myproblems">返回该题</Link>
</Button>
</div>
</div>
<div className="record_detail_ctx">
<div className="detail_ctx_header">
<h2 className="header_h2">提交记录</h2>
</div>
<div className="detail_ctx_status">
<span className="status_label">
状态: <span className="status_label_error">{reviewResult[detail.status]}</span>
</span>
<span className="status_label">
提交时间: <span className="status_label_sub">
{/* moment(detail.) */}
</span>
</span>
<span className="status_label">
语言: <span className="status_label_sub">C</span>
</span>
</div>
<div className="result_error_area">
<ErrorResult detail={detail}/>
</div>
<div className="detail_ctx_header">
<h2 className="header_h2">提交内容</h2>
<Button className={'header_btn'} type="primary">编辑代码</Button>
</div>
<div className="result_code_area">
<MonacoEditor
height="100%"
width="100%"
language={'c'}
value={'// init code'}
theme="dark"
/>
</div>
</div>
</div>
)
}
const mapStateToProps = (state) => {
const {recordDetail} = state.ojForUserReducer;
return {
recordDetail
}
}
const mapDispatchToProps = (dispatch) => ({
// 根据id号获取记录详情
getUserCommitRecordDetail: (id, type) => dispatch(actions.getUserCommitRecordDetail(id, type))
});
export default connect(
mapStateToProps,
mapDispatchToProps
)(RecordDetail);

@ -0,0 +1,39 @@
@import '../split_pane_resizer.scss';
.record_detail_area{
.record_detail_ctx{
padding: 0 30px;
.detail_ctx_header{
position: relative;
height: 56px;
}
.header_h2{
line-height: 56px;
}
.header_btn{
position: absolute;
right: 0;
top: 14px;
}
.detail_ctx_status{
line-height: 18px;
.status_label{
color: rgba(153,153,153,1);
margin-right: 40px;
}
.status_label_error{
color: #E51C24;
}
.status_label_success{
color: #28BD8B;
}
.status_label_sub{
color: #333333;
}
}
.result_code_area{
height: 500px;
}
}
}

@ -1,9 +1,11 @@
.new_add_task_wrap, .new_add_task_wrap,
.student_study_warp{ .student_study_warp,
.record_detail_area{
height: 100vh; height: 100vh;
.task_header, .task_header,
.student_study_header{ .student_study_header,
.record_detail_header{
height: 65px; height: 65px;
background:rgba(34,34,34,1); background:rgba(34,34,34,1);
padding:0 30px; padding:0 30px;
@ -50,7 +52,8 @@
} }
} }
.student_study_header{ .student_study_header,
.record_detail_header{
position: relative; position: relative;
.avator_nicker, .avator_nicker,
.study_quit, .study_quit,

@ -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-03 14:49:32 * @LastEditTime: 2019-12-04 14:02:05
*/ */
import './index.scss'; import './index.scss';
import React, { useEffect } from 'react'; import React, { useEffect } from 'react';
@ -30,6 +30,7 @@ const StudentStudy = (props) => {
saveUserProgramIdentifier, saveUserProgramIdentifier,
} = props; } = props;
console.log(props); console.log(props);
let { id } = params; let { id } = params;
// console.log(id); // console.log(id);
@ -57,7 +58,7 @@ const StudentStudy = (props) => {
</div> </div>
</div> </div>
<div className="split-pane-area"> <div className="split-pane-area">
<SplitPane split="vertical" minSize={200} maxSize={-200} defaultSize="50%"> <SplitPane split="vertical" minSize={350} maxSize={-350} defaultSize="50%">
<div className={'split-pane-left'}> <div className={'split-pane-left'}>
<LeftPane /> <LeftPane />
</div> </div>

@ -4,12 +4,13 @@
* @Github: * @Github:
* @Date: 2019-11-27 09:49:33 * @Date: 2019-11-27 09:49:33
* @LastEditors: tangjiang * @LastEditors: tangjiang
* @LastEditTime: 2019-12-03 20:47:59 * @LastEditTime: 2019-12-04 10:37:33
*/ */
import './index.scss'; import './index.scss';
import React, { useState, useEffect } from 'react'; import React, { useState, useEffect } from 'react';
import { Table, Icon, message } from 'antd'; import { Table, Icon, message } from 'antd';
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import { Link } from 'react-router-dom';
import actions from '../../../../../redux/actions'; import actions from '../../../../../redux/actions';
import CONST from '../../../../../constants'; import CONST from '../../../../../constants';
import moment from 'moment'; import moment from 'moment';
@ -109,7 +110,9 @@ const CommitRecord = (props) => {
</span> </span>
</p> </p>
<p className={'show_detail'}> <p className={'show_detail'}>
显示详情 <Icon type="right" className={'icon_style'}/> <Link to={`/myproblems/record_detail/${identifier}`}>
显示详情 <Icon type="right" className={'icon_style'}/>
</Link>
</p> </p>
</div> </div>
<div id="errcode" className={showErrorCode}> <div id="errcode" className={showErrorCode}>

@ -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-03 09:31:59 * @LastEditTime: 2019-12-04 10:57:49
*/ */
import React from 'react'; import React from 'react';
import {connect} from 'react-redux'; import {connect} from 'react-redux';
@ -20,7 +20,8 @@ const RightPane = (props) => {
submitUserCode, submitUserCode,
input, input,
updateCode, updateCode,
saveUserInputCode saveUserInputCode,
restoreInitialCode
} = props; } = props;
const handleSubmitForm = () => { const handleSubmitForm = () => {
@ -33,7 +34,7 @@ const RightPane = (props) => {
// 代码块内容变化时 // 代码块内容变化时
const handleCodeChange = (code) => { const handleCodeChange = (code) => {
// 保存用户提交的代码块 // 保存用户提交的代码块
console.log(code); // console.log(code);
// 保存用户代码块 // 保存用户代码块
saveUserInputCode(code); saveUserInputCode(code);
} }
@ -42,13 +43,19 @@ const RightPane = (props) => {
// 调用保存代码块接口,成功后,调用调试接口 // 调用保存代码块接口,成功后,调用调试接口
updateCode(identifier, value, 'debug'); updateCode(identifier, value, 'debug');
} }
// 恢复初始代码
const handleRestoreInitialCode = () => {
restoreInitialCode(identifier);
}
return ( return (
<div className={'right_pane_code_wrap'}> <div className={'right_pane_code_wrap'}>
<MyMonacoEditor <MyMonacoEditor
identifier={identifier}
language={props.language} language={props.language}
code={props.code} code={props.code}
onCodeChange={handleCodeChange} onCodeChange={handleCodeChange}
onRestoreInitialCode={handleRestoreInitialCode}
/> />
<ControlSetting <ControlSetting
identifier={identifier} identifier={identifier}
@ -79,6 +86,8 @@ const mapDispatchToProps = (dispatch) => ({
updateCode: (identifier, inputValue, type) => dispatch(actions.updateCode(identifier, inputValue, type)), updateCode: (identifier, inputValue, type) => dispatch(actions.updateCode(identifier, inputValue, type)),
// 保存用户代码块 // 保存用户代码块
saveUserInputCode: (code) => dispatch(actions.saveUserInputCode(code)), saveUserInputCode: (code) => dispatch(actions.saveUserInputCode(code)),
// 恢复初始代码
restoreInitialCode: (identifier) => dispatch(actions.restoreInitialCode(identifier)),
}); });
export default connect( export default connect(

@ -148,7 +148,7 @@ class TPMIndex extends Component {
componentDidMount = () => { componentDidMount = () => {
let id = this.props.match.params.shixunId; let id = this.props.match.params.shixunId;
console.log('props', this.props);
// let collaborators = `/shixuns/` + id + `/propaedeutics.json`; // let collaborators = `/shixuns/` + id + `/propaedeutics.json`;
// //
// axios.get(collaborators).then((response) => { // axios.get(collaborators).then((response) => {

@ -45,6 +45,8 @@ const types = {
CHANGE_PAGINATION_INFO: 'CHANGE_PAGINATION_INFO', // 改变分页数据 CHANGE_PAGINATION_INFO: 'CHANGE_PAGINATION_INFO', // 改变分页数据
UPDATE_TEST_AND_VALIDATE: 'UPDATE_TEST_AND_VALIDATE', // 更新测试用例及验证值 UPDATE_TEST_AND_VALIDATE: 'UPDATE_TEST_AND_VALIDATE', // 更新测试用例及验证值
UPDATE_OPEN_TESTCASE_INDEX: 'UPDATE_OPEN_TESTCASE_INDEX', // 更新测试用例索引 UPDATE_OPEN_TESTCASE_INDEX: 'UPDATE_OPEN_TESTCASE_INDEX', // 更新测试用例索引
GET_COMMIT_RECORD_DETAIL_BY_ID: 'GET_COMMIT_RECORD_DETAIL_BY_ID', // 根据id号获取提交记录详情
RESTORE_INITIAL_CODE: 'RESTORE_INITIAL_CODE' // 恢复初始代码
} }
export default types; export default types;

@ -40,6 +40,7 @@ import {
submitUserCode, submitUserCode,
getUserProgramDetail, getUserProgramDetail,
saveUserProgramIdentifier, saveUserProgramIdentifier,
restoreInitialCode,
// isUpdateCodeCtx // isUpdateCodeCtx
} from './ojForUser'; } from './ojForUser';
@ -87,6 +88,7 @@ export default {
getUserProgramDetail, getUserProgramDetail,
updateTestAndValidate, updateTestAndValidate,
updateOpenTestCaseIndex, updateOpenTestCaseIndex,
saveUserProgramIdentifier saveUserProgramIdentifier,
restoreInitialCode,
// isUpdateCodeCtx // isUpdateCodeCtx
} }

@ -4,18 +4,20 @@
* @Github: * @Github:
* @Date: 2019-11-27 13:42:11 * @Date: 2019-11-27 13:42:11
* @LastEditors: tangjiang * @LastEditors: tangjiang
* @LastEditTime: 2019-12-03 20:44:47 * @LastEditTime: 2019-12-04 10:54:50
*/ */
import types from "./actionTypes"; import types from "./actionTypes";
import { Base64 } from 'js-base64'; import { Base64 } from 'js-base64';
import { import {
fetchStartProgram, fetchStartProgram,
fetchUserProgramDetail, fetchUserProgramDetail,
fetchDebuggerCode, fetchCodeSubmit, fetchDebuggerCode,
fetchCodeSubmit,
fetchUserCommitRecord, fetchUserCommitRecord,
fetchUserCommitRecordDetail, fetchUserCommitRecordDetail,
fetchUpdateCode, fetchUpdateCode,
fetchUserCodeSubmit fetchUserCodeSubmit,
fetchRestoreInitialCode
} from "../../services/ojService"; } from "../../services/ojService";
// 进入编程页面时,首先调用开启编程题接口 // 进入编程页面时,首先调用开启编程题接口
@ -46,16 +48,23 @@ export const saveUserProgramIdentifier = (identifier) => {
} }
// 获取用户编程题详情 // 获取用户编程题详情
export const getUserProgramDetail = (identifier) => { export const getUserProgramDetail = (identifier, type) => {
// 调用用户编程详情接口 // 调用用户编程详情接口
return (dispatch) => { return (dispatch) => {
fetchUserProgramDetail(identifier).then(res => { fetchUserProgramDetail(identifier).then(res => {
const { status, data = {} } = res; const { status, data = {} } = res;
if (status === 200) { if (status === 200) {
dispatch({ if (!type) {
type: types.USER_PROGRAM_DETAIL, dispatch({
payload: data type: types.USER_PROGRAM_DETAIL,
}); payload: data
});
} else {
dispatch({
type: types.GET_COMMIT_RECORD_DETAIL_BY_ID,
payload: data
})
}
} }
}); });
} }
@ -227,9 +236,9 @@ export const getUserCommitRecord = (identifier) => {
} }
} }
// 获取提交记录详情 // 获取提交记录详情
export const getUserCommitRecordDetail = () => { export const getUserCommitRecordDetail = (identifier) => {
return (dispatch) => { return (dispatch) => {
fetchUserCommitRecordDetail().then(res => { fetchUserCommitRecordDetail(identifier).then(res => {
console.log('提交记录详情======》》》》', res); console.log('提交记录详情======》》》》', res);
}); });
} }
@ -302,3 +311,11 @@ export const submitUserCode = (identifier, inputValue, type) => {
} }
} }
export const restoreInitialCode = (identifier) => {
return (dispatch) => {
fetchRestoreInitialCode(identifier).then(res => {
console.log('恢复初始代码====》》》》', res);
});
}
}

@ -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-03 20:00:26 * @LastEditTime: 2019-12-04 09:02:30
*/ */
import types from "../actions/actionTypes"; import types from "../actions/actionTypes";
import { Base64 } from 'js-base64'; import { Base64 } from 'js-base64';
@ -13,12 +13,13 @@ const initialState = {
user_program_identifier: '', // 开启OJ题的唯一标题 user_program_identifier: '', // 开启OJ题的唯一标题
hack: {}, // 编程题主要内容 hack: {}, // 编程题主要内容
test_case: {}, // 测试用例 test_case: {}, // 测试用例
commitRecordDetail: {}, // 提交记录详情 commitRecordDetail: {}, // 提交成功后记录提交的详情
commitRecord: [], // 提交记录 commitRecord: [], // 提交记录
userCode: '', // 保存当前用户输入的代码 userCode: '', // 保存当前用户输入的代码
isUpdateCode: false, // 是否更新了代码内容 isUpdateCode: false, // 是否更新了代码内容
userCodeTab: 'task', // 学员测评tab位置: task | record | comment userCodeTab: 'task', // 学员测评tab位置: task | record | comment
userTestInput: '', // 用户自定义输入值 userTestInput: '', // 用户自定义输入值
recordDetail: {}, // 根据id号获取的记录详情
}; };
const ojForUserReducer = (state = initialState, action) => { const ojForUserReducer = (state = initialState, action) => {
@ -78,6 +79,11 @@ const ojForUserReducer = (state = initialState, action) => {
...state, ...state,
userCodeTab: action.payload userCodeTab: action.payload
} }
case types.GET_COMMIT_RECORD_DETAIL_BY_ID:
return {
...state,
recordDetail: action.payload
}
default: default:
return state; return state;
} }

@ -4,7 +4,7 @@
* @Github: * @Github:
* @Date: 2019-11-20 10:55:38 * @Date: 2019-11-20 10:55:38
* @LastEditors: tangjiang * @LastEditors: tangjiang
* @LastEditTime: 2019-12-03 14:10:13 * @LastEditTime: 2019-12-04 10:53:41
*/ */
import axios from 'axios'; import axios from 'axios';
@ -71,9 +71,11 @@ export async function fetchUserCommitRecord (identifier) {
} }
// 获取提交记录详情 // 获取提交记录详情
export async function fetchUserCommitRecordDetail () { export async function fetchUserCommitRecordDetail (identifier) {
const url = `/myproblems/record_detail.json`; const url = `/myproblems/record_detail.json`;
return axios.get(url); debugger;
const params = {id: identifier};
return axios.get(url, {params});
} }
// 恢复初始代码 // 恢复初始代码
@ -99,3 +101,9 @@ export async function fetchUserCodeSubmit (identifier) {
const url = `/myproblems/${identifier}/code_submit.json`; const url = `/myproblems/${identifier}/code_submit.json`;
return axios.get(url); return axios.get(url);
} }
// 恢复初始代码
export async function fetchRestoreInitialCode (identifier) {
const url = `/myproblems/${identifier}/restore_initial_code.json`;
return axios.post(url);
}

Loading…
Cancel
Save