|
@@ -0,0 +1,88 @@
|
|
|
|
+const { app, BrowserWindow, Menu } = require('electron/main');
|
|
|
|
+const { spawn } = require('child_process');
|
|
|
|
+const net = require('net');
|
|
|
|
+//const si = require('systeminformation');
|
|
|
|
+//const startDotnet = () => {
|
|
|
|
+// return new Promise((resolve, reject) => {
|
|
|
|
+// dotnetProcess = spawn('dotnet', ['run', '--project', '../IES.ExamServer/IES.ExamServer.csproj']);
|
|
|
|
+// dotnetProcess.stdout.on('data', (data) => {
|
|
|
|
+// console.log(`stdout: ${data}`);
|
|
|
|
+// // 假设dotnet服务启动后会输出包含"Now listening on"的日志
|
|
|
|
+// if (data.toString().includes('Now listening on')) {
|
|
|
|
+// resolve();
|
|
|
|
+// }
|
|
|
|
+// });
|
|
|
|
+
|
|
|
|
+// dotnetProcess.stderr.on('data', (data) => {
|
|
|
|
+// console.log(`stderr: ${data}`);
|
|
|
|
+// reject(new Error(`Dotnet process error: ${data}`));
|
|
|
|
+// });
|
|
|
|
+
|
|
|
|
+// dotnetProcess.on('close', (code) => {
|
|
|
|
+// console.log(`child process exited with code ${code}`);
|
|
|
|
+// if (code !== 0) {
|
|
|
|
+// reject(new Error(`Dotnet process exited with code ${code}`));
|
|
|
|
+// }
|
|
|
|
+// });
|
|
|
|
+// });
|
|
|
|
+//};
|
|
|
|
+// 获取网卡信息
|
|
|
|
+// npm start 启动命令
|
|
|
|
+const platform = process.platform;
|
|
|
|
+if (platform === 'win32') {
|
|
|
|
+ console.log('Running on Windows');
|
|
|
|
+} else if (platform === 'linux') {
|
|
|
|
+ console.log('Running on Linux');
|
|
|
|
+} else if (platform === 'darwin') {
|
|
|
|
+ console.log('Running on macOS');
|
|
|
|
+} else {
|
|
|
|
+ console.log('Running on an unknown platform');
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+//si.networkInterfaces()
|
|
|
|
+// .then(data => {
|
|
|
|
+// console.log('Network Interfaces:', data);
|
|
|
|
+// //mainWindow.webContents.send('network-interfaces', data);
|
|
|
|
+// })
|
|
|
|
+// .catch(error => {
|
|
|
|
+// console.error('Error fetching network interfaces:', error);
|
|
|
|
+// });
|
|
|
|
+const createWindow = async () => {
|
|
|
|
+ try {
|
|
|
|
+ //await startDotnet();
|
|
|
|
+ const win = new BrowserWindow({
|
|
|
|
+ width: 800,
|
|
|
|
+ height: 600
|
|
|
|
+ //webPreferences: {
|
|
|
|
+ // nodeIntegration: true,
|
|
|
|
+ // contextIsolation: false,
|
|
|
|
+ //},
|
|
|
|
+ });
|
|
|
|
+ // 忽略证书错误
|
|
|
|
+ //win.webContents.session.setCertificateVerifyProc((request, callback) => {
|
|
|
|
+ // callback(0); // 允许所有证书
|
|
|
|
+ //});
|
|
|
|
+ win.maximize();
|
|
|
|
+ win.loadURL('https://exam.habook.local:8888');
|
|
|
|
+ } catch (error) {
|
|
|
|
+ console.error('Error starting dotnet or loading window:', error);
|
|
|
|
+ }
|
|
|
|
+};
|
|
|
|
+
|
|
|
|
+// Menu.setApplicationMenu(null);
|
|
|
|
+
|
|
|
|
+app.whenReady().then(() => {
|
|
|
|
+ createWindow();
|
|
|
|
+
|
|
|
|
+ app.on('activate', () => {
|
|
|
|
+ if (BrowserWindow.getAllWindows().length === 0) {
|
|
|
|
+ createWindow();
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+});
|
|
|
|
+
|
|
|
|
+app.on('window-all-closed', () => {
|
|
|
|
+ if (process.platform !== 'darwin') {
|
|
|
|
+ app.quit();
|
|
|
|
+ }
|
|
|
|
+});
|