优化最小化窗口存储方式,从保存完整实例改为只保存ID列表以减少存储和避免重复数据

This commit is contained in:
zqm
2025-10-20 11:26:07 +08:00
parent a401620e88
commit e8a6c8dca2

View File

@@ -166,6 +166,8 @@ export class LayoutPersistence {
// 浮动窗口数据
floatingWindows: this.panelCollections.floatingWindows || [],
// 最小化窗口数据 - 只保存ID列表以优化存储
minimizedWindowsIds: (this.panelCollections.minimizedWindows || []).map(w => w.id) || [],
activeCenterTab: this.layoutState.activeCenterTab,
timestamp: new Date().toISOString()
@@ -275,6 +277,20 @@ export class LayoutPersistence {
this.panelCollections.floatingWindows = layout.floatingWindows;
}
if (Array.isArray(layout.minimizedWindowsIds) && this.panelCollections.minimizedWindows && this.panelCollections.floatingWindows) {
// 清空现有最小化窗口列表
this.panelCollections.minimizedWindows = [];
// 根据保存的ID列表从浮动窗口中找到对应的窗口并添加到最小化列表
layout.minimizedWindowsIds.forEach(windowId => {
const window = this.panelCollections.floatingWindows.find(w => w.id === windowId);
if (window) {
window.minimized = true; // 确保窗口标记为最小化
this.panelCollections.minimizedWindows.push(window);
}
});
}
// 应用激活标签
if (layout.activeCenterTab !== undefined) {
// 现在layoutState是store对象直接更新其中的activeCenterTab