瀏覽代碼

:bug: fix https://github.com/siyuan-note/siyuan/issues/9937

Vanessa 1 年之前
父節點
當前提交
ffc9164e08
共有 4 個文件被更改,包括 11 次插入7 次删除
  1. 7 3
      app/src/layout/Wnd.ts
  2. 2 2
      app/src/layout/dock/index.ts
  3. 1 1
      app/src/layout/util.ts
  4. 1 1
      app/src/protyle/util/onGet.ts

+ 7 - 3
app/src/layout/Wnd.ts

@@ -403,7 +403,7 @@ export class Wnd {
         }
     }
 
-    public switchTab(target: HTMLElement, pushBack = false, update = true, resize = true) {
+    public switchTab(target: HTMLElement, pushBack = false, update = true, resize = true, isSaveLayout = true) {
         let currentTab: Tab;
         this.children.forEach((item) => {
             if (target === item.headElement) {
@@ -431,7 +431,9 @@ export class Wnd {
             if (initData) {
                 currentTab.addModel(newModelByInitData(this.app, currentTab, JSON.parse(initData)));
                 currentTab.headElement.removeAttribute("data-initdata");
-                saveLayout();
+                if (isSaveLayout) {
+                    saveLayout();
+                }
                 return;
             }
         }
@@ -492,7 +494,9 @@ export class Wnd {
                 resize,
             });
         }
-        saveLayout();
+        if (isSaveLayout) {
+            saveLayout();
+        }
     }
 
     public addTab(tab: Tab, keepCursor = false, isSaveLayout = true) {

+ 2 - 2
app/src/layout/dock/index.ts

@@ -365,8 +365,8 @@ export class Dock {
             if ((type === "graph" || type === "globalGraph") && this.layout.element.querySelector(".fullscreen")) {
                 document.getElementById("drag")?.classList.remove("fn__hidden");
             }
-            // 关闭 dock 后设置光标
-            if (!document.querySelector(".layout__center .layout__wnd--active")) {
+            // 关闭 dock 后设置光标,初始化的时候不能设置,否则关闭文档树且多页签时会请求两次 getDoc
+            if (saveLayout && !document.querySelector(".layout__center .layout__wnd--active")) {
                 const currentElement = document.querySelector(".layout__center ul.layout-tab-bar .item--focus");
                 if (currentElement) {
                     getAllTabs().find(item => {

+ 1 - 1
app/src/layout/util.ts

@@ -474,7 +474,7 @@ export const JSONToLayout = (app: App, isStart: boolean) => {
         document.querySelectorAll('li[data-type="tab-header"][data-init-active="true"]').forEach((item: HTMLElement) => {
             item.removeAttribute("data-init-active");
             const tab = getInstanceById(item.getAttribute("data-id")) as Tab;
-            tab.parent.switchTab(item, false, false);
+            tab.parent.switchTab(item, false, false, true, false);
         });
     }
     resizeTopBar();

+ 1 - 1
app/src/protyle/util/onGet.ts

@@ -247,7 +247,7 @@ const setHTML = (options: {
             onGet({data: getResponse, protyle, action: [Constants.CB_GET_APPEND, Constants.CB_GET_UNCHANGEID]});
         });
     }
-    if (options.scrollAttr && !protyle.scroll.element.classList.contains("fn__none")) {
+    if (options.scrollAttr && !protyle.scroll.element.classList.contains("fn__none") && !protyle.element.classList.contains("fn__none")) {
         // 使用动态滚动条定位到最后一个块,重启后无法触发滚动事件,需要再次更新 index
         protyle.scroll.updateIndex(protyle, options.scrollAttr.startId);
         // https://github.com/siyuan-note/siyuan/issues/8224