feat: 优化同步文章时的文章 ID 链接形式

This commit is contained in:
Frankie Huang 2025-05-06 02:29:13 +08:00
parent f9177c7703
commit 9a2685c0ed

View File

@ -343,7 +343,9 @@ const uploadCloud = () => {
const match = title.match(/^\[(.*?)\]\((.*?)\)$/); const match = title.match(/^\[(.*?)\]\((.*?)\)$/);
if (match) { if (match) {
title = match[1].trim(); // "" 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 // ID ID
@ -372,7 +374,7 @@ const uploadCloud = () => {
SubmitArticle(title, markdownLines.join('\n')) SubmitArticle(title, markdownLines.join('\n'))
.then((data) => { .then((data) => {
articleID = data.id; articleID = data.id;
markdownLines[0] = '# [' + title + '](' + articleID + ')'; markdownLines[0] = '# [' + title + '](../' + articleID + ')';
editorState.text = markdownLines.join('\n'); editorState.text = markdownLines.join('\n');
Modal.remove(); Modal.remove();
Message.success('同步成功'); Message.success('同步成功');