mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-22 09:30:14 +01:00
This commit is contained in:
parent
fe4fe1aee6
commit
00fe7bffa4
5 changed files with 103 additions and 75 deletions
|
|
@ -1,5 +1,5 @@
|
|||
import {exportLayout, JSONToLayout, resetLayout, resizeTopbar, resizeTabs} from "../layout/util";
|
||||
import {hotKey2Electron, setStorageVal} from "../protyle/util/compatibility";
|
||||
import {setStorageVal} from "../protyle/util/compatibility";
|
||||
/// #if !BROWSER
|
||||
import {dialog, getCurrentWindow} from "@electron/remote";
|
||||
import {ipcRenderer, OpenDialogReturnValue, webFrame} from "electron";
|
||||
|
|
@ -27,6 +27,7 @@ import {openChangelog} from "./openChangelog";
|
|||
import {getIdFromSYProtocol, isSYProtocol} from "../util/pathName";
|
||||
import {App} from "../index";
|
||||
import {initWindowEvent} from "./globalEvent/event";
|
||||
import {sendGlobalShortcut} from "./globalEvent/keydown";
|
||||
|
||||
const matchKeymap = (keymap: Record<string, IKeymapItem>, key1: "general" | "editor", key2?: "general" | "insert" | "heading" | "list" | "table") => {
|
||||
if (key1 === "general") {
|
||||
|
|
@ -105,13 +106,7 @@ export const onGetConfig = (isStart: boolean, app: App) => {
|
|||
fetchPost("/api/setting/setKeymap", {
|
||||
data: window.siyuan.config.keymap
|
||||
}, () => {
|
||||
/// #if !BROWSER
|
||||
ipcRenderer.send(Constants.SIYUAN_HOTKEY, {
|
||||
languages: window.siyuan.languages["_trayMenu"],
|
||||
id: getCurrentWindow().id,
|
||||
hotkey: hotKey2Electron(window.siyuan.config.keymap.general.toggleWin.custom)
|
||||
});
|
||||
/// #endif
|
||||
sendGlobalShortcut(app);
|
||||
});
|
||||
}
|
||||
/// #if !BROWSER
|
||||
|
|
@ -121,11 +116,7 @@ export const onGetConfig = (isStart: boolean, app: App) => {
|
|||
id: getCurrentWindow().id,
|
||||
port: location.port
|
||||
});
|
||||
ipcRenderer.send(Constants.SIYUAN_HOTKEY, {
|
||||
languages: window.siyuan.languages["_trayMenu"],
|
||||
id: getCurrentWindow().id,
|
||||
hotkey: hotKey2Electron(window.siyuan.config.keymap.general.toggleWin.custom)
|
||||
});
|
||||
sendGlobalShortcut(app);
|
||||
webFrame.setZoomFactor(window.siyuan.storage[Constants.LOCAL_ZOOM]);
|
||||
/// #endif
|
||||
if (!window.siyuan.config.uiLayout || (window.siyuan.config.uiLayout && !window.siyuan.config.uiLayout.left)) {
|
||||
|
|
@ -314,6 +305,21 @@ export const initWindow = (app: App) => {
|
|||
ipcRenderer.on(Constants.SIYUAN_EXPORT_CLOSE, () => {
|
||||
window.siyuan.printWin.destroy();
|
||||
});
|
||||
ipcRenderer.on(Constants.SIYUAN_HOTKEY, (e, data) => {
|
||||
let matchCommand = false;
|
||||
app.plugins.find(item => {
|
||||
item.commands.find(command => {
|
||||
if (command.globalCallback && data === command.customHotkey) {
|
||||
matchCommand = true;
|
||||
command.globalCallback();
|
||||
return true;
|
||||
}
|
||||
});
|
||||
if (matchCommand) {
|
||||
return true;
|
||||
}
|
||||
});
|
||||
});
|
||||
ipcRenderer.on(Constants.SIYUAN_EXPORT_PDF, (e, ipcData) => {
|
||||
dialog.showOpenDialog({
|
||||
title: window.siyuan.languages.export + " PDF",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue