Преглед изворни кода

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

Vanessa пре 1 година
родитељ
комит
1e98e25801
1 измењених фајлова са 10 додато и 13 уклоњено
  1. 10 13
      app/src/layout/Wnd.ts

+ 10 - 13
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) {
         if (this.parent.type === "center" && this.children.length === 2 && !this.children[0].headElement) {
             this.removeTab(this.children[0].id);
             this.removeTab(this.children[0].id);
         } else if (this.children.length > window.siyuan.config.fileTree.maxOpenTabCount) {
         } else if (this.children.length > window.siyuan.config.fileTree.maxOpenTabCount) {
-            this.removeOverCounter(oldFocusIndex);
+            this.removeOverCounter(isSaveLayout);
         }
         }
         /// #if !BROWSER
         /// #if !BROWSER
         setTabPosition();
         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 removeId: string;
         let openTime: string;
         let openTime: string;
+        let removeCount = 0
         this.children.forEach((item, index) => {
         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;
                 return;
             }
             }
+            removeCount++;
             if (!openTime) {
             if (!openTime) {
                 openTime = item.headElement.getAttribute("data-activetime");
                 openTime = item.headElement.getAttribute("data-activetime");
                 removeId = this.children[index].id;
                 removeId = this.children[index].id;
@@ -666,7 +659,11 @@ export class Wnd {
             }
             }
         });
         });
         if (removeId) {
         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);
         }
         }
     }
     }