From 3be88c7b9fcdcac675d4f103698b74df36d2ac42 Mon Sep 17 00:00:00 2001 From: Vanessa Date: Wed, 28 Jan 2026 19:15:18 +0800 Subject: [PATCH] :art: https://github.com/siyuan-note/siyuan/issues/16879 --- app/src/boot/globalEvent/command/global.ts | 6 ++++-- app/src/constants.ts | 1 + app/src/layout/Wnd.ts | 9 +++++---- app/src/protyle/util/compatibility.ts | 4 +++- 4 files changed, 13 insertions(+), 7 deletions(-) diff --git a/app/src/boot/globalEvent/command/global.ts b/app/src/boot/globalEvent/command/global.ts index 753a6439c..ccd6de44e 100644 --- a/app/src/boot/globalEvent/command/global.ts +++ b/app/src/boot/globalEvent/command/global.ts @@ -42,6 +42,7 @@ import {Wnd} from "../../../layout/Wnd"; import {unsplitWnd} from "../../../menus/tab"; import {openFile} from "../../../editor/util"; import {fetchPost} from "../../../util/fetch"; +import {setStorageVal} from "../../../protyle/util/compatibility"; export const globalCommand = (command: string, app: App) => { /// #if MOBILE @@ -151,8 +152,9 @@ export const globalCommand = (command: string, app: App) => { openRecentDocs(); return true; case "recentClosed": - if (window.siyuan.closedTabs.length > 0) { - const closeData = window.siyuan.closedTabs.pop(); + if (window.siyuan.storage[Constants.LOCAL_CLOSED_TABS].length > 0) { + const closeData = window.siyuan.storage[Constants.LOCAL_CLOSED_TABS].pop(); + setStorageVal(Constants.LOCAL_CLOSED_TABS, window.siyuan.storage[Constants.LOCAL_CLOSED_TABS]); const childData = closeData.children as ILayoutJSON; if (childData.instance === "Search") { openFile({ diff --git a/app/src/constants.ts b/app/src/constants.ts index 421bcc222..40cff2d3f 100644 --- a/app/src/constants.ts +++ b/app/src/constants.ts @@ -168,6 +168,7 @@ export abstract class Constants { public static readonly LOCAL_EMOJIS = "local-emojis"; public static readonly LOCAL_MOVE_PATH = "local-move-path"; public static readonly LOCAL_RECENT_DOCS = "local-recent-docs"; + public static readonly LOCAL_CLOSED_TABS = "local-closed-tabs"; // dialog public static readonly DIALOG_CONFIRM = "dialog-confirm"; diff --git a/app/src/layout/Wnd.ts b/app/src/layout/Wnd.ts index 489b1f09b..c5f0885f0 100644 --- a/app/src/layout/Wnd.ts +++ b/app/src/layout/Wnd.ts @@ -52,6 +52,7 @@ import {setPadding} from "../protyle/ui/initUI"; import {setPosition} from "../util/setPosition"; import {clearOBG} from "./dock/util"; import {recordBeforeResizeTop} from "../protyle/util/resize"; +import {setStorageVal} from "../protyle/util/compatibility"; export class Wnd { private app: App; @@ -783,13 +784,13 @@ export class Wnd { clearCounter(); this.children.find((item, index) => { if (item.id === id) { - if (window.siyuan.closedTabs.length > Constants.SIZE_UNDO) { - window.siyuan.closedTabs.pop(); + if (window.siyuan.storage[Constants.LOCAL_CLOSED_TABS].length > Constants.SIZE_UNDO) { + window.siyuan.storage[Constants.LOCAL_CLOSED_TABS].pop(); } const tabJSON = {}; layoutToJSON(item, tabJSON); - window.siyuan.closedTabs.push(tabJSON); - + window.siyuan.storage[Constants.LOCAL_CLOSED_TABS].push(tabJSON); + setStorageVal(Constants.LOCAL_CLOSED_TABS, window.siyuan.storage[Constants.LOCAL_CLOSED_TABS]); if (item.model instanceof Custom && item.model.beforeDestroy) { item.model.beforeDestroy(); } diff --git a/app/src/protyle/util/compatibility.ts b/app/src/protyle/util/compatibility.ts index fdfaa0a4d..610f4a318 100644 --- a/app/src/protyle/util/compatibility.ts +++ b/app/src/protyle/util/compatibility.ts @@ -467,6 +467,7 @@ export const getLocalStorage = (cb: () => void) => { currentTab: "emoji" }; defaultStorage[Constants.LOCAL_FONTSTYLES] = []; + defaultStorage[Constants.LOCAL_CLOSED_TABS] = []; defaultStorage[Constants.LOCAL_FILESPATHS] = []; // IFilesPath[] defaultStorage[Constants.LOCAL_SEARCHDATA] = { removed: true, @@ -506,7 +507,8 @@ export const getLocalStorage = (cb: () => void) => { Constants.LOCAL_PLUGINTOPUNPIN, Constants.LOCAL_SEARCHASSET, Constants.LOCAL_FLASHCARD, Constants.LOCAL_DIALOGPOSITION, Constants.LOCAL_SEARCHUNREF, Constants.LOCAL_HISTORY, Constants.LOCAL_OUTLINE, Constants.LOCAL_FILEPOSITION, Constants.LOCAL_FILESPATHS, Constants.LOCAL_IMAGES, - Constants.LOCAL_PLUGIN_DOCKS, Constants.LOCAL_EMOJIS, Constants.LOCAL_MOVE_PATH, Constants.LOCAL_RECENT_DOCS].forEach((key) => { + Constants.LOCAL_PLUGIN_DOCKS, Constants.LOCAL_EMOJIS, Constants.LOCAL_MOVE_PATH, Constants.LOCAL_RECENT_DOCS, + Constants.LOCAL_CLOSED_TABS].forEach((key) => { if (typeof response.data[key] === "string") { try { const parseData = JSON.parse(response.data[key]);