sheetjs-clone/demos/electron/main.js

31 lines
1.1 KiB
JavaScript
Raw Normal View History

/* xlsx.js (C) 2013-present SheetJS -- http://sheetjs.com */
/* from the electron quick-start */
var electron = require('electron');
var XLSX = require('xlsx');
var app = electron.app;
2022-03-07 07:36:36 +00:00
require('@electron/remote/main').initialize();
var win = null;
function createWindow() {
if (win) return;
win = new electron.BrowserWindow({
width: 800, height: 600,
webPreferences: {
2021-09-08 01:43:05 +00:00
worldSafeExecuteJavaScript: true, // required for Electron 12+
contextIsolation: false, // required for Electron 12+
nodeIntegration: true,
enableRemoteModule: true
}
});
win.loadURL("file://" + __dirname + "/index.html");
2022-03-07 07:36:36 +00:00
require('@electron/remote/main').enable(win.webContents);
win.webContents.openDevTools();
win.on('closed', function () { win = null; });
}
if (app.setAboutPanelOptions) app.setAboutPanelOptions({ applicationName: 'sheetjs-electron', applicationVersion: "XLSX " + XLSX.version, copyright: "(C) 2017-present SheetJS LLC" });
app.on('open-file', function () { console.log(arguments); });
app.on('ready', createWindow);
app.on('activate', createWindow);
app.on('window-all-closed', function () { if (process.platform !== 'darwin') app.quit(); });