内网版本-文件内容没有渲染的问题(隐藏了 webIDE 的原因)

This commit is contained in:
caishi 2024-04-07 10:31:15 +08:00
parent df3ba179a3
commit 6fd469fd79
2 changed files with 25 additions and 13 deletions

View File

@ -27,7 +27,8 @@ class CoderRootFileDetail extends Component {
description: props.detail.replace_content, description: props.detail.replace_content,
menuList:undefined, menuList:undefined,
replaceVisible:false, replaceVisible:false,
loading:false loading:false,
random:0,
}; };
} }
@ -140,6 +141,12 @@ class CoderRootFileDetail extends Component {
EditFile = (flag) => { EditFile = (flag) => {
const { onEdit } = this.props; const { onEdit } = this.props;
onEdit && onEdit(flag); onEdit && onEdit(flag);
if(flag){
let num = Math.random();
this.setState({
random:num
})
}
}; };
DownLoadFile = (url) => { DownLoadFile = (url) => {
@ -272,7 +279,7 @@ class CoderRootFileDetail extends Component {
} = this.props; } = this.props;
// 文件只读状态 // 文件只读状态
const readOnly = this.props.history.location.search.indexOf('edit') === -1 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); let flag = current_user && current_user.login && (isManager || isDeveloper);
const Option = Select.Option; const Option = Select.Option;
return ( return (
@ -395,6 +402,7 @@ class CoderRootFileDetail extends Component {
filepath={`/${detail.path}`} filepath={`/${detail.path}`}
content={detail.content} content={detail.content}
readOnly={readOnly} readOnly={readOnly}
random={random}
md={md} md={md}
editorType="update" editorType="update"
currentBranch={currentBranch} currentBranch={currentBranch}

View File

@ -21,7 +21,14 @@ class m_editor extends Component {
}; };
} }
componentDidUpdate = (prevProps) => { 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({ this.setState({
editorValue: this.props.content editorValue: this.props.content
}) })
@ -57,20 +64,17 @@ class m_editor extends Component {
enabled: false, enabled: false,
}, },
}; };
let download_url = detail && detail.download_url; let download_url = detail && detail.download_url;
return ( return (
<Fragment> <Fragment>
<div className="editorBorderBox"> <div className="editorBorderBox">
{!readOnly ? <CodeMirror
<CodeMirror placeholder="请输入内容"
placeholder="请输入内容" value={editorValue}
value={editorValue} options={editor_options}
options={editor_options} onChange={this.changeEditor}
onChange={this.changeEditor} readOnly={readOnly}
/> : '' />
// <CloudIDE download_url={download_url} value={editorValue} params={params} filepath={filepath&&filepath.startsWith('/')?filepath.slice(1):filepath}/>
}
</div> </div>
{!readOnly && ( {!readOnly && (
<div className="editorBorderSubmitBox" style={{ padding: "20px" }}> <div className="editorBorderSubmitBox" style={{ padding: "20px" }}>