114 lines
2.9 KiB
JavaScript
114 lines
2.9 KiB
JavaScript
|
|
const electron = require('electron');
|
|||
|
|
const { app, BrowserWindow, desktopCapturer } = electron;
|
|||
|
|
const ipcMain = electron.ipcMain;
|
|||
|
|
const Menu = electron.Menu;
|
|||
|
|
const globalShortcut = electron.globalShortcut;
|
|||
|
|
const path = require('path');
|
|||
|
|
const os = require('os');
|
|||
|
|
const fs = require('fs');
|
|||
|
|
|
|||
|
|
let mainWindow;
|
|||
|
|
let hardKillTriggered = false;
|
|||
|
|
|
|||
|
|
app.whenReady().then(() => {
|
|||
|
|
Menu.setApplicationMenu(null);
|
|||
|
|
|
|||
|
|
mainWindow = new BrowserWindow({
|
|||
|
|
width: 1300,
|
|||
|
|
height: 820,
|
|||
|
|
minWidth: 800,
|
|||
|
|
minHeight: 500,
|
|||
|
|
title: 'Nexus AzA Remote',
|
|||
|
|
backgroundColor: '#0a0a0a',
|
|||
|
|
webPreferences: {
|
|||
|
|
nodeIntegration: true,
|
|||
|
|
contextIsolation: false,
|
|||
|
|
},
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
mainWindow.loadFile('index.html');
|
|||
|
|
|
|||
|
|
ipcMain.handle('get-sources', async () => {
|
|||
|
|
const sources = await desktopCapturer.getSources({
|
|||
|
|
types: ['screen'],
|
|||
|
|
thumbnailSize: { width: 1, height: 1 },
|
|||
|
|
});
|
|||
|
|
return sources.map((s) => ({ id: s.id, name: s.name }));
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
ipcMain.handle('save-credentials', async (_e, id, key) => {
|
|||
|
|
const desktop = path.join(os.homedir(), 'Desktop');
|
|||
|
|
const filePath = path.join(desktop, 'Nexus_AzA_Zugangsdaten.txt');
|
|||
|
|
const content =
|
|||
|
|
`-----------------------------------------
|
|||
|
|
NEXUS AzA REMOTE - DEINE ZUGANGSDATEN
|
|||
|
|
-----------------------------------------
|
|||
|
|
Deine ID: ${id}
|
|||
|
|
Sicherheits-Key: ${key}
|
|||
|
|
|
|||
|
|
SO VERBINDEST DU DICH:
|
|||
|
|
1. Oeffne Nexus Remote auf dem anderen PC
|
|||
|
|
2. Gib die obige ID als "Remote ID" ein
|
|||
|
|
3. Gib den obigen Key als "Remote Key" ein
|
|||
|
|
4. Klicke "Verbinden"
|
|||
|
|
5. Die Verbindung wird gespeichert!
|
|||
|
|
Beim naechsten Mal einfach "Verbinden"
|
|||
|
|
klicken – ID und Key sind gespeichert.
|
|||
|
|
|
|||
|
|
SICHERHEIT:
|
|||
|
|
- Gib diese Daten nur an Personen weiter,
|
|||
|
|
denen du vertraust.
|
|||
|
|
- ESC = Verbindung trennen
|
|||
|
|
- Ctrl+Alt+K = sofortiger Notaus
|
|||
|
|
-----------------------------------------`;
|
|||
|
|
try { fs.writeFileSync(filePath, content, 'utf-8'); } catch {}
|
|||
|
|
return filePath;
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
ipcMain.on('set-always-on-top', (_e, val) => {
|
|||
|
|
if (mainWindow && !mainWindow.isDestroyed()) {
|
|||
|
|
mainWindow.setAlwaysOnTop(val);
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
ipcMain.on('cleanup-done', () => {
|
|||
|
|
globalShortcut.unregisterAll();
|
|||
|
|
app.exit(0);
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
globalShortcut.register('CommandOrControl+Alt+K', () => {
|
|||
|
|
hardKillTriggered = true;
|
|||
|
|
if (mainWindow && !mainWindow.isDestroyed()) {
|
|||
|
|
mainWindow.webContents.send('hard-kill');
|
|||
|
|
setTimeout(() => {
|
|||
|
|
globalShortcut.unregisterAll();
|
|||
|
|
app.exit(0);
|
|||
|
|
}, 1200);
|
|||
|
|
} else {
|
|||
|
|
globalShortcut.unregisterAll();
|
|||
|
|
app.exit(0);
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
globalShortcut.register('Escape', () => {
|
|||
|
|
if (mainWindow && !mainWindow.isDestroyed()) {
|
|||
|
|
mainWindow.webContents.send('kill-switch');
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
mainWindow.on('close', () => {
|
|||
|
|
if (!mainWindow.isDestroyed()) {
|
|||
|
|
mainWindow.webContents.send('hard-kill');
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
app.on('will-quit', () => {
|
|||
|
|
globalShortcut.unregisterAll();
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
app.on('window-all-closed', () => {
|
|||
|
|
globalShortcut.unregisterAll();
|
|||
|
|
app.exit(0);
|
|||
|
|
});
|