mirror of
https://github.com/pierre42100/ComunicDesktop
synced 2025-04-09 02:20:54 +00:00
Compare commits
16 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
b6a4c1b1ee | ||
0ec6cf80db | |||
250a4544ab | |||
cb3867584f | |||
64f82bf087 | |||
5567ea7501 | |||
e01f521192 | |||
33b8e4e2b6 | |||
24643f0867 | |||
484813ff4d | |||
ee02924124 | |||
fd006da615 | |||
![]() |
594b07360f | ||
![]() |
60119b81e4 | ||
![]() |
6d06b71b78 | ||
![]() |
e86d694861 |
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
node_modules/*
|
14
Config.js
Normal file
14
Config.js
Normal file
@ -0,0 +1,14 @@
|
||||
/**
|
||||
* Project configuration
|
||||
*/
|
||||
|
||||
const Config = {
|
||||
|
||||
/**
|
||||
* URL to access to Comunic
|
||||
*/
|
||||
access_url: 'https://comunic.io'
|
||||
|
||||
}
|
||||
|
||||
module.exports = Config;
|
2
LICENSE
2
LICENSE
@ -1,6 +1,6 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2018 Pierre Hubert
|
||||
Copyright (c) 2018 The Comunic Project
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
@ -3,7 +3,7 @@
|
||||
## Using for dev
|
||||
Please make sure you have installed npm on your computer.
|
||||
|
||||
git clone https://github.com/pierre42100/ComunicDesktop
|
||||
git clone https://github.com/pierre42100/ComunicDesktop.git
|
||||
npm i --save electron
|
||||
npm install
|
||||
electron index.js
|
||||
|
5
app.css
Normal file
5
app.css
Normal file
@ -0,0 +1,5 @@
|
||||
/**
|
||||
* Comunic WebApp custom stylesheet
|
||||
*
|
||||
* @author Comunic authors
|
||||
*/
|
BIN
icon.png
BIN
icon.png
Binary file not shown.
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 8.4 KiB |
75
index.js
75
index.js
@ -1,69 +1,14 @@
|
||||
const electron = require('electron');
|
||||
const BrowserWindow = electron.BrowserWindow;
|
||||
const {app, Menu, Tray} = require('electron')
|
||||
/**
|
||||
* Application main script
|
||||
*
|
||||
* @author The Comunic Authors
|
||||
*/
|
||||
|
||||
let mainWindow
|
||||
let tray = null
|
||||
const {app} = require('electron');
|
||||
|
||||
function main(){
|
||||
mainWindow = new BrowserWindow({
|
||||
icon:'icon.png',
|
||||
webPreferences :{
|
||||
nodeIntegration :false
|
||||
},
|
||||
show: false
|
||||
});
|
||||
mainWindow.maximize();
|
||||
//createWindow --> create the window
|
||||
mainWindow.loadURL('https://comunic.io');
|
||||
//set the url who must be open
|
||||
|
||||
mainWindow.on('closed', () =>{
|
||||
mainWindow = null;
|
||||
});
|
||||
//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");
|
||||
}
|
||||
}]);
|
||||
const MainWindow = require("./modules/MainWindow");
|
||||
|
||||
console.log("Starting...");
|
||||
app.on('ready', main);
|
||||
app.on('ready', () => {
|
||||
MainWindow.show();
|
||||
});
|
||||
|
136
modules/ApplicationMenu.js
Normal file
136
modules/ApplicationMenu.js
Normal file
@ -0,0 +1,136 @@
|
||||
/**
|
||||
* Application menu
|
||||
*
|
||||
* @author Comunic Authors
|
||||
*/
|
||||
|
||||
const {app, Menu} = require('electron');
|
||||
|
||||
/**
|
||||
* Get application menu
|
||||
*
|
||||
* @param {BrowserWindow} window
|
||||
* @return {Menu} Application menu
|
||||
*/
|
||||
module.exports.Get = function(window){
|
||||
|
||||
/**
|
||||
* Execute javascript quickly
|
||||
*/
|
||||
let js = function(code) {window.webContents.executeJavaScript(code)};
|
||||
|
||||
|
||||
return Menu.buildFromTemplate([
|
||||
|
||||
//File menu
|
||||
{
|
||||
label: "File",
|
||||
submenu: [
|
||||
|
||||
//Close app
|
||||
{
|
||||
label: "Quit",
|
||||
click: () => {
|
||||
app.quit();
|
||||
}
|
||||
}
|
||||
|
||||
]
|
||||
},
|
||||
|
||||
|
||||
//Shorcuts menu
|
||||
{
|
||||
label: "Shorcuts",
|
||||
submenu: [
|
||||
|
||||
|
||||
//Latest posts
|
||||
{
|
||||
label: "Latest posts",
|
||||
click: () => {
|
||||
js("openPage('latest');");
|
||||
}
|
||||
},
|
||||
|
||||
//User page
|
||||
{
|
||||
label: "Your page",
|
||||
click: () => {
|
||||
js("openPage('user/' + userID());");
|
||||
}
|
||||
},
|
||||
|
||||
//Conversations
|
||||
{
|
||||
label: "Conversations",
|
||||
click: () => {
|
||||
js("openPage('conversations');");
|
||||
}
|
||||
},
|
||||
|
||||
//Groups
|
||||
{
|
||||
label: "Groups",
|
||||
click: () => {
|
||||
js("openPage('groups');");
|
||||
}
|
||||
}
|
||||
|
||||
]
|
||||
},
|
||||
|
||||
//Settings menu
|
||||
{
|
||||
label: "Settings",
|
||||
submenu: [
|
||||
|
||||
//Dark mode
|
||||
{
|
||||
label: "Toggle dark mode",
|
||||
click: () => {
|
||||
js("ComunicWeb.components.darkTheme.setEnabled(!ComunicWeb.components.darkTheme.isEnabled());");
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
//Incognito mode
|
||||
{
|
||||
label: "Enable incognito mode",
|
||||
sublabel: "F6",
|
||||
click: () => {
|
||||
js("ComunicWeb.components.incognito.ui.confirmEnable();");
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
//Account settings
|
||||
{
|
||||
label: "Account settings",
|
||||
click: () => {
|
||||
js("openPage('settings');");
|
||||
}
|
||||
}
|
||||
|
||||
]
|
||||
},
|
||||
|
||||
|
||||
//Advanced menu
|
||||
{
|
||||
label: "Advanced",
|
||||
submenu: [
|
||||
|
||||
//Dev tools
|
||||
{
|
||||
label: "Toggle developer tools",
|
||||
click: () => {
|
||||
window.webContents.toggleDevTools();
|
||||
}
|
||||
}
|
||||
|
||||
]
|
||||
}
|
||||
])
|
||||
|
||||
}
|
79
modules/MainWindow.js
Normal file
79
modules/MainWindow.js
Normal file
@ -0,0 +1,79 @@
|
||||
/**
|
||||
* Main Window script
|
||||
*
|
||||
* @author The Comunic authors
|
||||
*/
|
||||
|
||||
const electron = require('electron');
|
||||
const BrowserWindow = electron.BrowserWindow;
|
||||
const {Menu, Tray} = require('electron');
|
||||
const Config = require("../Config");
|
||||
const TrayMenu = require("./TrayMenu");
|
||||
const ApplicationMenu = require("./ApplicationMenu");
|
||||
const fs = require("fs");
|
||||
|
||||
|
||||
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");
|
||||
|
||||
//Set application menu
|
||||
Menu.setApplicationMenu(ApplicationMenu.Get(mainWindow));
|
||||
|
||||
mainWindow.once('ready-to-show', () => {
|
||||
mainWindow.show();
|
||||
});
|
||||
|
||||
mainWindow.webContents.on('did-finish-load', function() {
|
||||
page_finished_loading = true;
|
||||
|
||||
//Inject CSS
|
||||
fs.readFile("./app.css", (err, data) => {
|
||||
|
||||
//Check for errors
|
||||
if(err){
|
||||
console.error("Error while loading ./app.css: " + err);
|
||||
return;
|
||||
}
|
||||
|
||||
let style = data.toString();
|
||||
mainWindow.webContents.executeJavaScript("let style = document.createElement('style');" +
|
||||
"style.innerHTML = decodeURIComponent(\""+encodeURIComponent(style)+"\");" +
|
||||
"document.head.appendChild(style);");
|
||||
|
||||
});
|
||||
});
|
||||
}
|
14
modules/TrayMenu.js
Normal file
14
modules/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");
|
||||
}
|
||||
}]);
|
1210
package-lock.json
generated
Normal file
1210
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
@ -4,12 +4,13 @@
|
||||
"description": "A client-desktop for communiquons.org",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"test": "electron ."
|
||||
"test": "electron .",
|
||||
"run": "electron index.js"
|
||||
},
|
||||
"author": "Team dev communic",
|
||||
"license": "GPL-3.0",
|
||||
"dependencies": {},
|
||||
"devDependencies": {
|
||||
"electron": "^2.0.0"
|
||||
"electron": "^3.1.3"
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user