Vanessa 2024-02-28 23:12:49 +08:00
parent af03c658f0
commit 1e98e25801

View file

@ -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);
}
}