Updated project

This commit is contained in:
Pierre HUBERT 2019-02-11 18:13:40 +01:00
parent ee02924124
commit 484813ff4d
2 changed files with 59 additions and 57 deletions

14
Config.js Normal file
View File

@ -0,0 +1,14 @@
/**
* Project configuration
*/
const Config = {
/**
* URL to access to Comunic
*/
access_url: 'https://comunic.io'
}
module.exports = Config;

View File

@ -1,69 +1,57 @@
const electron = require('electron');
const BrowserWindow = electron.BrowserWindow;
const {app, Menu, Tray} = require('electron')
const {app, Menu, Tray} = require('electron');
let mainWindow
let tray = null
const Config = require("./Config");
function main(){
let mainWindow;
let tray = null;
let page_finished_loading = false;
const menu = Menu.buildFromTemplate([{
label : 'Close',
click: () => {
app.quit();
console.log("Closed");
}
}]);
console.log("Starting...");
app.on('ready', () => {
//Create and show main window
mainWindow = new BrowserWindow({
icon:'icon.png',
webPreferences: {
nodeIntegration: false
},
show: false
//show: false
});
mainWindow.maximize();
//createWindow --> create the window
mainWindow.loadURL('https://comunic.io');
//set the url who must be open
//mainWindow.maximize();
//set the url which must be open
mainWindow.loadURL(Config.access_url);
mainWindow.on('closed', () =>{
//To close the window
mainWindow = null;
});
//To close the window
//Create tray
tray = new Tray('./icon.png');
tray.setToolTip('Comunic');
tray.setContextMenu(menu);
tray.setContextMenu(menu_1);
console.log("Started succesfully");
console.log("Started successfully");
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");
}
}]);
mainWindow.show();
});
console.log("Starting...");
app.on('ready', main);
mainWindow.webContents.on('did-finish-load', function() {
page_finished_loading = true;
});
});