Vanessa 2024-12-09 11:23:46 +08:00
parent 553891defb
commit 44491e4442
2 changed files with 10 additions and 2 deletions

View file

@ -445,7 +445,7 @@ export class Wnd {
});
// 在 JSONToLayout 中进行 focus
if (!isInitActive) {
setPanelFocus(this.headersElement.parentElement.parentElement);
setPanelFocus(this.headersElement.parentElement.parentElement, isSaveLayout);
}
if (currentTab && currentTab.headElement) {
const initData = currentTab.headElement.getAttribute("data-initdata");

View file

@ -306,6 +306,8 @@ const JSONToDock = (json: any, app: App) => {
window.siyuan.layout.bottomDock = new Dock({position: "Bottom", data: json.bottom, app});
};
const removedTabs: Tab[] = []
export const JSONToCenter = (
app: App,
json: Config.TUILayoutItem,
@ -432,8 +434,10 @@ export const JSONToCenter = (
json.children.forEach((item: any) => {
JSONToCenter(app, item, layout ? child : window.siyuan.layout.layout);
});
} else {
} else if (json.children && Object.keys(json.children).length > 0) {
JSONToCenter(app, json.children, child);
} else if (child instanceof Tab) {
removedTabs.push(child)
}
}
};
@ -510,6 +514,10 @@ export const JSONToLayout = (app: App, isStart: boolean) => {
if (latestTabHeaderElement) {
setPanelFocus(latestTabHeaderElement.parentElement.parentElement.parentElement, false);
}
// 移除没有数据的页签 https://github.com/siyuan-note/siyuan/issues/13390
removedTabs.forEach(item => {
item.parent.removeTab(item.id);
})
}
// 需放在 tab.parent.switchTab 后,否则当前 tab 永远为最后一个
app.plugins.forEach(item => {