forked from Gitlink/forgeplus-react
复制wiki功能
This commit is contained in:
parent
a57bfa87ee
commit
3c60293cd5
File diff suppressed because it is too large
Load Diff
|
|
@ -54,7 +54,7 @@ export default Form.create()(({ form, history, showNotification, projectDetail,
|
|||
const content = Base64.decode(res.data.md_content);
|
||||
setContent(content);
|
||||
setFieldsValue({
|
||||
title: res.data.name,
|
||||
title: search === "?copy" ? `${res.data.name}(复制)` : res.data.name,
|
||||
md_content: content,
|
||||
});
|
||||
}
|
||||
|
|
@ -123,7 +123,7 @@ export default Form.create()(({ form, history, showNotification, projectDetail,
|
|||
return;
|
||||
}
|
||||
const {md_content, title} = values;
|
||||
if (wikiName) {
|
||||
if (wikiName && search!== "?copy") {
|
||||
updateWiki({
|
||||
owner,
|
||||
repo: projectsId,
|
||||
|
|
@ -160,7 +160,7 @@ export default Form.create()(({ form, history, showNotification, projectDetail,
|
|||
|
||||
function dealRes(res, title) {
|
||||
if (res && (res.message === "201" || res.message === "200")) {
|
||||
if(wikiName){
|
||||
if(wikiName && search!== "?copy"){
|
||||
// 如果有更改wiki文件名,则修改sidebar
|
||||
if(wikiName === title){
|
||||
message.success("操作成功");
|
||||
|
|
@ -173,7 +173,14 @@ export default Form.create()(({ form, history, showNotification, projectDetail,
|
|||
}
|
||||
}else{
|
||||
// 根据路由判断是新增的一级页面还是子页面
|
||||
if(search.includes("?key")){
|
||||
if(search === "?copy"){
|
||||
// 截断key的前几位,获取父元素的key值
|
||||
const keyArr = key.split('-');
|
||||
keyArr.pop();
|
||||
const list = menuList;
|
||||
addChildrenByKey(list, keyArr.join('-'), title);
|
||||
updateSidebar(treeToMd(list), title);
|
||||
}else if(search.includes("?key")){
|
||||
// 遍历menuList找到相同key的节点,children push[[页面]]
|
||||
const list = menuList;
|
||||
addChildrenByKey(list, key, title);
|
||||
|
|
|
|||
|
|
@ -231,8 +231,8 @@ export default (props) => {
|
|||
});
|
||||
}
|
||||
|
||||
function goEdit() {
|
||||
history.push(`/${owner}/${projectsId}/wiki/${encodeURI(checkItem.name)}/${checkItem.key}/edit`);
|
||||
function goEdit(params) {
|
||||
history.push(`/${owner}/${projectsId}/wiki/${encodeURI(checkItem.name)}/${checkItem.key}/edit${params}`);
|
||||
}
|
||||
|
||||
function preview() {
|
||||
|
|
@ -327,7 +327,8 @@ export default (props) => {
|
|||
</span>
|
||||
<span className="time-ago font-14">上次修改于{checkItem.commit ? timeAgo(checkItem.commit.author.date) : '刚刚'}</span>
|
||||
</div>
|
||||
{permission && <Button type="primary" onClick={goEdit}>编辑</Button>}
|
||||
{permission && <Button type="primary" ghost onClick={()=>{goEdit(`?copy`)}} className='mr10'>复制</Button>}
|
||||
{permission && <Button type="primary" onClick={()=>{goEdit("")}}>编辑</Button>}
|
||||
</div>
|
||||
|
||||
{itemDetail&&itemDetail.md_content&&<RenderHtml className="wiki-content-detail editor-content-panel imageLayerParent" value={ itemDetail && Base64.decode(itemDetail.md_content) } url={history.location}/>}
|
||||
|
|
|
|||
Loading…
Reference in New Issue