From 8c1bebcfdce70bb50d085ccdfaabbda3744008bc Mon Sep 17 00:00:00 2001 From: caishi <1149225589@qq.com> Date: Tue, 20 Apr 2021 10:30:47 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=87=E6=8D=A2=E5=B7=A6=E4=BE=A7=E7=9B=AE?= =?UTF-8?q?=E5=BD=95=EF=BC=8C=E9=80=89=E6=8B=A9=E4=B8=8D=E5=90=8C=E7=9A=84?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E6=97=B6=EF=BC=8C=E6=96=87=E4=BB=B6=E8=AF=A6?= =?UTF-8?q?=E6=83=85=E6=B2=A1=E6=9C=89=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/forge/Main/CoderRootFileDetail.js | 14 +++++++++++++- src/forge/Newfile/m_editor.js | 7 +++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/src/forge/Main/CoderRootFileDetail.js b/src/forge/Main/CoderRootFileDetail.js index a800e76c..19930155 100644 --- a/src/forge/Main/CoderRootFileDetail.js +++ b/src/forge/Main/CoderRootFileDetail.js @@ -31,6 +31,18 @@ class CoderRootFileDetail extends Component { this.languages_total(); }; + componentDidUpdate=(prevProps)=>{ + const { content } = this.props && this.props.detail; + const prevcontent = prevProps.detail && prevProps.detail.content; + if (content && prevcontent) { + if (prevcontent !== content){ + this.setState({ + description: content + }); + } + } + } + languages_total = () => { const { detail } = this.props; const file_name = detail.path.split("/").pop().split(".").pop(); @@ -268,7 +280,7 @@ class CoderRootFileDetail extends Component { {...this.state} language={language ? language : "javascript"} filepath={`/${detail.path}`} - content={detail.content} + content={description} readOnly={readOnly} editorType="update" currentBranch={currentBranch} diff --git a/src/forge/Newfile/m_editor.js b/src/forge/Newfile/m_editor.js index 862e5f8d..4e2e6851 100644 --- a/src/forge/Newfile/m_editor.js +++ b/src/forge/Newfile/m_editor.js @@ -12,6 +12,13 @@ class m_editor extends Component { editorValue: this.props.content, }; } + componentDidUpdate=(prevProps)=>{ + if(prevProps && this.props && this.props.content !== prevProps.content){ + this.setState({ + editorValue:this.props.content + }) + } + } changeEditor = (editorValue) => { this.setState({ editorValue,