2018-09-24 18:47:41 +00:00
|
|
|
const electron = require('electron');
|
|
|
|
const BrowserWindow = electron.BrowserWindow;
|
2018-09-26 18:08:35 +00:00
|
|
|
const {app, Menu, Tray} = require('electron')
|
2018-09-24 18:47:41 +00:00
|
|
|
|
|
|
|
let mainWindow
|
2018-09-26 18:08:35 +00:00
|
|
|
let tray = null
|
2018-09-24 18:47:41 +00:00
|
|
|
|
2018-09-26 18:08:35 +00:00
|
|
|
function main(){
|
2018-09-24 18:47:41 +00:00
|
|
|
mainWindow = new BrowserWindow({
|
2018-09-26 18:08:35 +00:00
|
|
|
icon:'icon.png',
|
|
|
|
webPreferences :{
|
|
|
|
nodeIntegration :false
|
|
|
|
},
|
|
|
|
show: false
|
2018-09-24 18:47:41 +00:00
|
|
|
});
|
2018-09-26 18:08:35 +00:00
|
|
|
mainWindow.maximize();
|
|
|
|
//createWindow --> create the window
|
|
|
|
mainWindow.loadURL('https://comunic.io');
|
|
|
|
//set the url who must be open
|
|
|
|
|
2018-09-24 18:47:41 +00:00
|
|
|
mainWindow.on('closed', () =>{
|
|
|
|
mainWindow = null;
|
|
|
|
});
|
2018-09-26 18:08:35 +00:00
|
|
|
//To close the window
|
|
|
|
|
|
|
|
tray = new Tray('./icon.png');
|
|
|
|
|
|
|
|
tray.setToolTip('Comunic');
|
|
|
|
|
|
|
|
|
|
|
|
tray.setContextMenu(menu_1);
|
|
|
|
|
|
|
|
console.log("Started succesfully");
|
|
|
|
|
|
|
|
mainWindow.once('ready-to-show', () => {
|
|
|
|
mainWindow.show()
|
|
|
|
})
|
|
|
|
};
|
|
|
|
const menu_1 = Menu.buildFromTemplate([{
|
|
|
|
label: "Ouvrir la version stable",
|
|
|
|
click: () => {
|
|
|
|
mainWindow.loadURL('https://communiquons.org');
|
|
|
|
tray.setContextMenu(menu_2)
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
label : 'Quit',
|
|
|
|
click: () => {
|
|
|
|
app.quit();
|
|
|
|
console.log("Closed");
|
|
|
|
}
|
|
|
|
}]);
|
|
|
|
const menu_2 = Menu.buildFromTemplate([{
|
|
|
|
label: "Ouvrir la nouvelle version",
|
|
|
|
click: () =>{
|
|
|
|
mainWindow.loadURL('https://comunic.io');
|
|
|
|
tray.setContextMenu(menu_1)
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
label:'Quit',
|
|
|
|
click: () => {
|
|
|
|
app.quit();
|
|
|
|
console.log("Closed");
|
|
|
|
}
|
|
|
|
}]);
|
2018-09-24 18:47:41 +00:00
|
|
|
|
2018-09-26 18:08:35 +00:00
|
|
|
console.log("Starting...");
|
|
|
|
app.on('ready', main);
|