This commit is contained in:
Vanessa 2022-07-25 16:13:28 +08:00
parent 2476cb4ccd
commit fa30244e3e

View file

@ -430,10 +430,24 @@ 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);
}
}
private removeOverCounter(oldFocusIndex?: number) {
if (typeof oldFocusIndex === "undefined") {
this.children.forEach((item, index) => {
if (item.headElement && item.headElement.classList.contains("item--focus")) {
oldFocusIndex = index;
}
});
}
let removeId: string;
let openTime: string;
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") ||
index === oldFocusIndex) {
return;
}
if (!openTime) {
@ -448,7 +462,6 @@ export class Wnd {
this.removeTab(removeId);
}
}
}
private destroyModel(model: Model) {
if (!model) {
@ -518,12 +531,15 @@ export class Wnd {
return true;
}
});
// 初始化移除窗口,但 centerLayout 还没有赋值 https://ld246.com/article/1658718634416
if (window.siyuan.layout.centerLayout) {
const wnd = getWndByLayout(window.siyuan.layout.centerLayout);
if (!wnd) {
const wnd = new Wnd();
window.siyuan.layout.centerLayout.addWnd(wnd);
wnd.addTab(newCenterEmptyTab());
}
}
/// #if !BROWSER
webFrame.clearCache();
getCurrentWindow().webContents.session.clearCache();
@ -565,6 +581,9 @@ export class Wnd {
} else {
this.children.push(tab);
}
if (this.children.length > window.siyuan.config.fileTree.maxOpenTabCount) {
this.removeOverCounter();
}
this.switchTab(tab.headElement);
const oldWnd = tab.parent;