fix: ColPage 回写侧栏宽度与收起状态以恢复跨页布局记忆

This commit is contained in:
2026-10-11 00:52:24 +08:00
parent c24051aa04
commit f4de5d8fd0
2 changed files with 78 additions and 14 deletions
@@ -56,11 +56,23 @@ export const useColSidebarLayoutStore = defineStore(
}
function setWidth(kind: ColSidebarKind, width: number) {
layoutOf(kind).width = clampWidth(width);
const next = clampWidth(width);
const prev = layoutOf(kind);
if (prev.width === next) return;
// 整对象替换,确保 pinia persist 能稳定序列化
layouts.value = {
...layouts.value,
[kind]: { ...prev, width: next },
};
}
function setCollapsed(kind: ColSidebarKind, collapsed: boolean) {
layoutOf(kind).collapsed = collapsed;
const prev = layoutOf(kind);
if (prev.collapsed === collapsed) return;
layouts.value = {
...layouts.value,
[kind]: { ...prev, collapsed },
};
}
function $reset() {