UNPKG

electron-about

Version:
86 lines (85 loc) 2.83 kB
"use strict"; /* IMPORT */ var electron_1 = require("electron"); var make_html_1 = require("./make_html"); /* ABOUT */ var About = { window: undefined, focus: function () { var win = About.window; if (!win) return; win.show(); win.focus(); }, isOpen: function () { return !!About.window; }, open: function (options) { if (!About.window) { var windowOptions = { frame: true, title: "About " + options.appName, titleBarStyle: 'default', autoHideMenuBar: true, fullscreenable: false, maximizable: false, minimizable: false, resizable: false, width: 258, height: 158, useContentSize: true, center: true, show: false, backgroundColor: '#ececec', webPreferences: { devTools: false, disableDialogs: true, enableRemoteModule: false, nativeWindowOpen: true, nodeIntegration: false, nodeIntegrationInWorker: false, javascript: false, sandbox: true, webSecurity: true } }; About.window = new electron_1.BrowserWindow(windowOptions); About.window.once('closed', function () { var _a; About.cleanup(); (_a = options.onClose) === null || _a === void 0 ? void 0 : _a.call(options); }); About.window.webContents.once('did-finish-load', function () { var _a; About.focus(); (_a = options.onOpen) === null || _a === void 0 ? void 0 : _a.call(options); }); var html = About.makeHTML(options).trim(), html64 = Buffer.from(html).toString('base64'); About.window.loadURL("data:text/html;base64," + html64); } else { About.focus(); } }, cleanup: function () { delete About.window; }, close: function () { var win = About.window; if (!win) return; win.close(); }, toggle: function (options, force) { force = typeof force === 'boolean' ? force : !About.isOpen(); if (force) return About.open(options); return About.close(); }, makeMenuItem: function (appName, options) { return { label: "About " + appName, click: function () { About.open(options); } }; }, makeHTML: make_html_1.default }; /* EXPORT */ module.exports = About; module.exports.default = About; Object.defineProperty(module.exports, "__esModule", { value: true });