|  |  |  | @ -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 17:19:15 | 
			
		
	
		
			
				
					|  |  |  |  |  */ | 
			
		
	
		
			
				
					|  |  |  |  | import './index.scss'; | 
			
		
	
		
			
				
					|  |  |  |  | import React, { useEffect, useState } from 'react'; | 
			
		
	
	
		
			
				
					|  |  |  | @ -23,22 +23,24 @@ import { withRouter } from 'react-router'; | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | function StudentStudy (props) { | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |   const [hasUpdate, setHasUpdate] = useState(true); | 
			
		
	
		
			
				
					|  |  |  |  |   const { | 
			
		
	
		
			
				
					|  |  |  |  |     // hack,
 | 
			
		
	
		
			
				
					|  |  |  |  |     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);
 | 
			
		
	
	
		
			
				
					|  |  |  | @ -46,10 +48,9 @@ function StudentStudy (props) { | 
			
		
	
		
			
				
					|  |  |  |  |   }, []); | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |   useEffect(() => { | 
			
		
	
		
			
				
					|  |  |  |  |     console.log('=======>>>>>>>>'); | 
			
		
	
		
			
				
					|  |  |  |  |     const { hack = {} } = props; | 
			
		
	
		
			
				
					|  |  |  |  |     if (!hack.modify_code && isUpdate) { // 代码更改,提示是否需要更新代码
 | 
			
		
	
		
			
				
					|  |  |  |  |       setIsUpdate(false); | 
			
		
	
		
			
				
					|  |  |  |  |     if (hack.modify_code && hasUpdate) { // 代码更改,提示是否需要更新代码
 | 
			
		
	
		
			
				
					|  |  |  |  |       setHasUpdate(false); | 
			
		
	
		
			
				
					|  |  |  |  |       Modal.confirm({ | 
			
		
	
		
			
				
					|  |  |  |  |         title: '提示', | 
			
		
	
		
			
				
					|  |  |  |  |         content: ( | 
			
		
	
	
		
			
				
					|  |  |  | @ -61,30 +62,11 @@ function StudentStudy (props) { | 
			
		
	
		
			
				
					|  |  |  |  |         okText: '立即更新', | 
			
		
	
		
			
				
					|  |  |  |  |         cancelText: '稍后再说', | 
			
		
	
		
			
				
					|  |  |  |  |         onOk () { | 
			
		
	
		
			
				
					|  |  |  |  |           console.log('更新代码....'); | 
			
		
	
		
			
				
					|  |  |  |  |           restoreInitialCode(id, '更新成功'); | 
			
		
	
		
			
				
					|  |  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  |  |       }); | 
			
		
	
		
			
				
					|  |  |  |  |     } | 
			
		
	
		
			
				
					|  |  |  |  |   }, [props]); | 
			
		
	
		
			
				
					|  |  |  |  |   // useEffect(() => {
 | 
			
		
	
		
			
				
					|  |  |  |  |   //   const {hack} = props; 
 | 
			
		
	
		
			
				
					|  |  |  |  |   //   if (!hack.modify_code) { // 代码更改,提示是否需要更新代码
 | 
			
		
	
		
			
				
					|  |  |  |  |   //     Modal.confirm({
 | 
			
		
	
		
			
				
					|  |  |  |  |   //       title: '提示',
 | 
			
		
	
		
			
				
					|  |  |  |  |   //       content: (
 | 
			
		
	
		
			
				
					|  |  |  |  |   //         <p>
 | 
			
		
	
		
			
				
					|  |  |  |  |   //           代码文件有更新啦 <br />
 | 
			
		
	
		
			
				
					|  |  |  |  |   //           还未提交的代码,请自行保存
 | 
			
		
	
		
			
				
					|  |  |  |  |   //         </p>
 | 
			
		
	
		
			
				
					|  |  |  |  |   //       ),
 | 
			
		
	
		
			
				
					|  |  |  |  |   //       okText: '立即更新',
 | 
			
		
	
		
			
				
					|  |  |  |  |   //       cancelText: '稍后再说',
 | 
			
		
	
		
			
				
					|  |  |  |  |   //       onOk () {
 | 
			
		
	
		
			
				
					|  |  |  |  |   //         console.log('更新代码....');
 | 
			
		
	
		
			
				
					|  |  |  |  |   //       }
 | 
			
		
	
		
			
				
					|  |  |  |  |   //     });
 | 
			
		
	
		
			
				
					|  |  |  |  |   //   }
 | 
			
		
	
		
			
				
					|  |  |  |  |   // }, [props]);
 | 
			
		
	
		
			
				
					|  |  |  |  |   }, [props, hasUpdate, setHasUpdate]); | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |   const _hack_id = hack_identifier || fromStore('hack_identifier'); | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
	
		
			
				
					|  |  |  | @ -110,7 +92,7 @@ function StudentStudy (props) { | 
			
		
	
		
			
				
					|  |  |  |  |         </div> */} | 
			
		
	
		
			
				
					|  |  |  |  |         <UserInfo userInfo={userInfo}/> | 
			
		
	
		
			
				
					|  |  |  |  |         <div className={'study_name'}> | 
			
		
	
		
			
				
					|  |  |  |  |           <span>乘积最大序列</span> | 
			
		
	
		
			
				
					|  |  |  |  |       <span>乘积最大序列 {hasUpdate}</span> | 
			
		
	
		
			
				
					|  |  |  |  |         </div> | 
			
		
	
		
			
				
					|  |  |  |  |         <div className={'study_quit'}> | 
			
		
	
		
			
				
					|  |  |  |  |           {/* to={`/problems/${_hack_id}/edit`} */} | 
			
		
	
	
		
			
				
					|  |  |  | @ -146,11 +128,13 @@ function StudentStudy (props) { | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | const mapStateToProps = (state) => { | 
			
		
	
		
			
				
					|  |  |  |  |   const { userInfo } = state.userReducer; | 
			
		
	
		
			
				
					|  |  |  |  |   const { hack_identifier } = state.ojForUserReducer; | 
			
		
	
		
			
				
					|  |  |  |  |   const { hack_identifier, user_program_identifier,  hack } = state.ojForUserReducer; | 
			
		
	
		
			
				
					|  |  |  |  |   return { | 
			
		
	
		
			
				
					|  |  |  |  |     hack, | 
			
		
	
		
			
				
					|  |  |  |  |     userInfo, | 
			
		
	
		
			
				
					|  |  |  |  |     user_program_identifier, | 
			
		
	
		
			
				
					|  |  |  |  |     hack_identifier | 
			
		
	
		
			
				
					|  |  |  |  |   }; | 
			
		
	
		
			
				
					|  |  |  |  |   };  | 
			
		
	
		
			
				
					|  |  |  |  | }; | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | const mapDispatchToProps = (dispatch) => ({ | 
			
		
	
	
		
			
				
					|  |  |  | @ -159,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( | 
			
		
	
	
		
			
				
					|  |  |  | 
 |