problem_set
hjm 5 years ago
parent 9d5efc98fa
commit dc52b5f503

@ -24,7 +24,7 @@ class VNCContainer extends Component {
repositoryCode: '', repositoryCode: '',
displayKey: 1, displayKey: 1,
vnc_reseting: false, vnc_reseting: false,
saving: false,
} }
} }
componentDidMount() { componentDidMount() {
@ -40,28 +40,56 @@ class VNCContainer extends Component {
getSecondDrawerWidth = () => { getSecondDrawerWidth = () => {
return $('#game_right_contents').width() - firstDrawerWidth 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 = () => { renderSecondDrawerChildren = () => {
const { readingCodeLoading, repositoryCode } = this.state; const { readingCodeLoading, repositoryCode, saving } = this.state;
const { shixun } = this.props
const height = $(window).height() - 130 const height = $(window).height() - 130
const isEditablePath = false; const isEditablePath = false;
return ( return (
<Spin tip="加载中..." spinning={readingCodeLoading}> <Spin tip={saving ? "保存中..." : "加载中..."} spinning={readingCodeLoading || saving}>
<div style={{ height: `${height}px` }}> <div style={{ height: `${height}px` }}>
{/* (isEditablePath ? 'none' : 'block') */}
<div className="codemirrorBackground" <div className="codemirrorBackground"
style={{ backgroundImage: `url('${notEditablePathImg}')`, display: (isEditablePath ? 'none' : 'block') }}></div> style={{ backgroundImage: `url('${notEditablePathImg}')`, display: (shixun.code_edit_permission ? 'none' : 'block') }}></div>
<TPIMonaco <TPIMonaco
{...this.state} {...this.state}
codeLoading={readingCodeLoading} codeLoading={readingCodeLoading}
repositoryCode={repositoryCode} repositoryCode={repositoryCode}
isEditablePath={false} isEditablePath={shixun.code_edit_permission}
shixun={this.props.shixun} shixun={this.props.shixun}
doFileUpdateRequestOnCodeMirrorBlur={this.doFileUpdateRequestOnCodeMirrorBlur}
></TPIMonaco> ></TPIMonaco>
</div> </div>
</Spin>); </Spin>);
} }
fetchReadRepositoryCode = (path) => { fetchReadRepositoryCode = (path) => {
this.currentPath = path;
const status = 1 const status = 1
const fetchRepoCodeUrl = `/tasks/${this.props.game.identifier}/rep_content.json?path=${path}&status=${status}` const fetchRepoCodeUrl = `/tasks/${this.props.game.identifier}/rep_content.json?path=${path}&status=${status}`
this.setState({ readingCodeLoading: true }); this.setState({ readingCodeLoading: true });

Loading…
Cancel
Save