From 915bf69e6f323cc2fb9db917a415c713a8aa5c2a Mon Sep 17 00:00:00 2001 From: caishi <1149225589@qq.com> Date: Wed, 1 Dec 2021 11:06:10 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=87=E4=BB=B6=E5=90=8D=E7=89=B9=E6=AE=8A?= =?UTF-8?q?=E5=AD=97=E7=AC=A6=E5=88=A4=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/forge/Newfile/Index.js | 43 ++++++++++++++++++++---- src/forge/Newfile/UserSubmitComponent.js | 8 ++--- src/forge/Newfile/index.css | 8 +++++ src/forge/Newfile/m_editor.js | 3 +- 4 files changed, 51 insertions(+), 11 deletions(-) diff --git a/src/forge/Newfile/Index.js b/src/forge/Newfile/Index.js index 953f5072..31ef5865 100644 --- a/src/forge/Newfile/Index.js +++ b/src/forge/Newfile/Index.js @@ -10,7 +10,8 @@ class Index extends Component { this.state = { editorValue: "", filename: "", - language: undefined + language: undefined, + checkName:false }; } @@ -26,16 +27,43 @@ class Index extends Component { }; select_language = (e) => { - console.log(e) this.setState({ language: e }) } + checkFileName=(e)=>{ + let value = (e.target.value); + //\需要单独判断 + const str = '!!@/::"“”<《》>||??%'; + let reg = /\\/g; + if(reg.test(value)){ + this.setState({ + checkName:true + }) + }else{ + for(var i=0;i -1){ + this.setState({ + checkName:true + }) + return; + }else{ + this.setState({ + checkName:false + }) + continue; + } + } + } + + } + render() { const { pathname } = this.props.location; - const { filename, language } = this.state; + const { filename, language , checkName } = this.state; const urlroot = pathname.split("newfile")[1]; const file_path = `${urlroot}/${filename}`; const { projectDetail } = this.props; @@ -47,15 +75,17 @@ class Index extends Component { 新建文件

-
+
-
diff --git a/src/forge/Newfile/UserSubmitComponent.js b/src/forge/Newfile/UserSubmitComponent.js index aa4bba6e..e67597cb 100644 --- a/src/forge/Newfile/UserSubmitComponent.js +++ b/src/forge/Newfile/UserSubmitComponent.js @@ -63,13 +63,13 @@ class UserSubmitComponent extends Component { // 提交变更 subMitFrom = () => { - const { filepath, content, editor_type } = this.props; + const { filepath, content, editor_type , checkName} = this.props; const { branch, projectsId , owner } = this.props.match.params; const { submitType, filename } = this.state; this.setState({ isSpin: true }); let path = editor_type === "upload" ? filepath : filepath.substr(1); this.props.form.validateFieldsAndScroll((err, values) => { - if (!err) { + if (!err && !checkName) { const url = `/${owner}/${projectsId}/create_file.json`; axios.post(url, { filepath: filename ? filename : path, @@ -103,13 +103,13 @@ class UserSubmitComponent extends Component { // 确认修改文件 UpdateFile = () => { this.setState({ isSpin: true }); - const { branch, detail, content , currentBranch } = this.props; + const { branch, detail, content , currentBranch ,checkName } = this.props; const { projectsId , owner } = this.props.match.params; const { submitType } = this.state; const url = `/${owner}/${projectsId}/update_file.json`; let b = currentBranch || branch; this.props.form.validateFieldsAndScroll((err, values) => { - if (!err) { + if (!err && !checkName) { axios .put(url, { filepath: detail.path, diff --git a/src/forge/Newfile/index.css b/src/forge/Newfile/index.css index 0bda4711..60156a34 100644 --- a/src/forge/Newfile/index.css +++ b/src/forge/Newfile/index.css @@ -9,6 +9,7 @@ .setInputAddon{ width: 350px; margin-right: 20px; + position: relative; } .setInputAddon .ant-input-group-addon{ height: 30px; @@ -16,6 +17,13 @@ border: 1px solid #d9d9d9!important; border-right: none!important; } +.setInputAddon.red .ant-input-group-addon{ + border-color: red!important; +} +.setInputAddon.red .ant-input-group > .ant-input:last-child{ + border-color: red!important; + border-left-color: #d9d9d9!important; +} .editorBorder .editorBorderBox{ border:1px solid #d0d0d0; border-radius: 2px; diff --git a/src/forge/Newfile/m_editor.js b/src/forge/Newfile/m_editor.js index d4446e3f..58a79403 100644 --- a/src/forge/Newfile/m_editor.js +++ b/src/forge/Newfile/m_editor.js @@ -34,7 +34,7 @@ class m_editor extends Component { render() { const { editorValue , changeValue } = this.state; - const { readOnly, editorType, currentBranch , descName } = this.props; + const { readOnly, editorType, currentBranch , descName , checkName } = this.props; const editor_options = { lineNumbers: "on", lineWrapping: true, //强制换行 @@ -76,6 +76,7 @@ class m_editor extends Component { editor_type={editorType} currentBranch={currentBranch} descName={descName} + checkName={checkName} >
)}