Merge branch 'master' of gitea.iwm-tuebingen.de:IWMBrowser/iwmlib

This commit is contained in:
2019-05-24 11:00:38 +02:00
6 changed files with 116 additions and 13 deletions
+31 -4
View File
@@ -1545,6 +1545,12 @@
}
const ipc = null;
try {
ipc = require('electron').ipcRenderer;
} catch (e) {}
/** Basic class for app specific logging requirements.
* Can be used to implement persistent logging in electron apps.
*/
@@ -1553,8 +1559,13 @@
/** Static log function.
* @param {*} message
*/
log(message) {
console.log(message);
static log(message) {
if (ipc) {
ipc.send('log', message);
} else {
console.log(message);
}
}
}
@@ -2684,10 +2695,26 @@
/**
* Distincts if the app is running inside electron or not.
*
* source: https://discuss.atom.io/t/detect-electron-or-web-page-running/33180/3
* source: https://github.com/cheton/is-electron
*/
static get isElectron() {
return typeof process != 'undefined' && process.versions && process.versions.electron !== undefined
// Renderer process
if (typeof window !== 'undefined' && typeof window.process === 'object' && window.process.type === 'renderer') {
return true
}
// Main process
if (typeof process !== 'undefined' && typeof process.versions === 'object' && !!process.versions.electron) {
return true
}
// Detect the user agent when the `nodeIntegration` option is set to true
if (typeof navigator === 'object' && typeof navigator.userAgent === 'string' && navigator.userAgent.indexOf('Electron') >= 0) {
return true
}
return false
}
/** Returns the display resolution. Necessary for retina displays.
+31 -4
View File
@@ -4709,6 +4709,12 @@
// }
}
const ipc = null;
try {
ipc = require('electron').ipcRenderer;
} catch (e) {}
/** Basic class for app specific logging requirements.
* Can be used to implement persistent logging in electron apps.
*/
@@ -4717,8 +4723,13 @@
/** Static log function.
* @param {*} message
*/
log(message) {
console.log(message);
static log(message) {
if (ipc) {
ipc.send('log', message);
} else {
console.log(message);
}
}
}
@@ -5848,10 +5859,26 @@
/**
* Distincts if the app is running inside electron or not.
*
* source: https://discuss.atom.io/t/detect-electron-or-web-page-running/33180/3
* source: https://github.com/cheton/is-electron
*/
static get isElectron() {
return typeof process != 'undefined' && process.versions && process.versions.electron !== undefined
// Renderer process
if (typeof window !== 'undefined' && typeof window.process === 'object' && window.process.type === 'renderer') {
return true
}
// Main process
if (typeof process !== 'undefined' && typeof process.versions === 'object' && !!process.versions.electron) {
return true
}
// Detect the user agent when the `nodeIntegration` option is set to true
if (typeof navigator === 'object' && typeof navigator.userAgent === 'string' && navigator.userAgent.indexOf('Electron') >= 0) {
return true
}
return false
}
/** Returns the display resolution. Necessary for retina displays.