Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:art: https://github.com/siyuan-note/siyuan/issues/13390

Vanessa44491e4442a8
diff --git a/app/src/layout/Wnd.ts b/app/src/layout/Wnd.ts
index 8f451af8e8..6c90435299 100644
--- a/app/src/layout/Wnd.ts
+++ b/app/src/layout/Wnd.ts
@@ -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");
diff --git a/app/src/layout/util.ts b/app/src/layout/util.ts
index 753d737492..2d125d8f0c 100644
--- a/app/src/layout/util.ts
+++ b/app/src/layout/util.ts
@@ -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 => {