mirror of
https://github.com/ElectronNET/Electron.NET.git
synced 2026-02-16 13:45:07 +00:00
42 lines
1.0 KiB
JavaScript
42 lines
1.0 KiB
JavaScript
const { app, BrowserWindow, Notification } = require('electron');
|
|
const io = require('socket.io')(3000);
|
|
const path = require('path');
|
|
|
|
let window;
|
|
let apiProcess;
|
|
|
|
app.on('ready', () => {
|
|
const process = require('child_process').spawn;
|
|
|
|
// run server
|
|
var apipath = path.join(__dirname, '..\\ElectronNET.WebApp\\bin\\dist\\win\\ElectronNET.WebApp.exe');
|
|
apiProcess = process(apipath);
|
|
|
|
apiProcess.stdout.on('data', (data) => {
|
|
console.log(`stdout: ${data}`);
|
|
});
|
|
});
|
|
|
|
io.on('connection', (socket) => {
|
|
console.log('ASP.NET Core Application connected...');
|
|
|
|
socket.on('createBrowserWindow', (options) => {
|
|
console.log(options);
|
|
options.show = true;
|
|
|
|
window = new BrowserWindow(options);
|
|
window.loadURL('http://localhost:5000');
|
|
|
|
window.on('closed', function () {
|
|
mainWindow = null;
|
|
apiProcess = null;
|
|
});
|
|
});
|
|
|
|
socket.on('createNotification', (options) => {
|
|
const notification = new Notification(options);
|
|
notification.show();
|
|
});
|
|
});
|
|
|