Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:art: https://github.com/siyuan-note/siyuan/issues/16879

Vanessac89b4971dacd
diff --git a/app/src/boot/globalEvent/command/global.ts b/app/src/boot/globalEvent/command/global.ts
index 89fd97b25d..409a47e654 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":