删除 index.js

This commit is contained in:
高峰君主 2024-10-20 20:17:28 +08:00
parent 0362a915b5
commit 8bb01e555c

View File

@ -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();
});