电子和socketsio无法closures窗口

我开始与NodeJS和Socket io聊天应用程序项目,一切都很好。

后来我决定把我的应用程序添加到Electron框架中,聊天开始在一个窗口中,但是我不能closures这个窗口,退出button什么也不做。

经过对我的代码的一些研究,以了解问题的来源,我删除了我的main.html中的socket.io.js行,然后我可以closures我的应用程序,但肯定我的客户端WebSocket停止工作。

<script src="/socket.io/socket.io.js"></script> 

这是我的main.js中的createWindow函数。

 function createWindow () { // Instantiate Express App app.server = require(__dirname + '/app/app')(); // Create the browser window. win = new BrowserWindow(); // win.maximize(); // and load the index.html of the app. win.loadURL('http://localhost:'+config.server.port); // Open the DevTools. // win.webContents.openDevTools(); win.focus(); // Emitted when the window is closed. win.on('closed', () => { console.log("close"); // Dereference the window object, usually you would store windows // in an array if your app supports multi windows, this is the time // when you should delete the corresponding element. win = null }); } 

我的项目文件树看起来像这样

 main.js // Electron, create the window load the app.js /app/app.js // Express, all my socket function /views/main.html // Html 

请帮帮我 !

erff解决了我的main.html我有这个function,删除一切后确定!

  /** * Alert when user leave the page * */ window.onbeforeunload = function (event) { var message = 'Sure you want to leave?'; if (typeof event == 'undefined') { event = window.event; } if (event) { event.returnValue = message; } return message; }