From 6fd469fd79bcc124bfc0fd241a5e1924e965c570 Mon Sep 17 00:00:00 2001 From: caishi <1149225589@qq.com> Date: Sun, 7 Apr 2024 10:31:15 +0800 Subject: [PATCH] =?UTF-8?q?=E5=86=85=E7=BD=91=E7=89=88=E6=9C=AC-=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E5=86=85=E5=AE=B9=E6=B2=A1=E6=9C=89=E6=B8=B2=E6=9F=93?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98(=E9=9A=90=E8=97=8F=E4=BA=86=20webID?= =?UTF-8?q?E=20=E7=9A=84=E5=8E=9F=E5=9B=A0)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/forge/Main/CoderRootFileDetail.js | 12 ++++++++++-- src/forge/Newfile/m_editor.js | 26 +++++++++++++++----------- 2 files changed, 25 insertions(+), 13 deletions(-) diff --git a/src/forge/Main/CoderRootFileDetail.js b/src/forge/Main/CoderRootFileDetail.js index 372af7202..7d1f6793e 100644 --- a/src/forge/Main/CoderRootFileDetail.js +++ b/src/forge/Main/CoderRootFileDetail.js @@ -27,7 +27,8 @@ class CoderRootFileDetail extends Component { description: props.detail.replace_content, menuList:undefined, replaceVisible:false, - loading:false + loading:false, + random:0, }; } @@ -140,6 +141,12 @@ class CoderRootFileDetail extends Component { EditFile = (flag) => { const { onEdit } = this.props; onEdit && onEdit(flag); + if(flag){ + let num = Math.random(); + this.setState({ + random:num + }) + } }; DownLoadFile = (url) => { @@ -272,7 +279,7 @@ class CoderRootFileDetail extends Component { } = this.props; // 文件只读状态 const readOnly = this.props.history.location.search.indexOf('edit') === -1 - const { language, languages, description , replaceVisible , loading } = this.state; + const { language, languages, description , replaceVisible , loading , random } = this.state; let flag = current_user && current_user.login && (isManager || isDeveloper); const Option = Select.Option; return ( @@ -395,6 +402,7 @@ class CoderRootFileDetail extends Component { filepath={`/${detail.path}`} content={detail.content} readOnly={readOnly} + random={random} md={md} editorType="update" currentBranch={currentBranch} diff --git a/src/forge/Newfile/m_editor.js b/src/forge/Newfile/m_editor.js index 8740b34be..53d652ed1 100644 --- a/src/forge/Newfile/m_editor.js +++ b/src/forge/Newfile/m_editor.js @@ -21,7 +21,14 @@ class m_editor extends Component { }; } componentDidUpdate = (prevProps) => { - if (prevProps && this.props && this.props.content !== prevProps.content) { + let firstCondition = prevProps && this.props && this.props.content !== prevProps.content; + let secondCondition = prevProps && this.props && this.props.random !== prevProps.random; + if (firstCondition) { + this.setState({ + editorValue: this.props.content + }) + } + if(secondCondition){ this.setState({ editorValue: this.props.content }) @@ -57,20 +64,17 @@ class m_editor extends Component { enabled: false, }, }; - let download_url = detail && detail.download_url; return (
- {!readOnly ? - : '' - // - } +
{!readOnly && (