From 0e2cc884a74e5869ff7b74351fc8b885c8bcb12e Mon Sep 17 00:00:00 2001 From: "sylor_huang@126.com" Date: Thu, 13 Aug 2020 10:38:18 +0800 Subject: [PATCH 1/2] Fix: Add New File Language Api Wrong --- src/forge/Newfile/Index.js | 152 ++++++++++++++++++++++++++++++++++++- 1 file changed, 148 insertions(+), 4 deletions(-) diff --git a/src/forge/Newfile/Index.js b/src/forge/Newfile/Index.js index 3df1614f..a9644a64 100644 --- a/src/forge/Newfile/Index.js +++ b/src/forge/Newfile/Index.js @@ -1,8 +1,94 @@ +// import React, { Component } from "react"; +// import Meditor from "./m_editor"; +// import "./index.css"; +// import { Input } from "antd"; +// import FileLanguage from '../Component/FileLanguage'; + +// class Index extends Component { +// constructor(props) { +// super(props); +// this.state = { +// editorValue: "", +// filename: "", +// language: undefined +// }; +// } + +// // 命名文件 +// changeFileName = (e) => { +// this.setState({ +// filename: e.target.value, +// }); +// }; +// // 取消,弹框询问 +// CancelAddFile = () => { +// this.props.history.goBack(); +// }; + +// select_language = (e) => { +// console.log(e) +// this.setState({ +// language: e +// }) + +// } + +// render() { +// const { pathname } = this.props.location; +// const { filename, language } = this.state; +// const urlroot = pathname.split("newfile")[1]; +// const file_path = `${urlroot}/${filename}`; +// const { projectDetail } = this.props; + +// return ( +// +//
+//

+// 新建文件 +//

+//
+//
+//
+//
+// +//
+// +// 取消 +// +//
+//
+// +//
+//
+// +//
+//
+//
+// ); +// } +// } +// export default Index; + import React, { Component } from "react"; import Meditor from "./m_editor"; +import Top from "../Main/DetailTop"; import "./index.css"; -import { Input } from "antd"; -import FileLanguage from '../Component/FileLanguage'; +import { Input, Select } from "antd"; class Index extends Component { constructor(props) { @@ -39,9 +125,62 @@ class Index extends Component { const urlroot = pathname.split("newfile")[1]; const file_path = `${urlroot}/${filename}`; const { projectDetail } = this.props; - + const Option = Select.Option; + const languages = [ + "apex", + "azcli", + "bat", + "clojure", + "coffee", + "cpp", + "csharp", + "csp", + "css", + "dockerfile", + "fsharp", + "go", + "handlebars", + "html", + "ini", + "java", + "javascript", + "json", + "less", + "lua", + "markdown", + "msdax", + "mysql", + "objective", + "perl", + "pgsql", + "php", + "postiats", + "powerquery", + "powershell", + "pug", + "python", + "r", + "razor", + "redis", + "redshift", + "ruby", + "rust", + "sb", + "scheme", + "scss", + "shell", + "solidity", + "sql", + "st", + "swift", + "typescript", + "vb", + "xml", + "yaml", + ]; return ( +

新建文件 @@ -64,7 +203,12 @@ class Index extends Component {

- +
Date: Thu, 13 Aug 2020 10:51:24 +0800 Subject: [PATCH 2/2] Fix: Add New File Language Api Wrong --- src/forge/Component/FileLanguage.jsx | 29 +++-- src/forge/Newfile/Index.js | 152 +-------------------------- 2 files changed, 18 insertions(+), 163 deletions(-) diff --git a/src/forge/Component/FileLanguage.jsx b/src/forge/Component/FileLanguage.jsx index 177449c4..7bfa617b 100644 --- a/src/forge/Component/FileLanguage.jsx +++ b/src/forge/Component/FileLanguage.jsx @@ -57,28 +57,27 @@ const LANGUAGE = [ export default (({ language , select_language })=>{ const [ languages , setLanguage ] = useState(undefined); - - useEffect(()=>{ - const url = '/dev_ops/languages.json'; - axios.get(url).then(result=>{ - if(result){ - setLanguage(result.data); - } - }).catch(error=>{ - console.log(error); - }) - },[]) + // useEffect(()=>{ + // const url = '/dev_ops/languages.json'; + // axios.get(url).then(result=>{ + // if(result){ + // setLanguage(result.data); + // } + // }).catch(error=>{ + // console.log(error); + // }) + // },[]) function changelanguage(value){ - let array = value ? languages.filter(item=>item.name === value) :undefined; - select_language(value,array && array[0]); + // let array = value ? languages.filter(item=>item.name === value) :undefined; + select_language(value); } return( ) diff --git a/src/forge/Newfile/Index.js b/src/forge/Newfile/Index.js index a9644a64..3df1614f 100644 --- a/src/forge/Newfile/Index.js +++ b/src/forge/Newfile/Index.js @@ -1,94 +1,8 @@ -// import React, { Component } from "react"; -// import Meditor from "./m_editor"; -// import "./index.css"; -// import { Input } from "antd"; -// import FileLanguage from '../Component/FileLanguage'; - -// class Index extends Component { -// constructor(props) { -// super(props); -// this.state = { -// editorValue: "", -// filename: "", -// language: undefined -// }; -// } - -// // 命名文件 -// changeFileName = (e) => { -// this.setState({ -// filename: e.target.value, -// }); -// }; -// // 取消,弹框询问 -// CancelAddFile = () => { -// this.props.history.goBack(); -// }; - -// select_language = (e) => { -// console.log(e) -// this.setState({ -// language: e -// }) - -// } - -// render() { -// const { pathname } = this.props.location; -// const { filename, language } = this.state; -// const urlroot = pathname.split("newfile")[1]; -// const file_path = `${urlroot}/${filename}`; -// const { projectDetail } = this.props; - -// return ( -// -//
-//

-// 新建文件 -//

-//
-//
-//
-//
-// -//
-// -// 取消 -// -//
-//
-// -//
-//
-// -//
-//
-//
-// ); -// } -// } -// export default Index; - import React, { Component } from "react"; import Meditor from "./m_editor"; -import Top from "../Main/DetailTop"; import "./index.css"; -import { Input, Select } from "antd"; +import { Input } from "antd"; +import FileLanguage from '../Component/FileLanguage'; class Index extends Component { constructor(props) { @@ -125,62 +39,9 @@ class Index extends Component { const urlroot = pathname.split("newfile")[1]; const file_path = `${urlroot}/${filename}`; const { projectDetail } = this.props; - const Option = Select.Option; - const languages = [ - "apex", - "azcli", - "bat", - "clojure", - "coffee", - "cpp", - "csharp", - "csp", - "css", - "dockerfile", - "fsharp", - "go", - "handlebars", - "html", - "ini", - "java", - "javascript", - "json", - "less", - "lua", - "markdown", - "msdax", - "mysql", - "objective", - "perl", - "pgsql", - "php", - "postiats", - "powerquery", - "powershell", - "pug", - "python", - "r", - "razor", - "redis", - "redshift", - "ruby", - "rust", - "sb", - "scheme", - "scss", - "shell", - "solidity", - "sql", - "st", - "swift", - "typescript", - "vb", - "xml", - "yaml", - ]; + return ( -

新建文件 @@ -203,12 +64,7 @@ class Index extends Component {

- +