diff --git a/app/src/constants.ts b/app/src/constants.ts index 917304a18..20fdcfb8c 100644 --- a/app/src/constants.ts +++ b/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; diff --git a/app/src/layout/util.ts b/app/src/layout/util.ts index 39c620cc7..419ca7a45 100644 --- a/app/src/layout/util.ts +++ b/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);