mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-16 22:50:13 +01:00
This commit is contained in:
parent
a20958272f
commit
019951cbf5
1 changed files with 14 additions and 16 deletions
|
|
@ -64,6 +64,17 @@ try {
|
||||||
app.exit();
|
app.exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const windowNavigate = (currentWindow) => {
|
||||||
|
currentWindow.webContents.on("will-navigate", (event) => {
|
||||||
|
const url = event.url;
|
||||||
|
if (url.startsWith(localServer)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
event.preventDefault();
|
||||||
|
shell.openExternal(url);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
const setProxy = (proxyURL, webContents) => {
|
const setProxy = (proxyURL, webContents) => {
|
||||||
if (proxyURL.startsWith("://")) {
|
if (proxyURL.startsWith("://")) {
|
||||||
console.log("network proxy [system]");
|
console.log("network proxy [system]");
|
||||||
|
|
@ -403,15 +414,7 @@ const boot = () => {
|
||||||
const menu = Menu.buildFromTemplate(template);
|
const menu = Menu.buildFromTemplate(template);
|
||||||
Menu.setApplicationMenu(menu);
|
Menu.setApplicationMenu(menu);
|
||||||
// 当前页面链接使用浏览器打开
|
// 当前页面链接使用浏览器打开
|
||||||
currentWindow.webContents.on("will-navigate", (event) => {
|
windowNavigate(currentWindow);
|
||||||
const url = event.url;
|
|
||||||
if (url.startsWith(localServer)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
event.preventDefault();
|
|
||||||
shell.openExternal(url);
|
|
||||||
});
|
|
||||||
|
|
||||||
currentWindow.on("close", (event) => {
|
currentWindow.on("close", (event) => {
|
||||||
if (currentWindow && !currentWindow.isDestroyed()) {
|
if (currentWindow && !currentWindow.isDestroyed()) {
|
||||||
currentWindow.webContents.send("siyuan-save-close", false);
|
currentWindow.webContents.send("siyuan-save-close", false);
|
||||||
|
|
@ -956,13 +959,7 @@ app.whenReady().then(() => {
|
||||||
printWin.center();
|
printWin.center();
|
||||||
printWin.webContents.userAgent = "SiYuan/" + appVer + " https://b3log.org/siyuan Electron " + printWin.webContents.userAgent;
|
printWin.webContents.userAgent = "SiYuan/" + appVer + " https://b3log.org/siyuan Electron " + printWin.webContents.userAgent;
|
||||||
printWin.loadURL(data);
|
printWin.loadURL(data);
|
||||||
printWin.webContents.on("will-navigate", (nEvent) => {
|
windowNavigate(printWin);
|
||||||
nEvent.preventDefault();
|
|
||||||
if (nEvent.url.startsWith(localServer)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
shell.openExternal(nEvent.url);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
ipcMain.on("siyuan-quit", (event, port) => {
|
ipcMain.on("siyuan-quit", (event, port) => {
|
||||||
exitApp(port);
|
exitApp(port);
|
||||||
|
|
@ -1000,6 +997,7 @@ app.whenReady().then(() => {
|
||||||
win.webContents.userAgent = "SiYuan/" + appVer + " https://b3log.org/siyuan Electron " + win.webContents.userAgent;
|
win.webContents.userAgent = "SiYuan/" + appVer + " https://b3log.org/siyuan Electron " + win.webContents.userAgent;
|
||||||
win.webContents.session.setSpellCheckerLanguages(["en-US"]);
|
win.webContents.session.setSpellCheckerLanguages(["en-US"]);
|
||||||
win.loadURL(data.url);
|
win.loadURL(data.url);
|
||||||
|
windowNavigate(win);
|
||||||
win.on("close", (event) => {
|
win.on("close", (event) => {
|
||||||
if (win && !win.isDestroyed()) {
|
if (win && !win.isDestroyed()) {
|
||||||
win.webContents.send("siyuan-save-close");
|
win.webContents.send("siyuan-save-close");
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue