From 2169aa90e9353f51c7e777761017398c41cb7701 Mon Sep 17 00:00:00 2001 From: Your Name Date: Thu, 22 Jan 2026 00:51:37 +0800 Subject: [PATCH] style: fix prettier formatting --- src/converters/main.ts | 4 ++-- src/converters/mineru.ts | 2 +- src/converters/pdfmathtranslate.ts | 14 ++++---------- src/pages/download.tsx | 4 ++-- 4 files changed, 9 insertions(+), 15 deletions(-) diff --git a/src/converters/main.ts b/src/converters/main.ts index 76e70dc..e411608 100644 --- a/src/converters/main.ts +++ b/src/converters/main.ts @@ -189,12 +189,12 @@ export async function handleConvert( new RegExp(`${fileTypeOrig}(?!.*${fileTypeOrig})`), newFileExt, ); - + // For archive output converters, the actual file will have .tar extension if (isArchiveOutput) { newFileName = `${newFileName}.tar`; } - + const targetPath = `${userOutputDir}${newFileName.replace(/\.tar$/, "")}`; toProcess.push( new Promise((resolve, reject) => { diff --git a/src/converters/mineru.ts b/src/converters/mineru.ts index b56f80c..ae90f7b 100644 --- a/src/converters/mineru.ts +++ b/src/converters/mineru.ts @@ -128,7 +128,7 @@ export async function convert( : mineruOutputDir; console.log(`[MinerU] Archiving directory: ${outputToArchive}`); - + // 列出要封裝的內容 if (existsSync(outputToArchive)) { const contents = readdirSync(outputToArchive); diff --git a/src/converters/pdfmathtranslate.ts b/src/converters/pdfmathtranslate.ts index 6f65a26..509dfc0 100644 --- a/src/converters/pdfmathtranslate.ts +++ b/src/converters/pdfmathtranslate.ts @@ -266,21 +266,15 @@ export async function convert( // - mono: 純翻譯版本(translated-.pdf) // - dual: 雙語對照版本(bilingual-.pdf) // ⚠️ 不包含原始 PDF,只包含翻譯結果 - + const translatedDest = join(archiveDir, `translated-${targetLang}.pdf`); const bilingualDest = join(archiveDir, `bilingual-${targetLang}.pdf`); // 檢查各種可能的 mono 輸出檔案名稱 - const possibleMonoOutputs = [ - monoPath, - join(tempDir, `${inputFileName}-mono.pdf`), - ]; + const possibleMonoOutputs = [monoPath, join(tempDir, `${inputFileName}-mono.pdf`)]; // 檢查各種可能的 dual 輸出檔案名稱 - const possibleDualOutputs = [ - dualPath, - join(tempDir, `${inputFileName}-dual.pdf`), - ]; + const possibleDualOutputs = [dualPath, join(tempDir, `${inputFileName}-dual.pdf`)]; let foundMono = false; let foundDual = false; @@ -309,7 +303,7 @@ export async function convert( if (!foundMono && !foundDual) { const allFiles = readdirSync(tempDir); const pdfFiles = allFiles.filter((f) => f.endsWith(".pdf") && f !== basename(filePath)); - + for (const pdfName of pdfFiles) { const pdfPath = join(tempDir, pdfName); if (pdfName.includes("mono") || pdfName.includes("translated")) { diff --git a/src/pages/download.tsx b/src/pages/download.tsx index 29fa6b1..1f425d0 100644 --- a/src/pages/download.tsx +++ b/src/pages/download.tsx @@ -25,14 +25,14 @@ export const download = new Elysia() const fileName = sanitize(decodeURIComponent(params.fileName)); const filePath = `${outputDir}${userId}/${jobId}/${fileName}`; - + // 檢查檔案是否存在 if (!existsSync(filePath)) { console.error(`[Download] File not found: ${filePath}`); set.status = 404; return { error: "File not found", path: filePath }; } - + return Bun.file(filePath); }, {