mirror of
https://github.com/Llewellynvdm/nativefier.git
synced 2024-11-12 08:06:27 +00:00
54 lines
1.1 KiB
JavaScript
54 lines
1.1 KiB
JavaScript
/**
|
|
* Created by JiaHao on 4/7/15.
|
|
*/
|
|
|
|
|
|
var app = require('app');
|
|
var fs = require('fs');
|
|
var BrowserWindow = require('browser-window');
|
|
|
|
const APP_ARGS_FILE_PATH = __dirname + '/targetUrl.txt';
|
|
require('crash-reporter').start();
|
|
|
|
var mainWindow = null;
|
|
|
|
app.on('window-all-closed', function() {
|
|
if (process.platform != 'darwin') {
|
|
app.quit();
|
|
}
|
|
});
|
|
|
|
app.on('ready', function() {
|
|
mainWindow = new BrowserWindow(
|
|
{
|
|
width: 1280,
|
|
height: 800,
|
|
'web-preferences': {
|
|
javascript: true,
|
|
plugins: true,
|
|
}
|
|
}
|
|
);
|
|
mainWindow.loadUrl('file://' + __dirname + '/index.html');
|
|
|
|
//mainWindow.openDevTools();
|
|
mainWindow.webContents.on('did-finish-load', function() {
|
|
|
|
fs.readFile(__dirname + '/targetUrl.txt', 'utf8', function (error, data) {
|
|
if (error) {
|
|
console.error('Error reading file: ' + error);
|
|
} else {
|
|
mainWindow.webContents.send('params', data);
|
|
}
|
|
|
|
})
|
|
});
|
|
|
|
|
|
mainWindow.on('closed', function() {
|
|
mainWindow = null;
|
|
})
|
|
|
|
});
|
|
|