feat: icon settings

This commit is contained in:
Amadou Ada DIENE
2020-04-29 18:16:07 +02:00
parent 2559e973dc
commit 720223ec7f
5 changed files with 23 additions and 5 deletions

View File

@@ -20,12 +20,15 @@
"!**/{npm-debug.log,yarn.lock,.yarn-integrity,.yarn-metadata.json}"
],
"linux": {
"icon": "dist/build/static/icons/icon.png",
"target": ["AppImage"]
},
"mac": {
"icon": "dist/build/static/icons/icon.png",
"target": ["dmg"]
},
"win": {
"icon": "dist/build/static/icons/icon.png",
"target": ["NSIS"]
}
}

View File

@@ -1,4 +1,5 @@
{
"staticSourceDirectory": "src/static",
"main": {
"extraEntries": ["@/preload.js"],
"sourceDirectory": "dist/electron"

View File

@@ -16,7 +16,7 @@
"e2e": "yarn ng:e2e && yarn electron:e2e",
"start": "del -f dist && npm-run-all -p ng:serve electron:serve",
"build:dist": "del -f dist && yarn ng:build && yarn electron:build",
"build:copy": "cpy package.json dist/main/* dist/angular/* dist/build",
"build:copy": "cpy package.json dist/main/* dist/angular/* dist/build && cpy static ../dist/build --cwd=src --parents",
"build": "yarn build:dist && yarn build:copy && cd dist/build && yarn --prod",
"package": "yarn build && electron-builder"
},

View File

@@ -1,9 +1,11 @@
import { app, BrowserWindow, ipcMain } from 'electron';
import { app, BrowserWindow, ipcMain, nativeImage } from 'electron';
import * as path from 'path';
import * as url from 'url';
import { AbstractService } from '../services/abstract-service';
import { MultiplesService } from '../services/multiples-service';
declare const __static: string;
export class Window {
private _window: BrowserWindow | any;
private _dev: boolean;
@@ -14,7 +16,7 @@ export class Window {
this._e2e = process.env.X_NODE_ENV === 'e2e-test';
this.createWindow();
this.loadRender();
this.loadRenderer();
this.registerService(MultiplesService);
}
@@ -23,6 +25,7 @@ export class Window {
width: 800,
height: 600,
backgroundColor: '#FFFFFF',
icon: this._dev ? this.loadIcon() : null,
webPreferences: {
// Default behavior in Electron since 5, that
// limits the powers granted to remote content
@@ -40,7 +43,18 @@ export class Window {
});
}
private loadRender(): void {
private loadIcon(): Electron.NativeImage {
const iconPath = path.join(__static, 'icons/icon.png');
console.debug('Icon Path ', iconPath);
const iconObj = nativeImage.createFromPath(iconPath);
// Change dock icon on MacOS
if (iconObj && process.platform === 'darwin') {
app.dock.setIcon(iconObj);
}
return iconObj;
}
private loadRenderer(): void {
if (this._dev) {
// Dev mode, take advantage of the live reload by loading local URL
this.window.loadURL(`http://localhost:4200`);
@@ -55,7 +69,7 @@ export class Window {
this.window.loadURL(indexPath);
}
// Delete current reference when the window is closed
// Delete current reference when the window is closed`
this._window.on('closed', () => {
delete this._window;
});

BIN
src/static/icons/icon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 78 KiB