删除 index.js
This commit is contained in:
parent
0362a915b5
commit
8bb01e555c
46
index.js
46
index.js
@ -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();
|
||||
});
|
Loading…
Reference in New Issue
Block a user