mirror of
https://github.com/pierre42100/ComunicDesktop
synced 2024-12-25 02:18:51 +00:00
Ready to inject CSS in app
This commit is contained in:
parent
250a4544ab
commit
0ec6cf80db
5
app.css
Normal file
5
app.css
Normal file
@ -0,0 +1,5 @@
|
||||
/**
|
||||
* Comunic WebApp custom stylesheet
|
||||
*
|
||||
* @author Comunic authors
|
||||
*/
|
@ -10,6 +10,7 @@ const {Menu, Tray} = require('electron');
|
||||
const Config = require("../Config");
|
||||
const TrayMenu = require("./TrayMenu");
|
||||
const ApplicationMenu = require("./ApplicationMenu");
|
||||
const fs = require("fs");
|
||||
|
||||
|
||||
let mainWindow;
|
||||
@ -58,5 +59,21 @@ exports.show = function(){
|
||||
|
||||
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);");
|
||||
|
||||
});
|
||||
});
|
||||
}
|
Loading…
Reference in New Issue
Block a user