mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-02-13 10:44:20 +01:00
This commit is contained in:
parent
278fa18aee
commit
af2d3ade5e
5 changed files with 49 additions and 20 deletions
|
|
@ -1,4 +1,4 @@
|
|||
import {isCtrl, isMac, updateHotkeyTip, writeText} from "../protyle/util/compatibility";
|
||||
import {isCtrl, isMac, setStorageVal, updateHotkeyTip, writeText} from "../protyle/util/compatibility";
|
||||
import {matchHotKey} from "../protyle/util/hotKey";
|
||||
import {openSearch} from "../search/spread";
|
||||
import {
|
||||
|
|
@ -42,6 +42,9 @@ import {getNextFileLi, getPreviousFileLi} from "../protyle/wysiwyg/getBlock";
|
|||
import {editor} from "../config/editor";
|
||||
import {hintMoveBlock} from "../protyle/hint/extend";
|
||||
import {Backlink} from "../layout/dock/Backlink";
|
||||
/// #if !BROWSER
|
||||
import {webFrame} from "electron";
|
||||
/// #endif
|
||||
import {openHistory} from "../history/history";
|
||||
import {openCard} from "../card/openCard";
|
||||
|
||||
|
|
@ -486,6 +489,39 @@ export const globalShortcut = () => {
|
|||
event.preventDefault();
|
||||
return;
|
||||
}
|
||||
/// #if !BROWSER
|
||||
if (matchHotKey("⌘=", event)) {
|
||||
Constants.SIZE_ZOOM.find((item, index) => {
|
||||
if (item === window.siyuan.storage[Constants.LOCAL_ZOOM]) {
|
||||
window.siyuan.storage[Constants.LOCAL_ZOOM] = Constants.SIZE_ZOOM[index + 1] || 3
|
||||
webFrame.setZoomFactor(window.siyuan.storage[Constants.LOCAL_ZOOM]);
|
||||
setStorageVal(Constants.LOCAL_ZOOM, window.siyuan.storage[Constants.LOCAL_ZOOM]);
|
||||
return true;
|
||||
}
|
||||
})
|
||||
event.preventDefault();
|
||||
return;
|
||||
}
|
||||
if (matchHotKey("⌘0", event)) {
|
||||
webFrame.setZoomFactor(1);
|
||||
window.siyuan.storage[Constants.LOCAL_ZOOM] = 1
|
||||
setStorageVal(Constants.LOCAL_ZOOM, 1)
|
||||
event.preventDefault();
|
||||
return;
|
||||
}
|
||||
if (matchHotKey("⌘-", event)) {
|
||||
Constants.SIZE_ZOOM.find((item, index) => {
|
||||
if (item === window.siyuan.storage[Constants.LOCAL_ZOOM]) {
|
||||
window.siyuan.storage[Constants.LOCAL_ZOOM] = Constants.SIZE_ZOOM[index - 1] || 0.25
|
||||
webFrame.setZoomFactor(window.siyuan.storage[Constants.LOCAL_ZOOM]);
|
||||
setStorageVal(Constants.LOCAL_ZOOM, window.siyuan.storage[Constants.LOCAL_ZOOM]);
|
||||
return true;
|
||||
}
|
||||
})
|
||||
event.preventDefault();
|
||||
return;
|
||||
}
|
||||
/// #endif
|
||||
|
||||
if (matchHotKey(window.siyuan.config.keymap.general.syncNow.custom, event)) {
|
||||
event.preventDefault();
|
||||
|
|
|
|||
|
|
@ -3,11 +3,10 @@ import {exportLayout, JSONToLayout, resetLayout, resizeDrag, resizeTabs} from ".
|
|||
import {hotKey2Electron, setStorageVal, updateHotkeyTip} from "../protyle/util/compatibility";
|
||||
/// #if !BROWSER
|
||||
import {dialog, getCurrentWindow} from "@electron/remote";
|
||||
import {ipcRenderer, OpenDialogReturnValue} from "electron";
|
||||
import {webFrame, ipcRenderer, OpenDialogReturnValue} from "electron";
|
||||
import * as fs from "fs";
|
||||
import * as path from "path";
|
||||
import {afterExport} from "../protyle/export/util";
|
||||
import {destroyPrintWindow} from "../protyle/export";
|
||||
/// #endif
|
||||
import {Constants} from "../constants";
|
||||
import {appearance} from "../config/appearance";
|
||||
|
|
@ -146,6 +145,7 @@ export const onGetConfig = (isStart: boolean) => {
|
|||
id: getCurrentWindow().id,
|
||||
hotkey: hotKey2Electron(window.siyuan.config.keymap.general.toggleWin.custom)
|
||||
});
|
||||
webFrame.setZoomFactor(window.siyuan.storage[Constants.LOCAL_ZOOM]);
|
||||
/// #endif
|
||||
if (!window.siyuan.config.uiLayout || (window.siyuan.config.uiLayout && !window.siyuan.config.uiLayout.left)) {
|
||||
window.siyuan.config.uiLayout = Constants.SIYUAN_EMPTY_LAYOUT;
|
||||
|
|
@ -391,7 +391,7 @@ const initWindow = () => {
|
|||
winOnClose(currentWindow, close);
|
||||
});
|
||||
ipcRenderer.on(Constants.SIYUAN_EXPORT_CLOSE, () => {
|
||||
destroyPrintWindow();
|
||||
window.siyuan.printWin.destroy();
|
||||
});
|
||||
ipcRenderer.on(Constants.SIYUAN_EXPORT_PDF, (e, ipcData) => {
|
||||
dialog.showOpenDialog({
|
||||
|
|
@ -399,7 +399,7 @@ const initWindow = () => {
|
|||
properties: ["createDirectory", "openDirectory"],
|
||||
}).then((result: OpenDialogReturnValue) => {
|
||||
if (result.canceled) {
|
||||
destroyPrintWindow();
|
||||
window.siyuan.printWin.destroy();
|
||||
return;
|
||||
}
|
||||
const msgId = showMessage(window.siyuan.languages.exporting, -1);
|
||||
|
|
@ -438,7 +438,7 @@ const initWindow = () => {
|
|||
}, () => {
|
||||
const pdfFilePath = path.join(result.filePaths[0], replaceLocalPath(ipcData.rootTitle) + ".pdf");
|
||||
fs.writeFileSync(pdfFilePath, pdfData);
|
||||
destroyPrintWindow();
|
||||
window.siyuan.printWin.destroy();
|
||||
fetchPost("/api/export/addPDFOutline", {
|
||||
id: ipcData.rootId,
|
||||
merge: ipcData.mergeSubdocs,
|
||||
|
|
@ -471,11 +471,11 @@ const initWindow = () => {
|
|||
});
|
||||
}).catch((error: string) => {
|
||||
showMessage("Export PDF error:" + error, 0, "error", msgId);
|
||||
destroyPrintWindow();
|
||||
window.siyuan.printWin.destroy();
|
||||
});
|
||||
} catch (e) {
|
||||
showMessage("Export PDF failed: " + e, 0, "error", msgId);
|
||||
destroyPrintWindow();
|
||||
window.siyuan.printWin.destroy();
|
||||
}
|
||||
window.siyuan.printWin.hide();
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue