mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-02-11 09:44:21 +01:00
This commit is contained in:
parent
d1009f2333
commit
60beaf291d
3 changed files with 94 additions and 35 deletions
|
|
@ -6,6 +6,8 @@ import {Constants} from "../constants";
|
|||
import {Tab} from "../layout/Tab";
|
||||
import {fetchPost} from "../util/fetch";
|
||||
import {showMessage} from "../dialog/message";
|
||||
import {getDisplayName, pathPosix} from "../util/pathName";
|
||||
import {getSearch} from "../util/functions";
|
||||
|
||||
interface windowOptions {
|
||||
position?: {
|
||||
|
|
@ -62,5 +64,39 @@ export const openNewWindowById = (id: string, options: windowOptions = {}) => {
|
|||
});
|
||||
/// #endif
|
||||
});
|
||||
|
||||
};
|
||||
|
||||
export const openAssetNewWindow = (assetPath: string, options: windowOptions = {}) => {
|
||||
/// #if !BROWSER
|
||||
const suffix = pathPosix().extname(assetPath.split("?page")[0]);
|
||||
if (Constants.SIYUAN_ASSETS_EXTS.includes(suffix)) {
|
||||
let docIcon = "iconPDF";
|
||||
if (Constants.SIYUAN_ASSETS_IMAGE.includes(suffix)) {
|
||||
docIcon = "iconImage";
|
||||
} else if (Constants.SIYUAN_ASSETS_AUDIO.includes(suffix)) {
|
||||
docIcon = "iconRecord";
|
||||
} else if (Constants.SIYUAN_ASSETS_VIDEO.includes(suffix)) {
|
||||
docIcon = "iconVideo";
|
||||
}
|
||||
const json: any = {
|
||||
title: getDisplayName(assetPath),
|
||||
docIcon,
|
||||
pin: false,
|
||||
active: true,
|
||||
instance: "Tab",
|
||||
action: "Tab",
|
||||
children: {
|
||||
path: assetPath,
|
||||
page: parseInt(getSearch("page", assetPath)),
|
||||
instance: "Asset",
|
||||
}
|
||||
};
|
||||
ipcRenderer.send(Constants.SIYUAN_OPEN_WINDOW, {
|
||||
position: options.position,
|
||||
width: options.width,
|
||||
height: options.height,
|
||||
url: `${window.location.protocol}//${window.location.host}/stage/build/app/window.html?v=${Constants.SIYUAN_VERSION}&json=${encodeURIComponent(JSON.stringify(json))}`
|
||||
});
|
||||
}
|
||||
/// #endif
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue