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/10470

Vanessa1e98e2580140
diff --git a/app/src/layout/Wnd.ts b/app/src/layout/Wnd.ts
index 1d3e9cf481..bcd74ad310 100644
--- a/app/src/layout/Wnd.ts
+++ b/app/src/layout/Wnd.ts
@@ -571,7 +571,7 @@ export class Wnd {
if (this.parent.type === "center" && this.children.length === 2 && !this.children[0].headElement) {
this.removeTab(this.children[0].id);
} else if (this.children.length > window.siyuan.config.fileTree.maxOpenTabCount) {
- this.removeOverCounter(oldFocusIndex);
+ this.removeOverCounter(isSaveLayout);
}
/// #if !BROWSER
setTabPosition();
@@ -641,22 +641,15 @@ export class Wnd {
});
}
- private removeOverCounter(oldFocusIndex?: number) {
- if (typeof oldFocusIndex === "undefined") {
- this.children.forEach((item, index) => {
- if (item.headElement && item.headElement.classList.contains("item--focus")) {
- oldFocusIndex = index;
- }
- });
- }
+ private removeOverCounter(isSaveLayout = false) {
let removeId: string;
let openTime: string;
+ let removeCount = 0
this.children.forEach((item, index) => {
- if (item.headElement.classList.contains("item--pin") ||
- item.headElement.classList.contains("item--focus") ||
- index === oldFocusIndex) {
+ if (item.headElement.classList.contains("item--pin") || item.headElement.classList.contains("item--focus")) {
return;
}
+ removeCount++;
if (!openTime) {
openTime = item.headElement.getAttribute("data-activetime");
removeId = this.children[index].id;
@@ -666,7 +659,11 @@ export class Wnd {
}
});
if (removeId) {
- this.removeTab(removeId);
+ this.removeTab(removeId, false, false, isSaveLayout);
+ removeCount--;
+ }
+ if (removeCount > 0 && this.children.length > window.siyuan.config.fileTree.maxOpenTabCount) {
+ this.removeOverCounter(isSaveLayout);
}
}