diff --git a/public/react/src/modules/page/VNCContainer.js b/public/react/src/modules/page/VNCContainer.js index f923dede8..36943f73b 100644 --- a/public/react/src/modules/page/VNCContainer.js +++ b/public/react/src/modules/page/VNCContainer.js @@ -24,7 +24,7 @@ class VNCContainer extends Component { repositoryCode: '', displayKey: 1, vnc_reseting: false, - + saving: false, } } componentDidMount() { @@ -40,28 +40,56 @@ class VNCContainer extends Component { getSecondDrawerWidth = () => { return $('#game_right_contents').width() - firstDrawerWidth } + doFileUpdateRequestOnCodeMirrorBlur = () => { + if (!this.currentPath) { + console.error('未找到文件path') + return; + } + const { myshixun, game } = this.props + var url = `/myshixuns/${myshixun.identifier}/update_file.json` + const codeContent = window.editor_monaco.getValue() + + this.setState({saving: true}) + axios.post(url, { + content: codeContent, + // 评测的时候传1,其它情况不用传,主要是为了区分是用户自己提交还是自动提交 + // evaluate: 0, + game_id : game.id, + path: this.currentPath + } + ).then(res => { + this.setState({saving: false}) + }).catch(e => { + this.setState({saving: false}) + console.error('update_file error') + }) + } renderSecondDrawerChildren = () => { - const { readingCodeLoading, repositoryCode } = this.state; + const { readingCodeLoading, repositoryCode, saving } = this.state; + const { shixun } = this.props const height = $(window).height() - 130 const isEditablePath = false; return ( - +
+ {/* (isEditablePath ? 'none' : 'block') */}
+ style={{ backgroundImage: `url('${notEditablePathImg}')`, display: (shixun.code_edit_permission ? 'none' : 'block') }}>
); } fetchReadRepositoryCode = (path) => { + this.currentPath = path; const status = 1 const fetchRepoCodeUrl = `/tasks/${this.props.game.identifier}/rep_content.json?path=${path}&status=${status}` this.setState({ readingCodeLoading: true });