3

electron-prebuilt を使用した単純な 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

この問題の原因は何ですか?

npm のバージョンは 1.4.10 で、ノード (io.js 経由) のバージョンは 0.11.13 (Windows 7 x64) です。

4

1 に答える 1

7

@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;
  });
});
于 2015-06-25T21:31:53.133 に答える