From 8bb01e555ccafdeeab37a454d09ee52b8371b0a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=AB=98=E5=B3=B0=E5=90=9B=E4=B8=BB?= <994923161@qq.com> Date: Sun, 20 Oct 2024 20:17:28 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=A0=E9=99=A4=20index.js?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- index.js | 46 ---------------------------------------------- 1 file changed, 46 deletions(-) delete mode 100644 index.js diff --git a/index.js b/index.js deleted file mode 100644 index 09fb4ac..0000000 --- a/index.js +++ /dev/null @@ -1,46 +0,0 @@ -const { app, BrowserWindow } = require('electron'); - -const { spawn } = require('child_process'); -const path = require('path'); - -const flaskProcess = spawn('python', [path.join(__dirname, 'app.py')]); - -flaskProcess.stdout.on('data', (data) => { - console.log(`Flask: ${data}`); -}); - -// 监听Node.js进程的关闭事件 -process.on('SIGINT', () => { - console.log('Closing Node.js application and Python script...'); - - // 杀掉Python进程 - pythonProcess.kill('SIGINT'); - - // 完全退出Node.js应用 - process.exit(); -}); - -let mainWindow; - -app.whenReady().then(() => { - mainWindow = new BrowserWindow({ - width: 800, - height: 600, - icon: path.join(__dirname, 'assets', 'icon.ico'), - webPreferences: { - nodeIntegration: false, // 禁用 Node 集成 - contextIsolation: true, // 启用上下文隔离 - }, - }); - - // 加载 HTTP 服务的 URL - mainWindow.loadURL('http://127.0.0.1:5000/'); - - mainWindow.on('closed', () => { - mainWindow = null; - }); -}); - -app.on('window-all-closed', () => { - if (process.platform !== 'darwin') app.quit(); -});