From 28b33d8c44f46ac8c0418e3f877a9db2ca564faa Mon Sep 17 00:00:00 2001 From: WangHe <51102@163.com> Date: Mon, 25 Aug 2025 11:38:18 +0800 Subject: [PATCH] =?UTF-8?q?opt:=20=E4=BC=98=E5=8C=96=E4=BB=85=E6=94=AF?= =?UTF-8?q?=E6=8C=81=E6=96=87=E7=AB=A0=E6=A0=87=E9=A2=98=E6=90=9C=E7=B4=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend_nuxt/utils/vditorPostCitation.js | 25 +++++------------------ 1 file changed, 5 insertions(+), 20 deletions(-) diff --git a/frontend_nuxt/utils/vditorPostCitation.js b/frontend_nuxt/utils/vditorPostCitation.js index 37b80ecac..d3fbcad61 100644 --- a/frontend_nuxt/utils/vditorPostCitation.js +++ b/frontend_nuxt/utils/vditorPostCitation.js @@ -1,17 +1,7 @@ import { authState, getToken } from '~/utils/auth' -async function getPost(apiBaseUrl, id) { - return await fetch(`${apiBaseUrl}/api/posts/${id}`, { - method: 'GET', - headers: { - 'Content-Type': 'application/json', - Authorization: `Bearer ${getToken()}`, - }, - }) -} - async function searchPost(apiBaseUrl, keyword) { - return await fetch(`${apiBaseUrl}/api/search/global?keyword=${keyword}`, { + return await fetch(`${apiBaseUrl}/api/search/posts/title?keyword=${keyword}`, { method: 'GET', headers: { 'Content-Type': 'application/json', @@ -31,15 +21,10 @@ export default (apiBaseUrl) => { const body = await response.json() let value = '' return ( - body - ?.filter((item) => item.type === 'comment' || item.type === 'post') - .map((item) => ({ - value: - item.type === 'comment' - ? `[${item.text}](posts/${item.postId}#comment-${item.id})` - : `[${item.text}](posts/${item.id})`, - html: `
${item.text}
`, - })) ?? [] + body.map((item) => ({ + value: `[${item.title}](/posts/${item.id})`, + html: `
${item.title}
`, + })) ?? [] ) } else { return []