🎨 add @electron/remote dependency (#9381)

This commit is contained in:
Yingyi / 颖逸 2023-10-09 21:51:39 +08:00 committed by GitHub
parent da0fa0853f
commit ff6220abaa
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 24 additions and 71 deletions

View file

@ -20,6 +20,8 @@ const {
const path = require("path");
const fs = require("fs");
const gNet = require("net");
const remote = require('@electron/remote/main');
process.noAsar = true;
const appDir = path.dirname(app.getAppPath());
const isDevEnv = process.env.NODE_ENV === "development";
@ -32,6 +34,8 @@ let workspaces = []; // workspaceDir, id, browserWindow, tray
let kernelPort = 6806;
let resetWindowStateOnRestart = false;
remote.initialize();
if (!app.requestSingleInstanceLock()) {
app.quit();
return;
@ -278,6 +282,8 @@ const boot = () => {
titleBarStyle: "hidden",
icon: path.join(appDir, "stage", "icon-large.png"),
});
remote.enable(currentWindow.webContents);
windowStateInitialized ? currentWindow.setPosition(x, y) : currentWindow.center();
currentWindow.webContents.userAgent = "SiYuan/" + appVer + " https://b3log.org/siyuan Electron " + currentWindow.webContents.userAgent;
@ -881,6 +887,8 @@ app.whenReady().then(() => {
autoplayPolicy: "user-gesture-required" // 桌面端禁止自动播放多媒体 https://github.com/siyuan-note/siyuan/issues/7587
},
});
remote.enable(win.webContents);
if (data.position) {
win.setPosition(data.position.x, data.position.y);
} else {