This commit is contained in:
Vanessa 2023-01-06 20:26:14 +08:00
parent 278fa18aee
commit af2d3ade5e
5 changed files with 49 additions and 20 deletions

View file

@ -71,7 +71,6 @@ export const saveExport = (option: { type: string, id: string }) => {
};
/// #if !BROWSER
let originalZoomFactor = 1;
const renderPDF = (id: string) => {
const localData = window.siyuan.storage[Constants.LOCAL_EXPORTPDF];
const servePath = window.location.protocol + "//" + window.location.host;
@ -453,7 +452,6 @@ const renderPDF = (id: string) => {
});
</script></body></html>`;
const mainWindow = getCurrentWindow();
originalZoomFactor = mainWindow.webContents.zoomFactor;
window.siyuan.printWin = new BrowserWindow({
parent: mainWindow,
modal: true,
@ -472,20 +470,11 @@ const renderPDF = (id: string) => {
},
});
window.siyuan.printWin.webContents.userAgent = `SiYuan/${app.getVersion()} https://b3log.org/siyuan Electron`;
window.siyuan.printWin.once("ready-to-show", () => {
// 导出 PDF 预览界面不受主界面缩放影响 https://github.com/siyuan-note/siyuan/issues/6262
window.siyuan.printWin.webContents.setZoomFactor(1);
});
fetchPost("/api/export/exportTempContent", {content: html}, (response) => {
window.siyuan.printWin.loadURL(response.data.url);
});
};
export const destroyPrintWindow = () => {
getCurrentWindow().webContents.setZoomFactor(originalZoomFactor);
window.siyuan.printWin.destroy();
};
const getExportPath = (option: { type: string, id: string }, removeAssets?: boolean, mergeSubdocs?: boolean) => {
fetchPost("/api/block/getBlockInfo", {
id: option.id