Skip to content

Commit

Permalink
Fixed link to tray icons
Browse files Browse the repository at this point in the history
  • Loading branch information
ransome1 committed Sep 23, 2023
1 parent 27d24c8 commit ec37b1b
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 10 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@
"asar": true,
"asarUnpack": "**\\*.{node,dll}",
"files": [
"assets/icons/tray",
"dist",
"node_modules",
"package.json"
Expand Down
9 changes: 1 addition & 8 deletions src/main/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { configStorage } from './config';
import { autoUpdater } from 'electron-updater';
import log from 'electron-log';
import createMenu from './menu';
import { resolveHtmlPath, File } from './util';
import { resolveHtmlPath, getAssetPath, File } from './util';
import createFileWatcher from './modules/FileWatcher';
import { createTray } from './tray';
import './modules/Ipc';
Expand Down Expand Up @@ -52,13 +52,6 @@ const handleMove = () => {
}

const createWindow = async() => {
const RESOURCES_PATH = app.isPackaged
? path.join(process.resourcesPath, 'assets')
: path.join(__dirname, '../../assets');

const getAssetPath = (...paths: string[]): string => {
return path.resolve(RESOURCES_PATH, ...paths);
};
mainWindow = new BrowserWindow({
width: 1280,
height: 1000,
Expand Down
5 changes: 3 additions & 2 deletions src/main/tray.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { app, Tray, Menu } from 'electron';
import { mainWindow, createWindow } from './main';
import { configStorage } from './config';
import { getAssetPath } from './util';
import { setFile } from './modules/File';

let tray;
Expand Down Expand Up @@ -56,8 +57,8 @@ function getMenuTemplate(files) {

function createTray(create) {
try {
tray?.destroy();
if (!create) {
tray?.destroy();
if (app.dock) {
app.dock.show();
}
Expand All @@ -67,7 +68,7 @@ function createTray(create) {
const files = configStorage.get('files') as File[] || [];
const menu = Menu.buildFromTemplate(getMenuTemplate(files));

tray = new Tray('./assets/icons/tray/tray.png');
tray = new Tray(getAssetPath('icons/tray/tray.png'));
tray.setContextMenu(menu);
tray.on('click', (event) => {
if (mainWindow) {
Expand Down
9 changes: 9 additions & 0 deletions src/main/util.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
import { URL } from 'url';
import path from 'path';
import { app } from 'electron';

const RESOURCES_PATH = app.isPackaged
? path.join(process.resourcesPath, 'assets')
: path.join(__dirname, '../../assets');

export const getAssetPath = (...paths: string[]): string => {
return path.resolve(RESOURCES_PATH, ...paths);
};

export function resolveHtmlPath(htmlFileName: string): string {
try {
Expand Down

0 comments on commit ec37b1b

Please sign in to comment.