fix(export): persist write layout across page switches

This commit is contained in:
tisonhuang
2026-03-05 09:20:52 +08:00
parent 49f99f57c9
commit e795474917
2 changed files with 5 additions and 7 deletions

View File

@@ -1398,7 +1398,7 @@ function ExportPage() {
setIsBaseConfigLoading(true) setIsBaseConfigLoading(true)
let isReady = true let isReady = true
try { try {
const [savedPath, savedMedia, savedVoiceAsText, savedExcelCompactColumns, savedTxtColumns, savedConcurrency, savedSessionMap, savedContentMap, savedSessionRecordMap, savedSnsPostCount, exportCacheScope] = await Promise.all([ const [savedPath, savedMedia, savedVoiceAsText, savedExcelCompactColumns, savedTxtColumns, savedConcurrency, savedSessionMap, savedContentMap, savedSessionRecordMap, savedSnsPostCount, savedWriteLayout, exportCacheScope] = await Promise.all([
configService.getExportPath(), configService.getExportPath(),
configService.getExportDefaultMedia(), configService.getExportDefaultMedia(),
configService.getExportDefaultVoiceAsText(), configService.getExportDefaultVoiceAsText(),
@@ -1409,6 +1409,7 @@ function ExportPage() {
configService.getExportLastContentRunMap(), configService.getExportLastContentRunMap(),
configService.getExportSessionRecordMap(), configService.getExportSessionRecordMap(),
configService.getExportLastSnsPostCount(), configService.getExportLastSnsPostCount(),
configService.getExportWriteLayout(),
ensureExportCacheScope() ensureExportCacheScope()
]) ])
@@ -1421,15 +1422,12 @@ function ExportPage() {
setExportFolder(downloadsPath) setExportFolder(downloadsPath)
} }
setWriteLayout('B') setWriteLayout(savedWriteLayout)
setLastExportBySession(savedSessionMap) setLastExportBySession(savedSessionMap)
setLastExportByContent(savedContentMap) setLastExportByContent(savedContentMap)
setExportRecordsBySession(savedSessionRecordMap) setExportRecordsBySession(savedSessionRecordMap)
setLastSnsExportPostCount(savedSnsPostCount) setLastSnsExportPostCount(savedSnsPostCount)
await Promise.all([ await configService.setExportDefaultFormat('json')
configService.setExportWriteLayout('B'),
configService.setExportDefaultFormat('json')
])
if (cachedSnsStats && Date.now() - cachedSnsStats.updatedAt <= EXPORT_SNS_STATS_CACHE_STALE_MS) { if (cachedSnsStats && Date.now() - cachedSnsStats.updatedAt <= EXPORT_SNS_STATS_CACHE_STALE_MS) {
setSnsStats({ setSnsStats({

View File

@@ -403,7 +403,7 @@ export type ExportWriteLayout = 'A' | 'B' | 'C'
export async function getExportWriteLayout(): Promise<ExportWriteLayout> { export async function getExportWriteLayout(): Promise<ExportWriteLayout> {
const value = await config.get(CONFIG_KEYS.EXPORT_WRITE_LAYOUT) const value = await config.get(CONFIG_KEYS.EXPORT_WRITE_LAYOUT)
if (value === 'A' || value === 'B' || value === 'C') return value if (value === 'A' || value === 'B' || value === 'C') return value
return 'A' return 'B'
} }
export async function setExportWriteLayout(layout: ExportWriteLayout): Promise<void> { export async function setExportWriteLayout(layout: ExportWriteLayout): Promise<void> {