feat: icon settings
This commit is contained in:
@@ -20,12 +20,15 @@
|
|||||||
"!**/{npm-debug.log,yarn.lock,.yarn-integrity,.yarn-metadata.json}"
|
"!**/{npm-debug.log,yarn.lock,.yarn-integrity,.yarn-metadata.json}"
|
||||||
],
|
],
|
||||||
"linux": {
|
"linux": {
|
||||||
|
"icon": "dist/build/static/icons/icon.png",
|
||||||
"target": ["AppImage"]
|
"target": ["AppImage"]
|
||||||
},
|
},
|
||||||
"mac": {
|
"mac": {
|
||||||
|
"icon": "dist/build/static/icons/icon.png",
|
||||||
"target": ["dmg"]
|
"target": ["dmg"]
|
||||||
},
|
},
|
||||||
"win": {
|
"win": {
|
||||||
|
"icon": "dist/build/static/icons/icon.png",
|
||||||
"target": ["NSIS"]
|
"target": ["NSIS"]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
{
|
{
|
||||||
|
"staticSourceDirectory": "src/static",
|
||||||
"main": {
|
"main": {
|
||||||
"extraEntries": ["@/preload.js"],
|
"extraEntries": ["@/preload.js"],
|
||||||
"sourceDirectory": "dist/electron"
|
"sourceDirectory": "dist/electron"
|
||||||
|
|||||||
@@ -16,7 +16,7 @@
|
|||||||
"e2e": "yarn ng:e2e && yarn electron:e2e",
|
"e2e": "yarn ng:e2e && yarn electron:e2e",
|
||||||
"start": "del -f dist && npm-run-all -p ng:serve electron:serve",
|
"start": "del -f dist && npm-run-all -p ng:serve electron:serve",
|
||||||
"build:dist": "del -f dist && yarn ng:build && yarn electron:build",
|
"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",
|
"build": "yarn build:dist && yarn build:copy && cd dist/build && yarn --prod",
|
||||||
"package": "yarn build && electron-builder"
|
"package": "yarn build && electron-builder"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1,9 +1,11 @@
|
|||||||
import { app, BrowserWindow, ipcMain } from 'electron';
|
import { app, BrowserWindow, ipcMain, nativeImage } from 'electron';
|
||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
import * as url from 'url';
|
import * as url from 'url';
|
||||||
import { AbstractService } from '../services/abstract-service';
|
import { AbstractService } from '../services/abstract-service';
|
||||||
import { MultiplesService } from '../services/multiples-service';
|
import { MultiplesService } from '../services/multiples-service';
|
||||||
|
|
||||||
|
declare const __static: string;
|
||||||
|
|
||||||
export class Window {
|
export class Window {
|
||||||
private _window: BrowserWindow | any;
|
private _window: BrowserWindow | any;
|
||||||
private _dev: boolean;
|
private _dev: boolean;
|
||||||
@@ -14,7 +16,7 @@ export class Window {
|
|||||||
this._e2e = process.env.X_NODE_ENV === 'e2e-test';
|
this._e2e = process.env.X_NODE_ENV === 'e2e-test';
|
||||||
|
|
||||||
this.createWindow();
|
this.createWindow();
|
||||||
this.loadRender();
|
this.loadRenderer();
|
||||||
this.registerService(MultiplesService);
|
this.registerService(MultiplesService);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -23,6 +25,7 @@ export class Window {
|
|||||||
width: 800,
|
width: 800,
|
||||||
height: 600,
|
height: 600,
|
||||||
backgroundColor: '#FFFFFF',
|
backgroundColor: '#FFFFFF',
|
||||||
|
icon: this._dev ? this.loadIcon() : null,
|
||||||
webPreferences: {
|
webPreferences: {
|
||||||
// Default behavior in Electron since 5, that
|
// Default behavior in Electron since 5, that
|
||||||
// limits the powers granted to remote content
|
// 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) {
|
if (this._dev) {
|
||||||
// Dev mode, take advantage of the live reload by loading local URL
|
// Dev mode, take advantage of the live reload by loading local URL
|
||||||
this.window.loadURL(`http://localhost:4200`);
|
this.window.loadURL(`http://localhost:4200`);
|
||||||
@@ -55,7 +69,7 @@ export class Window {
|
|||||||
this.window.loadURL(indexPath);
|
this.window.loadURL(indexPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Delete current reference when the window is closed
|
// Delete current reference when the window is closed`
|
||||||
this._window.on('closed', () => {
|
this._window.on('closed', () => {
|
||||||
delete this._window;
|
delete this._window;
|
||||||
});
|
});
|
||||||
|
|||||||
BIN
src/static/icons/icon.png
Normal file
BIN
src/static/icons/icon.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 78 KiB |
Reference in New Issue
Block a user