mirror of
https://github.com/wavetermdev/backup.git
synced 2026-08-05 13:57:07 -07:00
checkpoint
This commit is contained in:
+16
-1
@@ -53,8 +53,23 @@ function createWindow() {
|
||||
if (input.type != "keyDown") {
|
||||
return;
|
||||
}
|
||||
if (input.meta) {
|
||||
console.log("before-input", input.code, input.modifiers);
|
||||
}
|
||||
if (input.code == "KeyT" && input.meta) {
|
||||
win.webContents.send("cmt-t");
|
||||
win.webContents.send("cmd-t");
|
||||
e.preventDefault();
|
||||
return;
|
||||
}
|
||||
if (input.code == "BracketRight" && input.meta) {
|
||||
win.webContents.send("switch-screen", {relative: 1});
|
||||
e.preventDefault();
|
||||
return;
|
||||
}
|
||||
if (input.code == "BracketLeft" && input.meta) {
|
||||
win.webContents.send("switch-screen", {relative: -1});
|
||||
e.preventDefault();
|
||||
return;
|
||||
}
|
||||
});
|
||||
return win;
|
||||
|
||||
@@ -19,6 +19,7 @@ function isBlank(s : string) {
|
||||
type ElectronApi = {
|
||||
getId : () => string,
|
||||
onCmdT : (callback : () => void) => void,
|
||||
onSwitchScreen : (callback : (event : any, arg : {relative? : number, absolute? : number}) => void) => void,
|
||||
};
|
||||
|
||||
function getApi() : ElectronApi {
|
||||
@@ -405,6 +406,16 @@ class Model {
|
||||
this.loadSessionList();
|
||||
this.ws = new WSControl(this.clientId, this.onWSMessage.bind(this))
|
||||
this.ws.reconnect();
|
||||
getApi().onCmdT(this.onCmdT.bind(this));
|
||||
getApi().onSwitchScreen(this.onSwitchScreen.bind(this));
|
||||
}
|
||||
|
||||
onCmdT() {
|
||||
console.log("got cmd-t");
|
||||
}
|
||||
|
||||
onSwitchScreen(e : any, arg : {relative? : number, absolute? : number}) {
|
||||
console.log("switch screen", arg);
|
||||
}
|
||||
|
||||
isConnected() : boolean {
|
||||
|
||||
+2
-1
@@ -2,5 +2,6 @@ let {contextBridge, ipcRenderer} = require("electron");
|
||||
|
||||
contextBridge.exposeInMainWorld("api", {
|
||||
getId: () => ipcRenderer.sendSync("get-id"),
|
||||
onCmdT: (callback) => ipcRenderer.on("cmd-t"),
|
||||
onCmdT: (callback) => ipcRenderer.on("cmd-t", callback),
|
||||
onSwitchScreen: (callback) => ipcRenderer.on("switch-screen", callback),
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user