diff --git a/public/site.webmanifest b/public/site.webmanifest index fed067f..142bd2f 100644 --- a/public/site.webmanifest +++ b/public/site.webmanifest @@ -1,6 +1,7 @@ { - "name": "ConvertX-CN | Self Hosted File Converter", + "name": "ConvertX-CN | 自架檔案轉換器", "short_name": "ConvertX-CN", + "description": "自架式多格式檔案轉換工具,支援文件、圖片、音訊、影片等多種格式轉換", "icons": [ { "src": "/android-chrome-192x192.png", @@ -15,5 +16,9 @@ ], "theme_color": "#a5d601", "background_color": "#13171f", - "display": "standalone" + "display": "standalone", + "start_url": "/", + "scope": "/", + "lang": "zh-TW", + "categories": ["utilities", "productivity"] } diff --git a/src/components/base.tsx b/src/components/base.tsx index 8862bc3..60a8a57 100644 --- a/src/components/base.tsx +++ b/src/components/base.tsx @@ -18,6 +18,12 @@ export const BaseHtml = ({ + + + + + + {title} diff --git a/tests/e2e/format-matrix.e2e.test.ts b/tests/e2e/format-matrix.e2e.test.ts index f130f78..dd06805 100644 --- a/tests/e2e/format-matrix.e2e.test.ts +++ b/tests/e2e/format-matrix.e2e.test.ts @@ -18,6 +18,48 @@ import { existsSync, mkdirSync, writeFileSync } from "node:fs"; import { join } from "node:path"; import { spawnSync } from "node:child_process"; +// 靜態導入所有轉換器 +import { convert as convertInkscape } from "../../src/converters/inkscape"; +import { convert as convertImagemagick } from "../../src/converters/imagemagick"; +import { convert as convertGraphicsmagick } from "../../src/converters/graphicsmagick"; +import { convert as convertPandoc } from "../../src/converters/pandoc"; +import { convert as convertDasel } from "../../src/converters/dasel"; +import { convert as convertPotrace } from "../../src/converters/potrace"; +import { convert as convertVtracer } from "../../src/converters/vtracer"; +import { convert as convertResvg } from "../../src/converters/resvg"; +import { convert as convertVips } from "../../src/converters/vips"; +import { convert as convertLibreoffice } from "../../src/converters/libreoffice"; +import { convert as convertCalibre } from "../../src/converters/calibre"; +import { convert as convertFfmpeg } from "../../src/converters/ffmpeg"; +import { convert as convertLibheif } from "../../src/converters/libheif"; +import { convert as convertLibjxl } from "../../src/converters/libjxl"; + +// 轉換器映射表 +type ConvertFn = ( + filePath: string, + fileType: string, + convertTo: string, + targetPath: string, + options?: unknown, +) => Promise; + +const converterMap: Record = { + inkscape: convertInkscape, + imagemagick: convertImagemagick, + graphicsmagick: convertGraphicsmagick, + pandoc: convertPandoc, + dasel: convertDasel, + potrace: convertPotrace, + vtracer: convertVtracer, + resvg: convertResvg, + vips: convertVips, + libreoffice: convertLibreoffice, + calibre: convertCalibre, + ffmpeg: convertFfmpeg, + libheif: convertLibheif, + libjxl: convertLibjxl, +}; + // ============================================================================= // 配置 // ============================================================================= @@ -501,9 +543,12 @@ describe("📊 格式轉換矩陣 Format Conversion Matrix", () => { writeFileSync(inputPath, content, "utf-8"); } - // 動態導入並執行轉換 - const module = await import(`../../src/converters/${converterName}`); - await module.convert(inputPath, from, to, outputPath); + // 使用靜態導入的轉換器映射表 + const convertFn = converterMap[converterName]; + if (!convertFn) { + throw new Error(`Converter not found in converterMap: ${converterName}`); + } + await convertFn(inputPath, from, to, outputPath); const duration = Date.now() - startTime; const success = existsSync(outputPath); @@ -595,12 +640,16 @@ describe("📊 格式轉換矩陣 Format Conversion Matrix", () => { writeFileSync(inputPath, content, "utf-8"); } - const module = await import(`../../src/converters/${converterName}`); + // 使用靜態導入的轉換器映射表 + const convertFn = converterMap[converterName]; + if (!convertFn) { + throw new Error(`Converter not found in converterMap: ${converterName}`); + } // 對於 Pandoc,正規化格式名稱 const normalizedFrom = converterName === "pandoc" ? normalizeFormatForPandoc(from) : from; const normalizedTo = converterName === "pandoc" ? normalizeFormatForPandoc(to) : to; - await module.convert(inputPath, normalizedFrom, normalizedTo, outputPath); + await convertFn(inputPath, normalizedFrom, normalizedTo, outputPath); const duration = Date.now() - startTime; const success = existsSync(outputPath); @@ -681,8 +730,12 @@ describe("📊 格式轉換矩陣 Format Conversion Matrix", () => { const content = createTestContent(from); writeFileSync(inputPath, content, "utf-8"); - const module = await import(`../../src/converters/${converterName}`); - await module.convert(inputPath, from, to, outputPath); + // 使用靜態導入的轉換器映射表 + const convertFn = converterMap[converterName]; + if (!convertFn) { + throw new Error(`Converter not found in converterMap: ${converterName}`); + } + await convertFn(inputPath, from, to, outputPath); const duration = Date.now() - startTime; const success = existsSync(outputPath);