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
This commit is contained in:
+9
-4
@@ -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) => {
|
||||
|
||||
Reference in New Issue
Block a user