Selaa lähdekoodia

:art: https://github.com/siyuan-note/siyuan/issues/12656

Vanessa 7 kuukautta sitten
vanhempi
commit
72240c7f38
1 muutettua tiedostoa jossa 16 lisäystä ja 2 poistoa
  1. 16 2
      app/electron/main.js

+ 16 - 2
app/electron/main.js

@@ -43,7 +43,7 @@ const windowStatePath = path.join(confDir, "windowState.json");
 let bootWindow;
 let latestActiveWindow;
 let firstOpen = false;
-let workspaces = []; // workspaceDir, id, browserWindow, tray
+let workspaces = []; // workspaceDir, id, browserWindow, tray, hideShortcut
 let kernelPort = 6806;
 let resetWindowStateOnRestart = false;
 
@@ -1098,6 +1098,12 @@ app.whenReady().then(() => {
         if (!data.hotkeys || data.hotkeys.length === 0) {
             return;
         }
+        workspaces.find(workspaceItem => {
+            if (event.sender.id === workspaceItem.browserWindow.webContents.id) {
+                workspaceItem.hotkeys = data.hotkeys;
+                return true;
+            }
+        });
         data.hotkeys.forEach((item, index) => {
             const shortcut = hotKey2Electron(item);
             if (!shortcut) {
@@ -1111,11 +1117,19 @@ app.whenReady().then(() => {
                     let currentWorkspace;
                     const currentWebContentsId = (latestActiveWindow && !latestActiveWindow.isDestroyed()) ? latestActiveWindow.webContents.id : undefined;
                     workspaces.find(workspaceItem => {
-                        if ((currentWebContentsId || event.sender.id) === workspaceItem.browserWindow.webContents.id) {
+                        if (currentWebContentsId === workspaceItem.browserWindow.webContents.id && workspaceItem.hotkeys[0] === item) {
                             currentWorkspace = workspaceItem;
                             return true;
                         }
                     });
+                    if (!currentWorkspace) {
+                        workspaces.find(workspaceItem => {
+                            if (workspaceItem.hotkeys[0] === item && event.sender.id === workspaceItem.browserWindow.webContents.id) {
+                                currentWorkspace = workspaceItem;
+                                return true;
+                            }
+                        });
+                    }
                     if (!currentWorkspace) {
                         return;
                     }