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;
|
if (!data) return;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// 1. 获取导出设置
|
// 1. 先调用 API 获取最新导出设置
|
||||||
const { untranslatedColor, secondPageHeader, orientation } = exportConfig;
|
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. 收集所有需要翻译的内容(星期、餐食类型、菜品)
|
// 2. 收集所有需要翻译的内容(星期、餐食类型、菜品)
|
||||||
const allNames: string[] = [];
|
const allNames: string[] = [];
|
||||||
@@ -272,7 +278,6 @@ export default function RecipeTranslationPage() {
|
|||||||
|
|
||||||
// 表头行 - 星期列头 + 餐食类型都要上中下英
|
// 表头行 - 星期列头 + 餐食类型都要上中下英
|
||||||
const headerCells: TableCell[] = [];
|
const headerCells: TableCell[] = [];
|
||||||
const weekEnglish = translations["week"] || translations["Week"] || "Day";
|
|
||||||
headerCells.push(
|
headerCells.push(
|
||||||
new TableCell({
|
new TableCell({
|
||||||
children: [
|
children: [
|
||||||
@@ -427,7 +432,7 @@ export default function RecipeTranslationPage() {
|
|||||||
console.error("Export error:", err);
|
console.error("Export error:", err);
|
||||||
alert("导出失败,请重试");
|
alert("导出失败,请重试");
|
||||||
}
|
}
|
||||||
}, [data, fileName, exportConfig]);
|
}, [data, fileName]);
|
||||||
|
|
||||||
const handleFileUpload = useCallback(
|
const handleFileUpload = useCallback(
|
||||||
async (file: File) => {
|
async (file: File) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user