Vanessa 2024-12-11 09:18:30 +08:00
parent 6b59e9d7f2
commit 72240c7f38

View file

@ -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;
}