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

View file

@ -199,9 +199,11 @@ export const getLocalStorage = (cb:()=>void) => {
paragraph: window.siyuan.config.search.paragraph,
}
};
defaultStorage[Constants.LOCAL_ZOOM] = 1;
[Constants.LOCAL_SEARCHEKEYS, Constants.LOCAL_PDFTHEME, Constants.LOCAL_BAZAAR, Constants.LOCAL_EXPORTWORD,
Constants.LOCAL_EXPORTPDF, Constants.LOCAL_DOCINFO, Constants.LOCAL_FONTSTYLES, Constants.LOCAL_SEARCHEDATA].forEach((key) => {
Constants.LOCAL_EXPORTPDF, Constants.LOCAL_DOCINFO, Constants.LOCAL_FONTSTYLES, Constants.LOCAL_SEARCHEDATA,
Constants.LOCAL_ZOOM,].forEach((key) => {
if (typeof response.data[key] === "string") {
try {
window.siyuan.storage[key] = Object.assign(defaultStorage[key], JSON.parse(response.data[key]));