mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-16 14:40:12 +01:00
This commit is contained in:
parent
6f58d1387f
commit
e949458180
3 changed files with 6 additions and 11 deletions
|
|
@ -696,7 +696,7 @@ app.whenReady().then(() => {
|
|||
exitApp(port);
|
||||
});
|
||||
ipcMain.on("siyuan-open-window", (event, data) => {
|
||||
const mainWindow = BrowserWindow.fromId(data.id);
|
||||
const mainWindow = BrowserWindow.getFocusedWindow() || BrowserWindow.getAllWindows()[0];
|
||||
const mainBounds = mainWindow.getBounds();
|
||||
const mainScreen = screen.getDisplayNearestPoint({x: mainBounds.x, y: mainBounds.y});
|
||||
const win = new BrowserWindow({
|
||||
|
|
@ -753,9 +753,9 @@ app.whenReady().then(() => {
|
|||
});
|
||||
}
|
||||
});
|
||||
ipcMain.on("siyuan-init", async (event, data) => {
|
||||
ipcMain.handle("siyuan-init", async (event, data) => {
|
||||
const exitWS = workspaces.find(item => {
|
||||
if (data.id === item.id && item.workspaceDir) {
|
||||
if (event.sender.id === item.browserWindow.webContents.id && item.workspaceDir) {
|
||||
if (item.tray && "win32" === process.platform || "linux" === process.platform) {
|
||||
// Tray menu text does not change with the appearance language https://github.com/siyuan-note/siyuan/issues/7935
|
||||
resetTrayMenu(item.tray, data.languages, item.browserWindow);
|
||||
|
|
@ -771,14 +771,14 @@ app.whenReady().then(() => {
|
|||
// 系统托盘
|
||||
tray = new Tray(path.join(appDir, "stage", "icon-large.png"));
|
||||
tray.setToolTip(`${path.basename(data.workspaceDir)} - SiYuan v${appVer}`);
|
||||
const mainWindow = BrowserWindow.fromId(data.id);
|
||||
const mainWindow = BrowserWindow.fromId(BrowserWindow.getAllWindows().find((win) => win.webContents.id === event.sender.id).id);
|
||||
resetTrayMenu(tray, data.languages, mainWindow);
|
||||
tray.on("click", () => {
|
||||
showHideWindow(tray, data.languages, mainWindow);
|
||||
});
|
||||
}
|
||||
workspaces.find(item => {
|
||||
if (data.id === item.id) {
|
||||
if (!item.workspaceDir) {
|
||||
item.workspaceDir = data.workspaceDir;
|
||||
item.tray = tray;
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -111,10 +111,9 @@ export const onGetConfig = (isStart: boolean, app: App) => {
|
|||
});
|
||||
}
|
||||
/// #if !BROWSER
|
||||
ipcRenderer.send(Constants.SIYUAN_INIT, {
|
||||
ipcRenderer.invoke(Constants.SIYUAN_INIT, {
|
||||
languages: window.siyuan.languages["_trayMenu"],
|
||||
workspaceDir: window.siyuan.config.system.workspaceDir,
|
||||
id: getCurrentWindow().id,
|
||||
port: location.port
|
||||
});
|
||||
webFrame.setZoomFactor(window.siyuan.storage[Constants.LOCAL_ZOOM]);
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
import {layoutToJSON} from "../layout/util";
|
||||
/// #if !BROWSER
|
||||
import {ipcRenderer} from "electron";
|
||||
import {getCurrentWindow} from "@electron/remote";
|
||||
/// #endif
|
||||
import {Constants} from "../constants";
|
||||
import {Tab} from "../layout/Tab";
|
||||
|
|
@ -25,7 +24,6 @@ export const openNewWindow = (tab: Tab, options: windowOptions = {}) => {
|
|||
position: options.position,
|
||||
width: options.width,
|
||||
height: options.height,
|
||||
id: getCurrentWindow().id,
|
||||
// 需要 encode, 否则 https://github.com/siyuan-note/siyuan/issues/9343
|
||||
url: `${window.location.protocol}//${window.location.host}/stage/build/app/window.html?v=${Constants.SIYUAN_VERSION}&json=${encodeURIComponent(JSON.stringify(json))}`
|
||||
});
|
||||
|
|
@ -66,7 +64,6 @@ export const openNewWindowById = (id: string, options: windowOptions = {}) => {
|
|||
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=${encodeURIComponent(JSON.stringify(json))}`
|
||||
});
|
||||
/// #endif
|
||||
|
|
@ -81,7 +78,6 @@ export const openNewWindowById = (id: string, options: windowOptions = {}) => {
|
|||
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=${encodeURIComponent(JSON.stringify(json))}`
|
||||
});
|
||||
/// #endif
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue