From c89b4971dacd47548822e34e7c85716f35e816d8 Mon Sep 17 00:00:00 2001 From: Vanessa Date: Wed, 28 Jan 2026 11:40:42 +0800 Subject: [PATCH] :art: https://github.com/siyuan-note/siyuan/issues/16879 --- app/src/boot/globalEvent/command/global.ts | 126 +++++++++++++-------- 1 file changed, 78 insertions(+), 48 deletions(-) diff --git a/app/src/boot/globalEvent/command/global.ts b/app/src/boot/globalEvent/command/global.ts index 89fd97b25..409a47e65 100644 --- a/app/src/boot/globalEvent/command/global.ts +++ b/app/src/boot/globalEvent/command/global.ts @@ -41,6 +41,7 @@ import {syncGuide} from "../../../sync/syncGuide"; import {Wnd} from "../../../layout/Wnd"; import {unsplitWnd} from "../../../menus/tab"; import {openFile} from "../../../editor/util"; +import {fetchPost} from "../../../util/fetch"; export const globalCommand = (command: string, app: App) => { /// #if MOBILE @@ -153,59 +154,88 @@ export const globalCommand = (command: string, app: App) => { if (window.siyuan.closedTabs.length > 0) { const closeData = window.siyuan.closedTabs.pop(); const childData = closeData.children as ILayoutJSON; - if (childData.instance === "Editor") { - openFile({ - app, - fileName: closeData.title, - id: childData.blockId, - rootID: childData.rootId, - mode: childData.mode, - rootIcon: closeData.docIcon, - action: [childData.action] - }); - } else if (childData.instance === "Asset") { - openFile({ - app, - assetPath: childData.path, - page: childData.page, - }); - } else if (childData.instance === "Backlink") { - openBacklink({ - app, - blockId: childData.blockId, - rootId: childData.rootId, - title: closeData.title, - }); - } else if (childData.instance === "Graph") { - openGraph({ - app, - blockId: childData.blockId, - rootId: childData.rootId, - title: closeData.title - }); - } else if (childData.instance === "Outline") { - openOutline({ - app, - rootId: childData.blockId, - title: closeData.title, - isPreview: childData.isPreview - }); - } else if (childData.instance === "Search") { + if (childData.instance === "Search") { openFile({ app, searchData: childData.config, }); - } else if (childData.instance === "Custom") { - openFile({ - app, - custom: { - icon: closeData.icon, - title: closeData.title, - data: childData.customModelData, - id: childData.customModelType - }, - }); + return true; } + if (childData.instance === "Asset") { + fetchPost("/api/asset/statAsset", {path: childData.path}, (response) => { + if (response.code !== 1) { + openFile({ + app, + assetPath: childData.path, + page: childData.page, + }); + } + }); + return true; + } + if (childData.instance === "Custom") { + let exit = childData.customModelType === "siyuan-card"; + if (!exit) { + app.plugins.find(p => { + if (p.models[childData.customModelType]) { + exit = true; + return true; + } + }); + } + if (exit) { + openFile({ + app, + custom: { + icon: closeData.icon, + title: closeData.title, + data: childData.customModelData, + id: childData.customModelType + }, + }); + } + return true; + } + fetchPost("/api/block/checkBlockExist", {id: childData.rootId || childData.blockId}, (response) => { + if (response.data) { + fetchPost("/api/block/getBlockInfo", {id: childData.rootId || childData.blockId}, (infoResponse) => { + if (infoResponse.data.rootID === (childData.rootId || childData.blockId)) { + if (childData.instance === "Editor") { + openFile({ + app, + fileName: closeData.title, + id: childData.blockId, + rootID: childData.rootId, + mode: childData.mode, + rootIcon: closeData.docIcon, + action: [childData.action] + }); + } else if (childData.instance === "Backlink") { + openBacklink({ + app, + blockId: childData.blockId, + rootId: childData.rootId, + title: closeData.title, + }); + } else if (childData.instance === "Graph") { + openGraph({ + app, + blockId: childData.blockId, + rootId: childData.rootId, + title: closeData.title + }); + } else if (childData.instance === "Outline") { + openOutline({ + app, + rootId: childData.blockId, + title: closeData.title, + isPreview: childData.isPreview + }); + } + } + }); + } + }); } return true; case "toggleDock":