diff --git a/src/forge/Main/CoderRootFileDetail.js b/src/forge/Main/CoderRootFileDetail.js index b30e3d294..07dbb3402 100644 --- a/src/forge/Main/CoderRootFileDetail.js +++ b/src/forge/Main/CoderRootFileDetail.js @@ -4,7 +4,7 @@ import { Popconfirm, Result } from 'antd'; import './list.css'; import axios from 'axios'; -import CodeMirror from 'react-codeMirror'; +import CodeMirror from 'react-codemirror'; require('codemirror/lib/codemirror.css'); require('codemirror/mode/javascript/javascript'); require('codemirror/mode/xml/xml'); @@ -46,7 +46,7 @@ class CoderRootFileDetail extends Component{ } // 编辑文件 - + changeMmirror=(e,e1,value)=>{ this.setState({ value @@ -166,4 +166,4 @@ class CoderRootFileDetail extends Component{ } } -export default CoderRootFileDetail; \ No newline at end of file +export default CoderRootFileDetail; diff --git a/src/modules/page/main/CodeRepositoryView.js b/src/modules/page/main/CodeRepositoryView.js index 5dd87f6a0..05c430243 100644 --- a/src/modules/page/main/CodeRepositoryView.js +++ b/src/modules/page/main/CodeRepositoryView.js @@ -11,7 +11,7 @@ import Tree, { TreeNode } from 'rc-tree'; import 'rc-tree/assets/index.css'; import classNames from 'classnames' -// import CodeMirror from 'react-codeMirror' +// import CodeMirror from 'react-codemirror' import axios from 'axios' import _ from 'lodash' @@ -52,12 +52,12 @@ class CodeRepositoryView extends Component { } componentDidUpdate(prevProps, prevState, snapshot) { const { game, challenge, hide_code, tabIndex, } = this.props - + if ( // 初始化 或者 game切换 - !this.treeExpanded && challenge.path && challenge.path.length && this.state.expandedKeys.length === 0 || - game && (!prevProps.game + !this.treeExpanded && challenge.path && challenge.path.length && this.state.expandedKeys.length === 0 || + game && (!prevProps.game || prevProps.game.identifier !== this.props.game.identifier) ) { - + if (!this.treeExpanded) { this.treeExpanded = true const _path = challenge.multiPath ? challenge.path[0] : challenge.path; @@ -77,8 +77,8 @@ class CodeRepositoryView extends Component { }) } - if (game && (!prevProps.game - || prevProps.game.identifier !== this.props.game.identifier)) { + if (game && (!prevProps.game + || prevProps.game.identifier !== this.props.game.identifier)) { // 切换关卡时切换到第一个tab // 如果隐藏code tab,就只有一个ssh tab了 if (hide_code == true) { @@ -90,12 +90,12 @@ class CodeRepositoryView extends Component { } } - componentDidMount() { + componentDidMount() { // 隐藏code tab,则显示ssh tab(81) if (this.props.hide_code === true) { this.tabIndexChange(81) } - + //显示所有代码文件 $(".code-file-tab").hover(function(){ // var ulwidth=$("#blacktab_nav").width(); @@ -119,22 +119,22 @@ class CodeRepositoryView extends Component { const expandedKeys = this.state.expandedKeys.slice(0) const _index = expandedKeys.indexOf(selectedKeys[0]); if (_index == -1) { - expandedKeys.push(selectedKeys[0]) + expandedKeys.push(selectedKeys[0]) } else { expandedKeys.splice( _index, 1) } this.setState({ expandedKeys }) } - + this.props.onTreeSelect(selectedKeys, info) - } + } buildTree() { // TODO http://localhost:3007/tasks/xgffnuomytpj 这个实训没有文件树 const { fileTreeData, onLoadData, fileTreeSelectedKeys } = this.props; if (!fileTreeData || fileTreeData.length === 0) { return "" } - + const loop = (data) => { return data.map((item) => { @@ -147,8 +147,8 @@ class CodeRepositoryView extends Component { }); }; const treeNodes = loop(fileTreeData); - - + + // selectable={false} return ( { - domArray.push( + domArray.push(

this.onPathChange(index, true) } > - {item} + {item}

) }) - + return (
- {domArray} + {domArray}
) } @@ -209,11 +209,11 @@ class CodeRepositoryView extends Component { axios.get(url, { // withCredentials: true - } - ).then((response) => { + } + ).then((response) => { tabIndex && $(`#codetab_con_${tabIndex}`).html('') // 清空 ‘正在连接命令行服务...’ - if (response.data.game_id) { + if (response.data.game_id) { // 重置ssh状态 this.setSSHClosed(false); @@ -227,7 +227,7 @@ class CodeRepositoryView extends Component { var line_h = (navigator.userAgent.indexOf('Chrome') >= 0 ? 18 : 19); var rows = Math.round(h / line_h); var cols = parseInt(w / 9.9); - + response.data.width = w; response.data.height = h; response.data.line_h = line_h; @@ -237,7 +237,7 @@ class CodeRepositoryView extends Component { // this.loadSshInIframe( response.data, tabIndex ) this.loadSshNormal(response.data, tabIndex, isReInit) - + } // console.log(response) }).catch((error) => { @@ -257,7 +257,7 @@ class CodeRepositoryView extends Component { // $(".game_webssh").css({"min-height":h, "max-height":h}); const container = $(`#codetab_con_${tabIndex}`); // ReactDOM.unmountComponentAtNode(container) - // ReactDOM.render(, container); // this.setState({ // sshData: data @@ -273,7 +273,7 @@ class CodeRepositoryView extends Component { , height, width, line_h, rows, cols, } = data let _domain = webssh_url || 'https://webssh.educoder.net'; - // window.location.host === "www.educoder.net" ? + // window.location.host === "www.educoder.net" ? // 'https://webssh.educoder.net' // : 'https://testwebssh.educoder.net' const html = `` @@ -286,9 +286,9 @@ class CodeRepositoryView extends Component { if ($(`#codetab_con_${index} .terminal.xterm`).length === 1) { // 已经初始化过了 return; } - + this.initSsh($, index); - + } /** multi ssh */ setSSHClosed = (isClose) => { @@ -318,7 +318,7 @@ class CodeRepositoryView extends Component { close_ssh_cocket_iframe = (id) => { /* 关闭连接,清空tab content - */ + */ let _w = $(`.game_webssh_${id}`)[0].contentWindow _w && _w.postMessage({tp: 'close_ssh_cocket'}, "*"); $(`#codetab_con_${id}`).html('') @@ -326,7 +326,7 @@ class CodeRepositoryView extends Component { close_ssh_cocket_normal = (id) => { /* 关闭连接,清空tab content - */ + */ // let _w = $(`.game_webssh_${id}`)[0].contentWindow // _w && _w.postMessage({tp: 'close_ssh_cocket'}, "*"); // $(`#codetab_con_${id}`).html('') @@ -338,7 +338,7 @@ class CodeRepositoryView extends Component { this.tabIndexChange(STABLE_SSH_TAB_ID) this.setState({ addtionalSSHArray }) // game_webssh_${tabIndex} TODO - + this.close_ssh_cocket_normal(id) e.stopPropagation(); } @@ -379,7 +379,7 @@ class CodeRepositoryView extends Component { width={300} open={drawerOpen} - + onClose={() => showFilesDrawer( false )} > { loadingFirstRepoFiles ? ( @@ -390,7 +390,7 @@ class CodeRepositoryView extends Component {
- +
{/* 没必要显示这个,注释掉了 */} - {/* { !isEditablePath && + {/* { !isEditablePath &&
{currentPath} -
+
} */} {this.props.readRepoTimeout === true ?
- 代码加载失败, this.props.fetchRepositoryCode(this.props, null, null, true, true)}>重试
: -
{/**/} @@ -536,17 +536,17 @@ class CodeRepositoryView extends Component {
} -
{/* { tabIndex === STABLE_SSH_TAB_ID && this.state.sshData && } */}
-
-
-
@@ -554,13 +554,13 @@ class CodeRepositoryView extends Component { ); } } -/* +/* <%= Redmine::CodesetUtil.replace_invalid_utf8(@content) %> - , overflow: 'scroll' ref="editor" + , overflow: 'scroll' ref="editor" - */ -export default CodeRepositoryView; \ No newline at end of file +export default CodeRepositoryView; diff --git a/src/modules/test/codemirror/TestCodeMirror.js b/src/modules/test/codemirror/TestCodeMirror.js index f451bc356..08ca32f15 100644 --- a/src/modules/test/codemirror/TestCodeMirror.js +++ b/src/modules/test/codemirror/TestCodeMirror.js @@ -1,6 +1,6 @@ import React, { Component } from 'react'; -import CodeMirror from 'react-codeMirror' +import CodeMirror from 'react-codemirror' require('codemirror/lib/codemirror.css'); require('codemirror/mode/javascript/javascript'); @@ -28,13 +28,13 @@ class TestCodeMirror extends Component { componentDidMount() { var readOnlyLines = [0,1,2,3,8]; - + this.refs.editor.getCodeMirror().on('beforeChange',function(cm,change) { console.log('change.from.line', change.from.line) - if ( readOnlyLines.indexOf(change.from.line) !== -1 + if ( readOnlyLines.indexOf(change.from.line) !== -1 // 有问题:如果用回车将有内容的行挤到不可编辑的行,那么无法删除掉不可编辑行里的内容了 // 解决办法:将所需的行数固定写好,禁用掉回车键。 - // || change.from.line > ( readOnlyLines[readOnlyLines.length -1] + 1 ) + // || change.from.line > ( readOnlyLines[readOnlyLines.length -1] + 1 ) ) { change.cancel(); } @@ -60,4 +60,4 @@ class TestCodeMirror extends Component { } } -export default TestCodeMirror; \ No newline at end of file +export default TestCodeMirror;