mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-18 15:40:12 +01:00
This commit is contained in:
parent
91096274c7
commit
c8e64a8bbb
3 changed files with 27 additions and 8 deletions
|
|
@ -736,12 +736,15 @@ app.whenReady().then(() => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
ipcMain.on("siyuan-openwindow", (event, data) => {
|
ipcMain.on("siyuan-openwindow", (event, data) => {
|
||||||
|
const mainWindow = BrowserWindow.fromId(data.id);
|
||||||
|
const mainBounds = mainWindow.getBounds();
|
||||||
|
const mainScreen = screen.getDisplayNearestPoint({x: mainBounds.x, y: mainBounds.y});
|
||||||
const win = new BrowserWindow({
|
const win = new BrowserWindow({
|
||||||
show: true,
|
show: true,
|
||||||
backgroundColor: "#FFF",
|
backgroundColor: "#FFF",
|
||||||
trafficLightPosition: {x: 8, y: 13},
|
trafficLightPosition: {x: 8, y: 13},
|
||||||
width: screen.getPrimaryDisplay().size.width * 0.7,
|
width: mainScreen.size.width * 0.7,
|
||||||
height: screen.getPrimaryDisplay().size.height * 0.9,
|
height: mainScreen.size.height * 0.9,
|
||||||
minWidth: 493,
|
minWidth: 493,
|
||||||
minHeight: 376,
|
minHeight: 376,
|
||||||
fullscreenable: true,
|
fullscreenable: true,
|
||||||
|
|
@ -755,7 +758,11 @@ app.whenReady().then(() => {
|
||||||
webSecurity: false,
|
webSecurity: false,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
win.loadURL(data);
|
win.loadURL(data.url);
|
||||||
|
const targetScreen = screen.getDisplayNearestPoint(screen.getCursorScreenPoint())
|
||||||
|
if (mainScreen.id !== targetScreen.id) {
|
||||||
|
win.setBounds(targetScreen.workArea)
|
||||||
|
}
|
||||||
require("@electron/remote/main").enable(win.webContents);
|
require("@electron/remote/main").enable(win.webContents);
|
||||||
});
|
});
|
||||||
ipcMain.on("siyuan-open-workspace", (event, data) => {
|
ipcMain.on("siyuan-open-workspace", (event, data) => {
|
||||||
|
|
|
||||||
|
|
@ -2,14 +2,16 @@ import {Constants} from "../constants";
|
||||||
import {fetchPost} from "../util/fetch";
|
import {fetchPost} from "../util/fetch";
|
||||||
/// #if !MOBILE
|
/// #if !MOBILE
|
||||||
import {getAllModels} from "../layout/getAll";
|
import {getAllModels} from "../layout/getAll";
|
||||||
import {ipcRenderer} from "electron";
|
|
||||||
import {exportLayout} from "../layout/util";
|
import {exportLayout} from "../layout/util";
|
||||||
/// #endif
|
/// #endif
|
||||||
|
/// #if !BROWSER
|
||||||
|
import {ipcRenderer} from "electron";
|
||||||
|
import {getCurrentWindow} from "@electron/remote";
|
||||||
|
/// #endif
|
||||||
import {hideMessage, showMessage} from "./message";
|
import {hideMessage, showMessage} from "./message";
|
||||||
import {Dialog} from "./index";
|
import {Dialog} from "./index";
|
||||||
import {isMobile} from "../util/functions";
|
import {isMobile} from "../util/functions";
|
||||||
import {confirmDialog} from "./confirmDialog";
|
import {confirmDialog} from "./confirmDialog";
|
||||||
import {getCurrentWindow} from "@electron/remote";
|
|
||||||
import {escapeHtml} from "../util/escape";
|
import {escapeHtml} from "../util/escape";
|
||||||
import {getWorkspaceName} from "../util/noRelyPCFunction";
|
import {getWorkspaceName} from "../util/noRelyPCFunction";
|
||||||
import {needSubscribe} from "../util/needSubscribe";
|
import {needSubscribe} from "../util/needSubscribe";
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
import {layoutToJSON} from "../layout/util";
|
import {layoutToJSON} from "../layout/util";
|
||||||
/// #if !BROWSER
|
/// #if !BROWSER
|
||||||
import {ipcRenderer} from "electron";
|
import {ipcRenderer} from "electron";
|
||||||
|
import {getCurrentWindow} from "@electron/remote";
|
||||||
/// #endif
|
/// #endif
|
||||||
import {Constants} from "../constants";
|
import {Constants} from "../constants";
|
||||||
import {Tab} from "../layout/Tab";
|
import {Tab} from "../layout/Tab";
|
||||||
|
|
@ -12,7 +13,10 @@ export const openNewWindow = (tab: Tab) => {
|
||||||
const json = {};
|
const json = {};
|
||||||
layoutToJSON(tab, json);
|
layoutToJSON(tab, json);
|
||||||
/// #if !BROWSER
|
/// #if !BROWSER
|
||||||
ipcRenderer.send(Constants.SIYUAN_OPENWINDOW, `${window.location.protocol}//${window.location.host}/stage/build/app/window.html?v=${Constants.SIYUAN_VERSION}&json=${JSON.stringify(json)}`);
|
ipcRenderer.send(Constants.SIYUAN_OPENWINDOW, {
|
||||||
|
id: getCurrentWindow().id,
|
||||||
|
url: `${window.location.protocol}//${window.location.host}/stage/build/app/window.html?v=${Constants.SIYUAN_VERSION}&json=${JSON.stringify(json)}`
|
||||||
|
});
|
||||||
/// #endif
|
/// #endif
|
||||||
tab.parent.removeTab(tab.id);
|
tab.parent.removeTab(tab.id);
|
||||||
};
|
};
|
||||||
|
|
@ -47,7 +51,10 @@ export const openNewWindowById = (id: string) => {
|
||||||
fetchPost("/api/attr/getBlockAttrs", {id}, (attrResponse) => {
|
fetchPost("/api/attr/getBlockAttrs", {id}, (attrResponse) => {
|
||||||
json.children.scrollAttr = JSON.parse(attrResponse.data.scroll || "{}");
|
json.children.scrollAttr = JSON.parse(attrResponse.data.scroll || "{}");
|
||||||
/// #if !BROWSER
|
/// #if !BROWSER
|
||||||
ipcRenderer.send(Constants.SIYUAN_OPENWINDOW, `${window.location.protocol}//${window.location.host}/stage/build/app/window.html?v=${Constants.SIYUAN_VERSION}&json=${JSON.stringify(json)}`);
|
ipcRenderer.send(Constants.SIYUAN_OPENWINDOW, {
|
||||||
|
id: getCurrentWindow().id,
|
||||||
|
url: `${window.location.protocol}//${window.location.host}/stage/build/app/window.html?v=${Constants.SIYUAN_VERSION}&json=${JSON.stringify(json)}`
|
||||||
|
});
|
||||||
/// #endif
|
/// #endif
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -61,7 +68,10 @@ export const openNewWindowById = (id: string) => {
|
||||||
focusEnd: 0
|
focusEnd: 0
|
||||||
};
|
};
|
||||||
/// #if !BROWSER
|
/// #if !BROWSER
|
||||||
ipcRenderer.send(Constants.SIYUAN_OPENWINDOW, `${window.location.protocol}//${window.location.host}/stage/build/app/window.html?v=${Constants.SIYUAN_VERSION}&json=${JSON.stringify(json)}`);
|
ipcRenderer.send(Constants.SIYUAN_OPENWINDOW, {
|
||||||
|
id: getCurrentWindow().id,
|
||||||
|
url: `${window.location.protocol}//${window.location.host}/stage/build/app/window.html?v=${Constants.SIYUAN_VERSION}&json=${JSON.stringify(json)}`
|
||||||
|
});
|
||||||
/// #endif
|
/// #endif
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue