Ver código fonte

:art: fix https://github.com/siyuan-note/siyuan/issues/9855

Vanessa 1 ano atrás
pai
commit
f4e2c3423a
2 arquivos alterados com 20 adições e 6 exclusões
  1. 1 0
      app/src/constants.ts
  2. 19 6
      app/src/layout/util.ts

+ 1 - 0
app/src/constants.ts

@@ -101,6 +101,7 @@ export abstract class Constants {
     public static readonly LOCAL_PLUGINTOPUNPIN = "local-plugintopunpin";
     public static readonly LOCAL_FLASHCARD = "local-flashcard";
     public static readonly LOCAL_FILEPOSITION = "local-fileposition";
+    public static readonly LOCAL_SESSION_FIRSTLOAD = "local-session-firstload";
 
     // timeout
     public static readonly TIMEOUT_DBLCLICK = 190;

+ 19 - 6
app/src/layout/util.ts

@@ -375,12 +375,25 @@ export const JSONToLayout = (app: App, isStart: boolean) => {
     JSONToCenter(app, window.siyuan.config.uiLayout.layout, undefined);
     JSONToDock(window.siyuan.config.uiLayout, app);
     // 启动时不打开页签,需要移除没有钉住的页签
-    if (window.siyuan.config.fileTree.closeTabsOnStart && isStart) {
-        getAllTabs().forEach(item => {
-            if (item.headElement && !item.headElement.classList.contains("item--pin")) {
-                item.parent.removeTab(item.id, false, false);
-            }
-        });
+    if (window.siyuan.config.fileTree.closeTabsOnStart) {
+        /// #if BROWSER
+        if (!sessionStorage.getItem(Constants.LOCAL_SESSION_FIRSTLOAD)) {
+            getAllTabs().forEach(item => {
+                if (item.headElement && !item.headElement.classList.contains("item--pin")) {
+                    item.parent.removeTab(item.id, false, false);
+                }
+            });
+            sessionStorage.setItem(Constants.LOCAL_SESSION_FIRSTLOAD, "true");
+        }
+        /// #else
+        if (isStart) {
+            getAllTabs().forEach(item => {
+                if (item.headElement && !item.headElement.classList.contains("item--pin")) {
+                    item.parent.removeTab(item.id, false, false);
+                }
+            });
+        }
+        /// #endif
     }
     app.plugins.forEach(item => {
         afterLoadPlugin(item);