Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
/* eslint-env node */
const {BrowserWindow, app} = require('electron');
let mainWindow = null;
app.on('window-all-closed', function onWindowAllClosed() {
if (process.platform !== 'darwin') {
app.quit();
}
});
app.on('ready', function onReady() {
mainWindow = new BrowserWindow({
width: 800,
height: 600
});
delete mainWindow.module;
if (process.env.EMBER_ENV === 'test') {
mainWindow.loadURL('file://' + __dirname + '/index.html');
} else {
mainWindow.loadURL('file://' + __dirname + '/dist/index.html');
}
mainWindow.on('closed', function onClosed() {
mainWindow = null;
});
if (focusedWindow) {
focusedWindow.minimize();
}
}
}
]
}
]);
ipcMain.on('contextmenu-click', function() {
rightClickMenu.popup();
});
// This method will be called when Electron has finished
// initialization and is ready to create browser windows.
app.on('ready', function() {
// Application Menu
var appMenu = Menu.buildFromTemplate([
{
label: 'OpenBazaar',
submenu: [
{
label: 'Quit OpenBazaar',
accelerator: 'CmdOrCtrl+Q',
click: function() {
app.quit();
}
}
]
},
{
const {
app: App,
BrowserWindow,
Menu
} = require('electron');
// please set the environmental variable KKT_SV_NAME as the name of your server.
const Pug = require('electron-pug')({ pretty: true }, {
version: PKG.version,
serverName: SETTINGS['server-name'] || process.env['KKT_SV_NAME']
});
const Runner = require("./runner.js");
let mainWindow;
App.on('ready', main);
App.on('window-all-closed', () => {
if(process.platform != 'darwin'){
App.quit();
}
});
App.on('activate', () => {
if(mainWindow === null){
main();
}
});
Runner.send = (...argv) => {
mainWindow.webContents.send.apply(mainWindow.webContents, argv);
};
function main(){
Menu.setApplicationMenu(Menu.buildFromTemplate(Runner.MAIN_MENU));
let mainWindow: BrowserWindow | null
let tray: Tray | null
const winURL = process.env.NODE_ENV === 'development' ? `http://localhost:9080` : `file://${__dirname}/index.html`
// MAS build is not allowed requestSingleInstanceLock.
// ref: https://github.com/h3poteto/whalebird-desktop/issues/1030
// ref: https://github.com/electron/electron-osx-sign/issues/137#issuecomment-307626305
if (process.platform !== 'darwin') {
// Enforces single instance for linux and windows.
const gotTheLock = app.requestSingleInstanceLock()
if (!gotTheLock) {
app.quit()
} else {
app.on('second-instance', () => {
// Someone tried to run a second instance, we should focus our window.
if (mainWindow) {
if (mainWindow.isMinimized()) mainWindow.restore()
if (!mainWindow!.isVisible()) {
mainWindow!.show()
mainWindow!.setSkipTaskbar(false)
}
mainWindow.focus()
}
})
}
}
const appId = pkg.build.appId
const splashURL =
// Emitted when the window is closed.
mainWindow.on('closed', function () {
// Dereference the window object, usually you would store windows
// in an array if your app supports multi windows, this is the time
// when you should delete the corresponding element.
mainWindow = null
})
}
// This method will be called when Electron has finished
// initialization and is ready to create browser windows.
// Some APIs can only be used after this event occurs.
app.on('ready', createWindow)
// Quit when all windows are closed.
app.on('window-all-closed', function () {
// On OS X it is common for applications and their menu bar
// to stay active until the user quits explicitly with Cmd + Q
if (process.platform !== 'darwin') {
app.quit()
}
})
app.on('activate', function () {
// On OS X it's common to re-create a window in the app when the
// dock icon is clicked and there are no other windows open.
if (mainWindow === null) {
createWindow()
}
})
const {app, globalShortcut, BrowserWindow} = require('electron');
let mainWindow;
// Quit when all windows are closed.
app.on('window-all-closed', function() {
app.quit();
});
// This method will be called when Electron has done everything
// initialization and ready for creating browser windows.
app.on('ready', function() {
// Create the browser window.
mainWindow = new BrowserWindow({title: 'CS:GO Music Player', icon: 'logo.ico', width: 400, height: 700, maxWidth: 400, minWidth: 400, frame: false});
const next = globalShortcut.register('ALT+N', () => {
mainWindow.webContents.send('queueNext');
})
const startStop = globalShortcut.register('ALT+M', () => {
mainWindow.webContents.send('togglePlayer');
})
// and load the index.html of the app.
mainWindow.loadURL('file://' + __dirname + '/index.html');
const persist = new PersistStore()
const store = Restore.create(state(), actions)
store.events = new EventEmitter()
rpc('getSigners', (err, signers) => {
if (err) return store.signersError(err)
store.updateSigners(signers)
})
rpc('launchStatus', (err, status) => {
if (err) return console.log(err) // launchStatusError
store.setLaunch(status)
})
ipcRenderer.on('main:addSigner', (e, signer) => store.addSigner(signer))
ipcRenderer.on('main:removeSigner', (e, signer) => store.removeSigner(signer))
ipcRenderer.on('main:updateSigner', (e, signer) => store.updateSigner(signer))
ipcRenderer.on('main:setSigner', (e, signer) => store.setSigner(signer))
// Replace events with observers
store.events.on('approveRequest', (id, req) => {
store.requestPending(id)
provider.approveRequest(req, (err, res) => {
if (err) return store.requestError(id, err)
store.requestSuccess(id, res)
})
})
// Store Observers
store.observer(() => {
if (store('panel.show')) {
case '--squirrel-uninstall':
// Undo anything you did in the --squirrel-install and
// --squirrel-updated handlers
// Remove desktop and start menu shortcuts
spawnUpdate(['--removeShortcut', exeName]);
setTimeout(app.quit, 1000);
return true;
case '--squirrel-obsolete':
// This is called on the outgoing version of your app before
// we update to the new version - it's the opposite of
// --squirrel-updated
app.quit();
return true;
}
}
app.on('window-all-closed', function() {
if (process.platform != 'darwin')
app.quit()
})
// This method will be called when Electron has done everything
app.on('window-all-closed', () => {
// On OS X it is common for applications and their menu bar
// to stay active until the user quits explicitly with Cmd + Q
if (process.platform !== 'darwin') {
app.quit();
}
});