Skip to content

Commit

Permalink
🎨 add @electron/remote dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
Zuoqiu-Yingyi committed Oct 9, 2023
1 parent 9288e52 commit 11bc453
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 71 deletions.
8 changes: 8 additions & 0 deletions app/electron/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -32,6 +34,8 @@ let workspaces = []; // workspaceDir, id, browserWindow, tray
let kernelPort = 6806;
let resetWindowStateOnRestart = false;

remote.initialize();

if (!app.requestSingleInstanceLock()) {
app.quit();
return;
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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 {
Expand Down
3 changes: 3 additions & 0 deletions app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,5 +72,8 @@
"webpack": "^5.76.0",
"webpack-bundle-analyzer": "^4.5.0",
"webpack-cli": "^4.10.0"
},
"dependencies": {
"@electron/remote": "^2.0.12"
}
}
Loading

0 comments on commit 11bc453

Please sign in to comment.