/** * Detail page: show full body_text + separate OCR; no silent truncation. */ import fs from "fs"; const path = "src/app/(ops)/mails/[id]/page.tsx"; let src = fs.readFileSync(path, "utf8"); const old = ` {mail.body_text || mail.ocr_text || "(无正�?"} ), }, ]} />`; const neu = ` 入库原文完整保留,解�?OCR 不会覆盖此字段。可滚动查看全部内容�?
                  {(mail.body_text || "").trim()
                    ? mail.body_text
                    : "(无正�?"}
                
{(mail.ocr_text || "").trim() ? ( <> OCR 文本(附件识别,与原文分开保存)·{" "} {(mail.ocr_text || "").length} �?
                      {mail.ocr_text}
                    
) : null} ), }, ]} />`; if (!src.includes('label: "原始正文(排查用�?')) { console.error("collapse block missing"); process.exit(1); } // Replace by finding key markers const start = src.indexOf('key: "body"'); const labelIdx = src.lastIndexOf("Collapse", start); const collapseStart = src.lastIndexOf("", end); // better: match from that closes it const slice = src.slice(collapseStart, end); const closeRel = slice.indexOf("/>"); if (closeRel < 0) { console.error("no close"); process.exit(1); } // Might be wrong close - find ` />\n\n \n\n \r?\n\r?\n?\s*