1
This commit is contained in:
2026-03-26 11:54:19 +08:00
parent e643596b60
commit 27790399f3

View File

@ -540,6 +540,25 @@ export default function App() {
}
};
const normalizeSelectedLabelsForRestore = (raw: any): { [key: string]: string | string[] } => {
if (!raw || typeof raw !== 'object') return {};
const out: { [key: string]: string | string[] } = { ...raw };
const normalizeToArray = (val: any): string[] => {
if (Array.isArray(val)) return val.map(v => String(v ?? '').trim()).filter(Boolean);
if (typeof val === 'string') {
return val.split(/[,,、]+/).map(v => v.trim()).filter(Boolean);
}
return [];
};
for (const key of ['标签7', '标签8', '标签10', '标签12']) {
if (key in out) {
const arr = normalizeToArray(out[key]);
out[key] = arr;
}
}
return out;
};
const normalizeExcludedDatesOverride = (raw: any): string[] => {
const parts: string[] = [];
if (Array.isArray(raw)) {
@ -1030,7 +1049,7 @@ export default function App() {
restoreExcludedDatesByNodeOverrideFromSnapshot(snapshot, snapshot?.timelineResults);
// 恢复页面与全局状态
if (snapshot.selectedLabels) setSelectedLabels(snapshot.selectedLabels);
if (snapshot.selectedLabels) setSelectedLabels(normalizeSelectedLabelsForRestore(snapshot.selectedLabels));
if (!mode && snapshot.mode) setMode(snapshot.mode);
if (snapshot.foreignId) setCurrentForeignId(snapshot.foreignId);
if (snapshot.styleText) setCurrentStyleText(snapshot.styleText);
@ -1178,7 +1197,7 @@ export default function App() {
restoreExcludedDatesOverrideFromSnapshot(snapshot, snapshot?.timelineResults);
restoreExcludedDatesByNodeOverrideFromSnapshot(snapshot, snapshot?.timelineResults);
if (snapshot.selectedLabels) setSelectedLabels(snapshot.selectedLabels);
if (snapshot.selectedLabels) setSelectedLabels(normalizeSelectedLabelsForRestore(snapshot.selectedLabels));
if (!mode && snapshot.mode) setMode(snapshot.mode);
if (snapshot.foreignId) setCurrentForeignId(snapshot.foreignId);
if (snapshot.styleText) setCurrentStyleText(snapshot.styleText);
@ -1317,7 +1336,7 @@ export default function App() {
restoreTimelineDirectionFromSnapshot(snapshot);
restoreBaseBufferDaysFromSnapshot(snapshot);
// 恢复页面状态
if (snapshot.selectedLabels) setSelectedLabels(snapshot.selectedLabels);
if (snapshot.selectedLabels) setSelectedLabels(normalizeSelectedLabelsForRestore(snapshot.selectedLabels));
// 保留当前模式,不覆写为快照的模式(避免调整模式被还原为生成模式)
if (!mode && snapshot.mode) setMode(snapshot.mode);
// 快照回填的foreign_id/款式/颜色/版本
@ -4483,7 +4502,7 @@ export default function App() {
}
setStartTime(s.startTime || null);
setExpectedDate(s.expectedDate || null);
setSelectedLabels(s.selectedLabels || {});
setSelectedLabels(normalizeSelectedLabelsForRestore(s.selectedLabels));
const normalizedAdjustments = normalizeTimelineAdjustmentsFromSnapshot(s.timelineAdjustments || {}, s.timelineResults || []);
setTimelineAdjustments(normalizedAdjustments);
setBaseBufferDays(s.baseBufferDays ?? 0);
@ -5557,7 +5576,7 @@ export default function App() {
const raw = f[fieldId];
const list = normalizeToStringList(raw);
if (list.length > 0) {
if (i2 === 7 || i2 === 8 || i2 === 10) labels[key] = list;
if (i2 === 7 || i2 === 8 || i2 === 10 || i2 === 12) labels[key] = list;
else labels[key] = list.join('');
}
}