From f283dc2d4091849b37a38d058ba58b63d1ceb3d7 Mon Sep 17 00:00:00 2001 From: Ad-closeNN <1709301095@qq.com> Date: Sat, 16 May 2026 23:32:58 +0800 Subject: [PATCH] =?UTF-8?q?fix(summary):=20=E4=BF=AE=E5=A4=8D=20AI=20?= =?UTF-8?q?=E6=91=98=E8=A6=81=E8=84=9A=E6=9C=AC=E5=88=A0=E9=99=A4=20:::=20?= =?UTF-8?q?=E6=A0=87=E8=AE=B0=E5=92=8C=E6=8D=A2=E8=A1=8C=E7=AC=A6=E4=B8=8D?= =?UTF-8?q?=E4=B8=80=E8=87=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - bodyContent 不再写回文件,避免 ::: admonition 被 strip - 写文件时检测原文换行符(CRLF/LF),避免混用 - 换用 deepseek-v4-flash-free 免费模型 Co-Authored-By: Claude Code --- scripts/summary.js | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/scripts/summary.js b/scripts/summary.js index 5a4c48a..76395d1 100644 --- a/scripts/summary.js +++ b/scripts/summary.js @@ -6,7 +6,7 @@ import https from "https" import readline from "readline" const targetDir = "./src/content/posts/" -const summaryModel = "gpt-5-nano" +const summaryModel = "deepseek-v4-flash-free" const batchDelayMs = 1500 const frontmatterRegex = /^---\r?\n([\s\S]*?)\r?\n---\r?\n?/ @@ -274,11 +274,11 @@ async function generateSummary(fileName) { const fullPath = path.join(targetDir, fileName) const fileContent = fs.readFileSync(fullPath, "utf-8") const frontmatterMatch = fileContent.match(frontmatterRegex) - const bodyContent = stripAdmonitionMarkers( - frontmatterMatch - ? fileContent.slice(frontmatterMatch[0].length).trimStart() - : fileContent, - ) + const bodyOriginal = frontmatterMatch + ? fileContent.slice(frontmatterMatch[0].length).trimStart() + : fileContent; + const bodyForAI = stripAdmonitionMarkers(bodyOriginal) + const eol = fileContent.includes("\r\n") ? "\r\n" : "\n" console.log("\n生成 AI 摘要中...\n") @@ -293,7 +293,7 @@ async function generateSummary(fileName) { - 不要输出 Markdown 语法、admonition 标记或提示框类型,例如 :::warning、:::caution、[!warning]、警告、注意。 文章内容: -${bodyContent}` +${bodyForAI}` const requestBody = JSON.stringify({ model: summaryModel, @@ -349,9 +349,9 @@ ${bodyContent}` summaryModel, ) - newContent = `---\n${newFrontmatter}\n---\n${bodyContent}` + newContent = `---${eol}${newFrontmatter}${eol}---${eol}${bodyOriginal}` } else { - newContent = `---\n${formatFrontmatterField("aiSummary", summary)}\n${formatFrontmatterField("aiSummaryModel", summaryModel)}\n---\n${bodyContent}` + newContent = `---${eol}${formatFrontmatterField("aiSummary", summary)}${eol}${formatFrontmatterField("aiSummaryModel", summaryModel)}${eol}---${eol}${bodyOriginal}` } fs.writeFileSync(fullPath, newContent)