Skip to content

Instantly share code, notes, and snippets.

@taishi41228
Last active December 22, 2016 05:55
Show Gist options
  • Save taishi41228/e2aa1e083f229d5fb92836ce84701ddc to your computer and use it in GitHub Desktop.
Save taishi41228/e2aa1e083f229d5fb92836ce84701ddc to your computer and use it in GitHub Desktop.
Hello Electron!!
const electron = require('electron');
const {
app,
BrowserWindow
} = electron;
const fs = require("fs");
app.on('ready', function () {
function isExistFile(file) {
try {
fs.statSync(file);
return true
} catch(err) {
if(err.code === 'ENOENT') return false
}
}
if(isExistFile('./loading.gif')){
console.log("あるよ");
}else{
console.log("ないよ");
}
});
// ファイルを
// src
// |-- index.html
// |-- main.js
const electron = require('electron');
const {
app,
BrowserWindow
} = electron;
let win;
app.on('ready', function () {
win = new BrowserWindow({
title: 'Hello Electron!!',
width: 600,
height: 600
});
win.loadURL(`file://${__dirname}/index.html`);
// win.loadURL(`file://${__dirname}/loading.gif`);でも可能
win.on('closed', () => {
win = null;
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment