diff --git a/src/components/MainEditor.vue b/src/components/MainEditor.vue index d97e8cf..b993a22 100644 --- a/src/components/MainEditor.vue +++ b/src/components/MainEditor.vue @@ -343,7 +343,9 @@ const uploadCloud = () => { const match = title.match(/^\[(.*?)\]\((.*?)\)$/); if (match) { title = match[1].trim(); // "标题" - articleID = match[2].trim(); // "链接,例如 https://github.com" + let url = match[2].trim(); // "链接,例如 https://example.com/blog/1" + const matchID = url.match(/(\d+)$/); + articleID = matchID ? matchID[1] : ''; } // 如果存在文章 ID,则更新该文章;否则发布该文章,并在文章 ID 中加入链接 @@ -372,7 +374,7 @@ const uploadCloud = () => { SubmitArticle(title, markdownLines.join('\n')) .then((data) => { articleID = data.id; - markdownLines[0] = '# [' + title + '](' + articleID + ')'; + markdownLines[0] = '# [' + title + '](../' + articleID + ')'; editorState.text = markdownLines.join('\n'); Modal.remove(); Message.success('同步成功');