Merge branch 'feature_repo_second_page' of https://git.trustie.net/Gitlink/forgeplus-react into feature_repo_second_page

This commit is contained in:
caishi 2021-09-30 20:42:16 +08:00
commit a6675d6c3f
3 changed files with 74 additions and 55 deletions

View File

@ -67,6 +67,7 @@ function CoderDepot(props){
const [ editReadme , setEditReadme ] = useState(false); const [ editReadme , setEditReadme ] = useState(false);
const [ pullsFlag , setPullsFlag ] = useState(true); const [ pullsFlag , setPullsFlag ] = useState(true);
const [ issuesFlag , setIssuesFlag ] = useState(true); const [ issuesFlag , setIssuesFlag ] = useState(true);
const [ releaseVersions , setReleaseVersions] = useState(undefined);
const owner = props.match.params.owner; const owner = props.match.params.owner;
const projectsId = props.match.params.projectsId; const projectsId = props.match.params.projectsId;
@ -131,6 +132,18 @@ function CoderDepot(props){
} }
},[projectsId,owner,pathname,defaultBranch]) },[projectsId,owner,pathname,defaultBranch])
useEffect(()=>{
axios.get(`/${owner}/${projectsId}/releases.json`).then((result)=>{
if(result && result.data){
const release = {
"list":result.data.releases,
"total_count":result.data.releases.length
}
setReleaseVersions(release);
}
})
},[])
// readme // readme
function getReadmeInfo(path, ref) { function getReadmeInfo(path, ref) {
axios.get(`/${owner}/${projectsId}/readme.json`, { axios.get(`/${owner}/${projectsId}/readme.json`, {
@ -545,13 +558,13 @@ function CoderDepot(props){
} }
{/* 发布 */} {/* 发布 */}
{ {
projectDetail && projectDetail.release_versions && releaseVersions &&
<React.Fragment> <React.Fragment>
<Divider /> <Divider />
<Releases <Releases
owner={owner} owner={owner}
projectsId={projectsId} projectsId={projectsId}
releaseVersions={projectDetail.release_versions} releaseVersions={releaseVersions}
history={props.history} history={props.history}
distribution={distribution} distribution={distribution}
/> />

View File

@ -63,7 +63,7 @@ function version(props) {
<span className={`${item.draft === "稳定" ?"versionTag green":"versionTag orange"}`}>{item.draft}</span> <span className={`${item.draft === "稳定" ?"versionTag green":"versionTag orange"}`}>{item.draft}</span>
<span className="color-grey-3 mt15 font-12"> <span className="color-grey-3 mt15 font-12">
<i className="iconfont icon-biaoqianicon mr3 font-14"></i> <i className="iconfont icon-biaoqianicon mr3 font-14"></i>
<Link className="hover" to={`/${owner}/${projectsId}/tree/${item.name}`} >{item.tag_name}</Link> <Link className="hover" to={`/${owner}/${projectsId}/tree/${item.tag_name}`} >{item.tag_name}</Link>
</span> </span>
<span className="color-grey-3 font-12"> <span className="color-grey-3 font-12">
<img src={Tree} width="16px" color="#333333" className="mr3"/> <img src={Tree} width="16px" color="#333333" className="mr3"/>

View File

@ -52,68 +52,74 @@ class m_editor extends Component {
const handleEditorMount = (editor, monaco) => { const handleEditorMount = (editor, monaco) => {
editor.onDidChangeModelDecorations(() => { editor.onDidChangeModelDecorations(() => {
updateEditorHeight(); // typing updateEditorHeight(); // typing
requestAnimationFrame(updateEditorHeight); //folding requestAnimationFrame(updateEditorHeight); // folding
}); });
const updateEditorHeight = () => { const updateEditorHeight = () => {
const editorElement = editor.getDomNode(); const editorElement = editor.getDomNode();
if (!editorElement) { if (!editorElement) {
return; return;
} }
const padding = 40; const padding = 40;
const lineHeight = editor.getOption( const lineHeight = editor.getOption(
monaco.editor.EditorOption.lineHeight monaco.editor.EditorOption.lineHeight
); );
const lineCount = editor.getModel().getLineCount() || 1;
const height =
editor.getTopForLineNumber(lineCount + 1) +
lineHeight +
padding;
if (this.state.prevHeight !== height) { const lineCount = editor.getModel().getLineCount() || 1;
this.setState({ const height =
prevHeight:height editor.getTopForLineNumber(lineCount + 1) +
}) lineHeight +
padding;
if (this.state.prevHeight !== height) {
this.setState({
prevHeight:height
})
// setPrevHeight(height); // setPrevHeight(height);
editorElement.style.height = `${height}px`; editorElement.style.height = `${height}px`;
editor.layout(); editor.layout();
} }
}; };
}; };
return ( return (
<div>
<div className="">
<Editor <React.Fragment>
height="400px" <div>
language={language ? language : "plaintext"} <div className="">
theme={"vs-grey"} <Editor
placeholder="请输入内容" // height={this.state.x}
value={editorValue} language={language ? language : "plaintext"}
options={editor_options} theme={"vs-grey"}
onChange={this.changeEditor} placeholder="请输入内容"
editorWillMount={this.editorWillMount} value={editorValue}
editorDidMount={handleEditorMount} options={editor_options}
/> onChange={this.changeEditor}
</div> editorWillMount={this.editorWillMount}
{!readOnly && ( editorDidMount={handleEditorMount}
<div style={{marginTop:"20px",padding:"20px"}}> />
<UserSubmitComponent </div>
{...this.props} {!readOnly && (
{...this.state} <div style={{marginTop:"20px",padding:"20px"}}>
filepath={`${this.props.filepath}`} <UserSubmitComponent
content={editorValue} {...this.props}
editor_type={editorType} {...this.state}
currentBranch={currentBranch} filepath={`${this.props.filepath}`}
descName={descName} content={editorValue}
></UserSubmitComponent> editor_type={editorType}
</div> currentBranch={currentBranch}
)} descName={descName}
</div> ></UserSubmitComponent>
</div>
)}
</div>
</React.Fragment>
); );
} }
} }