简介修改
This commit is contained in:
parent
55f23dea0d
commit
ec1ff5d479
|
@ -17,6 +17,7 @@ import Releases from '../Component/Releases';
|
|||
import Contributors from '../Component/Contributors';
|
||||
import LanguagePower from '../Component/LanguagePower';
|
||||
import DrawerPanel from '../Component/DrawerPanel';
|
||||
import UpdateDescModal from './sub/UpdateDescModal';
|
||||
import Nodata from '../Nodata';
|
||||
|
||||
|
||||
|
@ -38,6 +39,9 @@ function CoderDepot(props){
|
|||
const [ isSpin , setIsSpin] = useState(true);
|
||||
const [ visible ,setVisible ] = useState(false);
|
||||
const [ mainFlag ,setMainFlag ] = useState(false);
|
||||
const [ openModal , setOpenModal ] = useState(false);
|
||||
const [ desc , setDesc ] = useState(undefined);
|
||||
const [ website , setWebsite ] = useState(undefined);
|
||||
|
||||
const owner = props.match.params.owner;
|
||||
const projectsId = props.match.params.projectsId;
|
||||
|
@ -47,6 +51,8 @@ function CoderDepot(props){
|
|||
useEffect(()=>{
|
||||
if(props.projectDetail){
|
||||
setProjectDetail(props.projectDetail);
|
||||
setDesc(props.projectDetail.description);
|
||||
setWebsite(props.projectDetail.website);
|
||||
}
|
||||
},[props])
|
||||
|
||||
|
@ -208,8 +214,20 @@ function CoderDepot(props){
|
|||
</Menu>
|
||||
</div>
|
||||
)
|
||||
function okUpdate(d,w){
|
||||
const url = `/${owner}/${projectsId}.json`;
|
||||
axios.put(url,{
|
||||
description:d,website:w
|
||||
}).then(result=>{
|
||||
if(result && result.data && result.data.id){
|
||||
setDesc(result.data.description);
|
||||
setWebsite(result.data.website);
|
||||
}
|
||||
})
|
||||
}
|
||||
return(
|
||||
<WhiteBack>
|
||||
<UpdateDescModal desc={desc} website={website} visible={openModal} onCancel={()=>setOpenModal(false)} onOk={okUpdate}/>
|
||||
<Spin spinning={isSpin}>
|
||||
{
|
||||
(dirInfo || fileInfo) &&
|
||||
|
@ -337,13 +355,15 @@ function CoderDepot(props){
|
|||
<ShortWidth>
|
||||
<Gap style={{paddingLeft:"30px"}}>
|
||||
<div className="panelmenu">
|
||||
<p className="font-18 color-grey-6 mb20" style={{lineHeight:"28px"}}>简介</p>
|
||||
<p className="font-14 color-grey-9 mb15" style={{lineHeight:"22px"}}>{projectDetail && projectDetail.content}</p>
|
||||
<FlexAJ className="font-18 color-grey-6 mb20" style={{lineHeight:"28px"}}>简介
|
||||
{projectDetail.permission && (projectDetail.permission==="Admin" || projectDetail.permission==="Owner") && <i onClick={()=>setOpenModal(true)} className="iconfont icon-anquanshezhi color-grey-9 font-15"></i>}
|
||||
</FlexAJ>
|
||||
{desc && <p className="font-14 color-grey-9 mb15 task-hide-2" style={{lineHeight:"22px",WebkitLineClamp:"4",textAlign:"justify"}}>{desc}</p>}
|
||||
{
|
||||
projectDetail && projectDetail.website &&
|
||||
website &&
|
||||
<p className="color-grey-6 df">
|
||||
<i className="iconfont icon-lianjie2 font-15 mr10 color-grey-9"></i>
|
||||
<span style={{wordBreak:"break-all",lineHeight:"20px",marginTop:"5px"}}>{projectDetail.website}</span>
|
||||
<span style={{wordBreak:"break-all",lineHeight:"20px",marginTop:"5px"}}>{website}</span>
|
||||
</p>
|
||||
}
|
||||
<p>
|
||||
|
|
|
@ -0,0 +1,56 @@
|
|||
import React , { forwardRef, useEffect } from 'react';
|
||||
import {Form , Modal , Input } from 'antd';
|
||||
import "./sub.scss";
|
||||
const { TextArea } = Input;
|
||||
function UpdateDescModal({form , visible , onCancel , onOk,desc,website}){
|
||||
const { getFieldDecorator, validateFields , setFieldsValue } = form;
|
||||
|
||||
useEffect(()=>{
|
||||
if(desc || website){
|
||||
setFieldsValue({
|
||||
website,desc
|
||||
})
|
||||
}
|
||||
},[desc,website])
|
||||
|
||||
function onSure(){
|
||||
validateFields((err,values)=>{
|
||||
if(!err){
|
||||
onCancel();
|
||||
onOk(values.desc,values.website)
|
||||
}
|
||||
})
|
||||
}
|
||||
return(
|
||||
<Modal
|
||||
title={"修改信息"}
|
||||
closable={false}
|
||||
visible={visible}
|
||||
centered
|
||||
onCancel={onCancel}
|
||||
onOk={onSure}
|
||||
okText="确定"
|
||||
cancelText="取消"
|
||||
width="400px"
|
||||
className={"descmodal"}
|
||||
>
|
||||
<Form>
|
||||
<Form.Item label="仓库描述">
|
||||
{getFieldDecorator("desc",{
|
||||
rules:[]
|
||||
})(
|
||||
<TextArea placeholder="仓库描述" rows={4} maxLength={200}/>
|
||||
)}
|
||||
</Form.Item>
|
||||
<Form.Item label="website">
|
||||
{getFieldDecorator("website",{
|
||||
rules:[]
|
||||
})(
|
||||
<Input placeholder="website链接"/>
|
||||
)}
|
||||
</Form.Item>
|
||||
</Form>
|
||||
</Modal>
|
||||
)
|
||||
}
|
||||
export default Form.create()(forwardRef(UpdateDescModal));
|
|
@ -11,4 +11,13 @@
|
|||
}
|
||||
align-items: flex-start;
|
||||
}
|
||||
}
|
||||
.descmodal{
|
||||
.ant-row.ant-form-item{
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
.ant-col.ant-form-item-label{
|
||||
height: 20px;
|
||||
line-height: 20px;
|
||||
}
|
||||
}
|
|
@ -226,7 +226,7 @@ class Setting extends Component {
|
|||
})(
|
||||
<TextArea
|
||||
placeholder="请输入仓库描述"
|
||||
style={{ height: "80px" }}
|
||||
style={{ height: "80px" }} maxLength={200}
|
||||
/>
|
||||
)}
|
||||
</Form.Item>
|
||||
|
|
Loading…
Reference in New Issue