diff --git a/src/forge/Main/CoderDepot.jsx b/src/forge/Main/CoderDepot.jsx index 7db7d6bb..d2a989c3 100644 --- a/src/forge/Main/CoderDepot.jsx +++ b/src/forge/Main/CoderDepot.jsx @@ -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){ ) + 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( + setOpenModal(false)} onOk={okUpdate}/> { (dirInfo || fileInfo) && @@ -337,13 +355,15 @@ function CoderDepot(props){
-

简介

-

{projectDetail && projectDetail.content}

+ 简介 + {projectDetail.permission && (projectDetail.permission==="Admin" || projectDetail.permission==="Owner") && setOpenModal(true)} className="iconfont icon-anquanshezhi color-grey-9 font-15">} + + {desc &&

{desc}

} { - projectDetail && projectDetail.website && + website &&

- {projectDetail.website} + {website}

}

diff --git a/src/forge/Main/sub/UpdateDescModal.jsx b/src/forge/Main/sub/UpdateDescModal.jsx new file mode 100644 index 00000000..a2489bca --- /dev/null +++ b/src/forge/Main/sub/UpdateDescModal.jsx @@ -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( + +

+ + {getFieldDecorator("desc",{ + rules:[] + })( +