复制wiki功能

This commit is contained in:
谢思 2023-12-14 14:06:27 +08:00
parent a57bfa87ee
commit 3c60293cd5
3 changed files with 1433 additions and 1425 deletions

2836
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -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"){
// wikisidebar
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"){
// keykey
const keyArr = key.split('-');
keyArr.pop();
const list = menuList;
addChildrenByKey(list, keyArr.join('-'), title);
updateSidebar(treeToMd(list), title);
}else if(search.includes("?key")){
// menuListkeychildren push[[]]
const list = menuList;
addChildrenByKey(list, key, title);

View File

@ -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}/>}