Minor fixes

This commit is contained in:
argenius 2024-11-10 16:57:02 +01:00
parent f793945a5b
commit 897cc00bb7
5 changed files with 16 additions and 57 deletions

View file

@ -8,10 +8,10 @@ import * as https from 'https';
import { createHash } from 'crypto'; import { createHash } from 'crypto';
import * as tar from 'tar'; import * as tar from 'tar';
import * as os from 'os'; import * as os from 'os';
import * as pidusage from 'pidusage';
import AutoLaunch from './auto-launch'; import AutoLaunch from './auto-launch';
import * as AdmZip from 'adm-zip'; import AdmZip from 'adm-zip';
const pidusage = require('pidusage');
const batteryLevel = require('battery-level'); const batteryLevel = require('battery-level');
const network = require('network'); const network = require('network');
@ -205,7 +205,7 @@ function createWindow(): BrowserWindow {
allowRunningInsecureContent: (serve), allowRunningInsecureContent: (serve),
contextIsolation: true, contextIsolation: true,
devTools: !app.isPackaged, devTools: !app.isPackaged,
sandbox: false sandbox: true
}, },
show: false, show: false,
autoHideMenuBar: true, autoHideMenuBar: true,
@ -495,7 +495,6 @@ function monitorMonerod(): void {
} }
win?.webContents.send('on-monitor-monerod', stats); win?.webContents.send('on-monitor-monerod', stats);
}); });
} }

View file

@ -1,6 +1,5 @@
import { Component } from '@angular/core'; import { Component } from '@angular/core';
import { ElectronService } from './core/services'; import { ElectronService } from './core/services';
import { APP_CONFIG } from '../environments/environment';
import { DaemonService } from './core/services/daemon/daemon.service'; import { DaemonService } from './core/services/daemon/daemon.service';
import { DaemonDataService } from './core/services/daemon/daemon-data.service'; import { DaemonDataService } from './core/services/daemon/daemon-data.service';
import { LogsService } from './pages/logs/logs.service'; import { LogsService } from './pages/logs/logs.service';
@ -26,17 +25,6 @@ export class AppComponent {
private LogService: LogsService, private LogService: LogsService,
private trayService: DaemonTrayService private trayService: DaemonTrayService
) { ) {
console.log('APP_CONFIG', APP_CONFIG);
if (electronService.isElectron) {
console.log(process.env);
console.log('Run in electron');
console.log('Electron ipcRenderer', this.electronService.ipcRenderer);
console.log('NodeJS childProcess', this.electronService.childProcess);
} else {
console.log('Run in browser');
}
this.load().then().catch((error: any) => console.error(error)); this.load().then().catch((error: any) => console.error(error));
} }

View file

@ -509,9 +509,11 @@ export class DaemonDataService {
this._txPoolStats = undefined; this._txPoolStats = undefined;
} }
if (!this.daemonService.settings.offline) {
this._gettingConnections = true; this._gettingConnections = true;
this._connections = await this.daemonService.getConnections(); this._connections = await this.daemonService.getConnections();
this._gettingConnections = false; this._gettingConnections = false;
}
this._lastRefreshHeight = this._daemonInfo.heightWithoutBootstrap; this._lastRefreshHeight = this._daemonInfo.heightWithoutBootstrap;
this._lastRefresh = Date.now(); this._lastRefresh = Date.now();

View file

@ -1,60 +1,31 @@
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
// If you import a module but never use any of the imported values other than as TypeScript types, // If you import a module but never use any of the imported values other than as TypeScript types,
// the resulting javascript file will look as if you never imported the module at all. // the resulting javascript file will look as if you never imported the module at all.
import { ipcRenderer, webFrame } from 'electron';
import * as childProcess from 'child_process'; import * as childProcess from 'child_process';
import * as fs from 'fs'; import * as fs from 'fs';
import { APP_CONFIG } from '../../../../environments/environment';
@Injectable({ @Injectable({
providedIn: 'root' providedIn: 'root'
}) })
export class ElectronService { export class ElectronService {
ipcRenderer!: typeof ipcRenderer;
webFrame!: typeof webFrame;
childProcess!: typeof childProcess; childProcess!: typeof childProcess;
fs!: typeof fs; fs!: typeof fs;
private _isAppImage?: boolean; private _isAppImage?: boolean;
private _isAutoLaunched?: boolean; private _isAutoLaunched?: boolean;
private _online: boolean = false; private _online: boolean = false;
private _isProduction: boolean = false;
public get isProduction(): boolean {
return this._isProduction;
}
constructor() { constructor() {
// Conditional imports
if (this.isElectron) {
this.ipcRenderer = (window as any).require('electron').ipcRenderer;
this.webFrame = (window as any).require('electron').webFrame;
this.fs = (window as any).require('fs');
this.childProcess = (window as any).require('child_process');
this.childProcess.exec('node -v', (error, stdout, stderr) => {
if (error) {
console.error(`error: ${error.message}`);
return;
}
if (stderr) {
console.error(`stderr: ${stderr}`);
return;
}
console.log(`stdout:\n${stdout}`);
});
// Notes :
// * A NodeJS's dependency imported with 'window.require' MUST BE present in `dependencies` of both `app/package.json`
// and `package.json (root folder)` in order to make it work here in Electron's Renderer process (src folder)
// because it will loaded at runtime by Electron.
// * A NodeJS's dependency imported with TS module import (ex: import { Dropbox } from 'dropbox') CAN only be present
// in `dependencies` of `package.json (root folder)` because it is loaded during build phase and does not need to be
// in the final bundle. Reminder : only if not used in Electron's Main process (app folder)
// If you want to use a NodeJS 3rd party deps in Renderer process,
// ipcRenderer.invoke can serve many common use cases.
// https://www.electronjs.org/docs/latest/api/ipc-renderer#ipcrendererinvokechannel-args
}
this._online = navigator.onLine; this._online = navigator.onLine;
window.addEventListener('online', () => this._online = true); window.addEventListener('online', () => this._online = true);
window.addEventListener('offline', () => this._online = false); window.addEventListener('offline', () => this._online = false);
this._isProduction = APP_CONFIG.production;
} }
public get online(): boolean { public get online(): boolean {

View file

@ -327,8 +327,7 @@ export class MiningComponent extends BasePageComponent implements AfterViewInit,
return true; return true;
} catch (error: any) { } catch {
console.debug(error);
return false; return false;
} }
} }