From 4586649131fd77a25474df6bd63406afcb9eed9b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AF=92=E5=AF=92?= <2596194220@qq.com> Date: Sun, 12 Apr 2026 23:57:33 +0800 Subject: [PATCH] fix: fetch latest export config before export - Call /api/config endpoint at export start to get latest settings - Ensures export uses user's most recent configuration changes --- app/page.tsx | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/app/page.tsx b/app/page.tsx index 026064b..39ecf63 100644 --- a/app/page.tsx +++ b/app/page.tsx @@ -220,8 +220,14 @@ export default function RecipeTranslationPage() { if (!data) return; try { - // 1. 获取导出设置 - const { untranslatedColor, secondPageHeader, orientation } = exportConfig; + // 1. 先调用 API 获取最新导出设置 + const configResponse = await fetch("/api/config"); + const configResult = await configResponse.json(); + const exportConfig = configResult.success ? configResult.data?.export : { + untranslatedColor: "CC0000", + orientation: "landscape", + }; + const { untranslatedColor, orientation } = exportConfig; // 2. 收集所有需要翻译的内容(星期、餐食类型、菜品) const allNames: string[] = []; @@ -272,7 +278,6 @@ export default function RecipeTranslationPage() { // 表头行 - 星期列头 + 餐食类型都要上中下英 const headerCells: TableCell[] = []; - const weekEnglish = translations["week"] || translations["Week"] || "Day"; headerCells.push( new TableCell({ children: [ @@ -427,7 +432,7 @@ export default function RecipeTranslationPage() { console.error("Export error:", err); alert("导出失败,请重试"); } - }, [data, fileName, exportConfig]); + }, [data, fileName]); const handleFileUpload = useCallback( async (file: File) => {