mirror of
				https://github.com/pierre42100/ComunicDesktop
				synced 2025-10-31 17:44:04 +00:00 
			
		
		
		
	Updated project structure
This commit is contained in:
		
							
								
								
									
										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; |  * Application main script | ||||||
| const {app, Menu, Tray} = require('electron'); |  *  | ||||||
|  |  * @author The Comunic Authors | ||||||
|  |  */ | ||||||
|  |  | ||||||
| const Config = require("./Config"); | const {app} = require('electron'); | ||||||
|  |  | ||||||
| let mainWindow; |  | ||||||
| let tray = null; |  | ||||||
| let page_finished_loading = false; |  | ||||||
|  |  | ||||||
| const menu = Menu.buildFromTemplate([{ |  | ||||||
| 		label : 'Close', |  | ||||||
| 		click: () => { |  | ||||||
| 			app.quit(); |  | ||||||
| 			console.log("Closed"); |  | ||||||
| 		} |  | ||||||
| }]); |  | ||||||
|  |  | ||||||
|  | const MainWindow = require("./MainWindow"); | ||||||
|  |  | ||||||
| console.log("Starting..."); | console.log("Starting..."); | ||||||
| app.on('ready', () => { | app.on('ready', () => { | ||||||
|  | 	MainWindow.show(); | ||||||
| 	//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; |  | ||||||
| 	}); |  | ||||||
| }); | }); | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user