From 5ac9adefd40d0932341f2a844f642db5afa3cef0 Mon Sep 17 00:00:00 2001 From: ertherod Date: Wed, 26 Sep 2018 20:08:35 +0200 Subject: [PATCH] Add version 0.2.0 --- index.js | 75 ++++++++++++++++++++++++++++++++++++++++------------ package.json | 2 +- 2 files changed, 59 insertions(+), 18 deletions(-) diff --git a/index.js b/index.js index 691c4c2..4ae7b13 100644 --- a/index.js +++ b/index.js @@ -1,28 +1,69 @@ const electron = require('electron'); -const app = electron.app; const BrowserWindow = electron.BrowserWindow; +const {app, Menu, Tray} = require('electron') let mainWindow +let tray = null -function createWindow() { +function main(){ mainWindow = new BrowserWindow({ - icon:'resources/app/icon.png', - webPreferences: { - nodeIntegration: false, - preload: './preload.js' - } + icon:'icon.png', + webPreferences :{ + nodeIntegration :false + }, + show: false }); - mainWindow.setIco - mainWindow.loadURL('https://beta.communiquons.org/'); - + mainWindow.maximize(); + //createWindow --> create the window + mainWindow.loadURL('https://comunic.io'); + //set the url who must be open + mainWindow.on('closed', () =>{ mainWindow = null; }); -} -app.on('window-all-closed', () =>{ - if(process.platform !== 'darwin'){ - app.quit(); - } -}); + //To close the window -app.on('ready', createWindow); \ No newline at end of file + 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"); + } +}]); + +console.log("Starting..."); +app.on('ready', main); diff --git a/package.json b/package.json index 51772f2..5e3bf45 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "communic-desktop", - "version": "0.1.0", + "version": "0.2.0", "description": "A client-desktop for communiquons.org", "main": "index.js", "scripts": {