mirror of
https://github.com/pierre42100/ComunicDesktop
synced 2024-11-27 06:19:22 +00:00
Updated project structure
This commit is contained in:
parent
484813ff4d
commit
24643f0867
58
MainWindow.js
Normal file
58
MainWindow.js
Normal file
@ -0,0 +1,58 @@
|
||||
/**
|
||||
* Main Window script
|
||||
*
|
||||
* @author The Comunic authors
|
||||
*/
|
||||
|
||||
const electron = require('electron');
|
||||
const BrowserWindow = electron.BrowserWindow;
|
||||
const {Tray} = require('electron');
|
||||
const Config = require("./Config");
|
||||
const TrayMenu = require("./TrayMenu");
|
||||
|
||||
|
||||
let mainWindow;
|
||||
let tray = null;
|
||||
let page_finished_loading = false;
|
||||
|
||||
|
||||
/**
|
||||
* Show main window
|
||||
*/
|
||||
exports.show = function(){
|
||||
|
||||
//Create and show main window
|
||||
mainWindow = new BrowserWindow({
|
||||
icon:'icon.png',
|
||||
webPreferences: {
|
||||
nodeIntegration: false
|
||||
},
|
||||
//show: false
|
||||
});
|
||||
//mainWindow.maximize();
|
||||
|
||||
//set the url which must be open
|
||||
mainWindow.loadURL(Config.access_url);
|
||||
|
||||
|
||||
mainWindow.on('closed', () =>{
|
||||
//To close the window
|
||||
mainWindow = null;
|
||||
});
|
||||
|
||||
|
||||
//Create tray
|
||||
tray = new Tray('./icon.png');
|
||||
tray.setToolTip('Comunic');
|
||||
tray.setContextMenu(TrayMenu);
|
||||
|
||||
console.log("Started successfully");
|
||||
|
||||
mainWindow.once('ready-to-show', () => {
|
||||
mainWindow.show();
|
||||
});
|
||||
|
||||
mainWindow.webContents.on('did-finish-load', function() {
|
||||
page_finished_loading = true;
|
||||
});
|
||||
}
|
14
TrayMenu.js
Normal file
14
TrayMenu.js
Normal file
@ -0,0 +1,14 @@
|
||||
/**
|
||||
* Tray menu
|
||||
*
|
||||
* @author Comunic Authors
|
||||
*/
|
||||
const {app, Menu} = require('electron');
|
||||
|
||||
module.exports = Menu.buildFromTemplate([{
|
||||
label : 'Close',
|
||||
click: () => {
|
||||
app.quit();
|
||||
console.log("Closed");
|
||||
}
|
||||
}]);
|
59
index.js
59
index.js
@ -1,57 +1,14 @@
|
||||
const electron = require('electron');
|
||||
const BrowserWindow = electron.BrowserWindow;
|
||||
const {app, Menu, Tray} = require('electron');
|
||||
/**
|
||||
* Application main script
|
||||
*
|
||||
* @author The Comunic Authors
|
||||
*/
|
||||
|
||||
const Config = require("./Config");
|
||||
|
||||
let mainWindow;
|
||||
let tray = null;
|
||||
let page_finished_loading = false;
|
||||
|
||||
const menu = Menu.buildFromTemplate([{
|
||||
label : 'Close',
|
||||
click: () => {
|
||||
app.quit();
|
||||
console.log("Closed");
|
||||
}
|
||||
}]);
|
||||
const {app} = require('electron');
|
||||
|
||||
const MainWindow = require("./MainWindow");
|
||||
|
||||
console.log("Starting...");
|
||||
app.on('ready', () => {
|
||||
|
||||
//Create and show main window
|
||||
mainWindow = new BrowserWindow({
|
||||
icon:'icon.png',
|
||||
webPreferences: {
|
||||
nodeIntegration: false
|
||||
},
|
||||
//show: false
|
||||
});
|
||||
//mainWindow.maximize();
|
||||
|
||||
//set the url which must be open
|
||||
mainWindow.loadURL(Config.access_url);
|
||||
|
||||
|
||||
mainWindow.on('closed', () =>{
|
||||
//To close the window
|
||||
mainWindow = null;
|
||||
});
|
||||
|
||||
|
||||
//Create tray
|
||||
tray = new Tray('./icon.png');
|
||||
tray.setToolTip('Comunic');
|
||||
tray.setContextMenu(menu);
|
||||
|
||||
console.log("Started successfully");
|
||||
|
||||
mainWindow.once('ready-to-show', () => {
|
||||
mainWindow.show();
|
||||
});
|
||||
|
||||
mainWindow.webContents.on('did-finish-load', function() {
|
||||
page_finished_loading = true;
|
||||
});
|
||||
MainWindow.show();
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user