电子(原子壳)窗口在一段时间后自行关闭

Mat*_*cal 2 node.js npm electron

只设置了一个使用电子预建的普通Hello World应用程序.我按npm start命令运行它.

窗口正常显示为预期.然而,经过一段时间后它会自行关闭.

在命令提示符下,它会在窗口关闭之前抛出以下警告:

WARNING:raw_channel_win.cc(473)] WriteFile: The pipe is being closed. (0xE8)
WARNING:channel.cc(549)] Failed to send message to ack remove remote endpoint (local ID 1, remote ID 1)
WARNING:channel.cc(315)] RawChannel write error
Run Code Online (Sandbox Code Playgroud)

是什么导致了这个问题?

npm版本是1.4.10&node(通过io.js)版本是0.11.13(Windows 7 x64)

And*_*rns 6

正如@Oztaco所说,在快速入门指南中,它有以下代码示例:

// Keep a global reference of the window object, if you don't, the window will
// be closed automatically when the javascript object is GCed.
var mainWindow = null;

// This method will be called when Electron has done everything
// initialization and ready for creating browser windows.
app.on('ready', function() {
  // Create the browser window.
  mainWindow = new BrowserWindow({width: 800, height: 600});

  // other code ommited

  // Emitted when the window is closed.
  mainWindow.on('closed', function() {
    // 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.
    mainWindow = null;
  });
});
Run Code Online (Sandbox Code Playgroud)