MrTerm: SSH/SFTP/RDP-Client im Termius-Stil (Electron)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
const { contextBridge, ipcRenderer } = require('electron');
|
||||
|
||||
async function call(channel, ...args) {
|
||||
const r = await ipcRenderer.invoke(channel, ...args);
|
||||
if (!r.ok) throw new Error(r.error);
|
||||
return r.value;
|
||||
}
|
||||
|
||||
function on(channel, fn) {
|
||||
const h = (_e, ...a) => fn(...a);
|
||||
ipcRenderer.on(channel, h);
|
||||
return () => ipcRenderer.removeListener(channel, h);
|
||||
}
|
||||
|
||||
contextBridge.exposeInMainWorld('api', {
|
||||
platform: process.platform,
|
||||
call,
|
||||
on,
|
||||
win: {
|
||||
min: () => ipcRenderer.send('win:min'),
|
||||
max: () => ipcRenderer.send('win:max'),
|
||||
close: () => ipcRenderer.send('win:close'),
|
||||
},
|
||||
ssh: {
|
||||
write: (id, d) => ipcRenderer.send('ssh:write', id, d),
|
||||
resize: (id, c, r) => ipcRenderer.send('ssh:resize', id, c, r),
|
||||
close: (id) => ipcRenderer.send('ssh:close', id),
|
||||
},
|
||||
replySecret: (reqId, v) => ipcRenderer.send('secret:reply', reqId, v),
|
||||
});
|
||||
Reference in New Issue
Block a user