0
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Electron メインプロセス変更箇所

0
Posted at

正式バージョンのアップデートされてから、コーディングルールが幾つか変更され、またデフォルトのJavaScript仕様は厳格モードになりました。

メインプロセス最低宣言変更

const app = require('app');

このappから各種機能を呼び出す事が出来ましたが、

const electron = require('electron');
const {app} = electron;
const {BrowserWindow} = electron;

electronをベースにオブジェクトの読み込みになりました。

厳格モードでより具体的に

let win;

function createWindow(){
  win = new BrowserWindow({width: 800, height: 600});
  win.loadURL('file://${__dirname}/index.html');

  win.webContents.openDevTools();

  win.on('closed', () => {
    win = null;
  });
}

app.on('ready', createWindow);

app.on('window-all-closed', () => {
  if(process.platform !== 'darwin'){
    app.quit();
  }
});

app.on('activate', () => {
  if(win === null){
    createWindow();
  }
});

0
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?