mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-17 07:00:12 +01:00
This commit is contained in:
parent
bcf05a6d21
commit
e14e8749c9
3 changed files with 15 additions and 10 deletions
|
|
@ -660,6 +660,17 @@ app.whenReady().then(() => {
|
||||||
ipcMain.on('siyuan-export-close', (event, id) => {
|
ipcMain.on('siyuan-export-close', (event, id) => {
|
||||||
BrowserWindow.fromId(id).webContents.send('siyuan-export-close', id)
|
BrowserWindow.fromId(id).webContents.send('siyuan-export-close', id)
|
||||||
})
|
})
|
||||||
|
ipcMain.on('siyuan-export-prevent', (event, id) => {
|
||||||
|
BrowserWindow.fromId(id).webContents.on('will-navigate', (event, url) => {
|
||||||
|
const currentURL = new URL(event.sender.getURL())
|
||||||
|
if (url.startsWith(getServer(currentURL.port))) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
event.preventDefault()
|
||||||
|
shell.openExternal(url)
|
||||||
|
})
|
||||||
|
})
|
||||||
ipcMain.on('siyuan-quit', (event, id) => {
|
ipcMain.on('siyuan-quit', (event, id) => {
|
||||||
const mainWindow = BrowserWindow.fromId(id)
|
const mainWindow = BrowserWindow.fromId(id)
|
||||||
let tray
|
let tray
|
||||||
|
|
|
||||||
|
|
@ -31,6 +31,7 @@ export abstract class Constants {
|
||||||
public static readonly SIYUAN_SAVE_CLOSE: string = "siyuan-save-close";
|
public static readonly SIYUAN_SAVE_CLOSE: string = "siyuan-save-close";
|
||||||
public static readonly SIYUAN_EXPORT_PDF: string = "siyuan-export-pdf";
|
public static readonly SIYUAN_EXPORT_PDF: string = "siyuan-export-pdf";
|
||||||
public static readonly SIYUAN_EXPORT_CLOSE: string = "siyuan-export-close";
|
public static readonly SIYUAN_EXPORT_CLOSE: string = "siyuan-export-close";
|
||||||
|
public static readonly SIYUAN_EXPORT_PREVENT: string = "siyuan-export-prevent";
|
||||||
|
|
||||||
// size
|
// size
|
||||||
public static readonly SIZE_TOOLBAR_HEIGHT: number = 42;
|
public static readonly SIZE_TOOLBAR_HEIGHT: number = 42;
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
import {hideMessage, showMessage} from "../../dialog/message";
|
import {hideMessage, showMessage} from "../../dialog/message";
|
||||||
import {Constants} from "../../constants";
|
import {Constants} from "../../constants";
|
||||||
/// #if !BROWSER
|
/// #if !BROWSER
|
||||||
import {OpenDialogReturnValue, shell} from "electron";
|
import {OpenDialogReturnValue, ipcRenderer} from "electron";
|
||||||
import {app, BrowserWindow, dialog, getCurrentWindow} from "@electron/remote";
|
import {app, BrowserWindow, dialog, getCurrentWindow} from "@electron/remote";
|
||||||
import * as fs from "fs";
|
import * as fs from "fs";
|
||||||
import * as path from "path";
|
import * as path from "path";
|
||||||
|
|
@ -451,9 +451,8 @@ const renderPDF = (id: string) => {
|
||||||
renderPreview(response.data.content);
|
renderPreview(response.data.content);
|
||||||
});
|
});
|
||||||
</script></body></html>`;
|
</script></body></html>`;
|
||||||
const mainWindow = getCurrentWindow();
|
|
||||||
window.siyuan.printWin = new BrowserWindow({
|
window.siyuan.printWin = new BrowserWindow({
|
||||||
parent: mainWindow,
|
parent: getCurrentWindow(),
|
||||||
modal: true,
|
modal: true,
|
||||||
show: true,
|
show: true,
|
||||||
width: 1032,
|
width: 1032,
|
||||||
|
|
@ -469,13 +468,7 @@ const renderPDF = (id: string) => {
|
||||||
webSecurity: false,
|
webSecurity: false,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
window.siyuan.printWin.webContents.on('will-navigate', (event, url) => {
|
ipcRenderer.send(Constants.SIYUAN_EXPORT_PREVENT, window.siyuan.printWin.id);
|
||||||
if (url.indexOf(location.host) > -1) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
event.preventDefault()
|
|
||||||
shell.openExternal(url)
|
|
||||||
})
|
|
||||||
window.siyuan.printWin.webContents.userAgent = `SiYuan/${app.getVersion()} https://b3log.org/siyuan Electron`;
|
window.siyuan.printWin.webContents.userAgent = `SiYuan/${app.getVersion()} https://b3log.org/siyuan Electron`;
|
||||||
fetchPost("/api/export/exportTempContent", {content: html}, (response) => {
|
fetchPost("/api/export/exportTempContent", {content: html}, (response) => {
|
||||||
window.siyuan.printWin.loadURL(response.data.url);
|
window.siyuan.printWin.loadURL(response.data.url);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue