mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-02-08 00:04:21 +01:00
This commit is contained in:
parent
a77e0820ad
commit
c89b4971da
1 changed files with 78 additions and 48 deletions
|
|
@ -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":
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue