mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-01-26 18:26:09 +01:00
This commit is contained in:
parent
f54705e151
commit
336eaef000
3 changed files with 35 additions and 7 deletions
|
|
@ -27,17 +27,23 @@ openWindow = () => {
|
|||
};
|
||||
/// #else
|
||||
openWindow = (options: {
|
||||
position?: {
|
||||
x: number,
|
||||
y: number,
|
||||
},
|
||||
height?: number,
|
||||
width?: number,
|
||||
tab?: Tab,
|
||||
doc?: {
|
||||
id: string, // 块 id
|
||||
},
|
||||
}) => {
|
||||
if (options.doc.id) {
|
||||
openNewWindowById(options.doc.id);
|
||||
openNewWindowById(options.doc.id, {position: options.position, width: options.width, height: options.height});
|
||||
return;
|
||||
}
|
||||
if (options.tab) {
|
||||
openNewWindow(options.tab)
|
||||
openNewWindow(options.tab, {position: options.position, width: options.width, height: options.height});
|
||||
return;
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -8,11 +8,23 @@ import {Tab} from "../layout/Tab";
|
|||
import {fetchPost} from "../util/fetch";
|
||||
import {showMessage} from "../dialog/message";
|
||||
|
||||
export const openNewWindow = (tab: Tab) => {
|
||||
interface windowOptions {
|
||||
position?: {
|
||||
x: number,
|
||||
y: number,
|
||||
},
|
||||
width?: number,
|
||||
height?: number
|
||||
}
|
||||
|
||||
export const openNewWindow = (tab: Tab, options: windowOptions = {}) => {
|
||||
const json = {};
|
||||
layoutToJSON(tab, json);
|
||||
/// #if !BROWSER
|
||||
ipcRenderer.send(Constants.SIYUAN_OPENWINDOW, {
|
||||
position: options.position,
|
||||
width: options.width,
|
||||
height: options.height,
|
||||
id: getCurrentWindow().id,
|
||||
url: `${window.location.protocol}//${window.location.host}/stage/build/app/window.html?v=${Constants.SIYUAN_VERSION}&json=${JSON.stringify(json)}`
|
||||
});
|
||||
|
|
@ -20,7 +32,7 @@ export const openNewWindow = (tab: Tab) => {
|
|||
tab.parent.removeTab(tab.id);
|
||||
};
|
||||
|
||||
export const openNewWindowById = (id: string) => {
|
||||
export const openNewWindowById = (id: string, options: windowOptions = {}) => {
|
||||
fetchPost("/api/block/getBlockInfo", {id}, (response) => {
|
||||
if (response.code === 3) {
|
||||
showMessage(response.msg);
|
||||
|
|
@ -50,6 +62,9 @@ export const openNewWindowById = (id: string) => {
|
|||
}
|
||||
/// #if !BROWSER
|
||||
ipcRenderer.send(Constants.SIYUAN_OPENWINDOW, {
|
||||
position: options.position,
|
||||
width: options.width,
|
||||
height: options.height,
|
||||
id: getCurrentWindow().id,
|
||||
url: `${window.location.protocol}//${window.location.host}/stage/build/app/window.html?v=${Constants.SIYUAN_VERSION}&json=${JSON.stringify(json)}`
|
||||
});
|
||||
|
|
@ -62,6 +77,9 @@ export const openNewWindowById = (id: string) => {
|
|||
};
|
||||
/// #if !BROWSER
|
||||
ipcRenderer.send(Constants.SIYUAN_OPENWINDOW, {
|
||||
position: options.position,
|
||||
width: options.width,
|
||||
height: options.height,
|
||||
id: getCurrentWindow().id,
|
||||
url: `${window.location.protocol}//${window.location.host}/stage/build/app/window.html?v=${Constants.SIYUAN_VERSION}&json=${JSON.stringify(json)}`
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue