view index.js @ 0:12d9c981a5f4

add source
author ryokka
date Wed, 29 May 2019 18:53:44 +0900
parents
children e3851f39ad5c
line wrap: on
line source

"use strict";

const electron = require("electron");
const app = electron.app;
const Menu = electron.Menu;
const BrowserWindow = electron.BrowserWindow;
let mainWindow;
let locate;

// 全てのウィンドウが閉じたら終了
app.on('window-all-closed', function() {
  if (process.platform != 'darwin') {
    app.quit();
  }
});

// app.on('open-file', function() {

// });

// Electronの初期化完了後に実行
app.on('ready', function() {
  // メイン画面の表示。ウィンドウの幅、高さを指定できる
  mainWindow = new BrowserWindow({
      width: 800,
      height: 600,
      maxWidth: 800,
      maxHeight: 600,
      disableAutoHideCursor: true,
      resizable: true,
      autoHideMenuBar: true,
      frame: false,
      webPreferences: {},
  });

    var inmenu = [
        {submenu: [
             { role: 'quit',},
         ]},

        {label: 'View',
         submenu: [
             { role: 'minimize',},
             { role: 'zoomin',},
             { role: 'zoomout',},
             { role: 'togglefullscreen'},
         ]}
    ];

    const menu = Menu.buildFromTemplate(inmenu);
    Menu.setApplicationMenu(menu);


    locate = 'file://' + __dirname + '/index.html';
    // if (process.argv[2] !== undefined) {
    //     locate = process.argv[2];
    // }

    mainWindow.loadURL(locate);
  // ウィンドウが閉じられたらアプリも終了
  mainWindow.on('closed', function() {
    mainWindow = null;
  });
});