WIP: tray icon image

This commit is contained in:
Enrique H. Oliva 2021-07-29 09:04:35 -05:00
commit 95e73f7c28
7 changed files with 34 additions and 5 deletions

BIN
src/images/icon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

BIN
src/images/icon@2x.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4 KiB

BIN
src/images/icon_32x32.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.6 KiB

View file

@ -13,8 +13,37 @@ import initIpcMain from "@/ipc/index";
import { accountAuth } from "./account";
import createWindow from "./window";
import { Menu, Tray } from 'electron';
const nativeImage = require('electron').nativeImage
import path, {resolve} from 'path';
let tray = null
export default async function main() {
// TODO: fix image paths
// currently looking in dist-electron directory
// should be looking in source
console.log(resolve(__dirname, './images', 'icon.png'))
console.log(path.join(__dirname, './images/icon.png'))
try {
const image = nativeImage.createFromPath(resolve(__dirname, 'images', 'icon_16x16.png'));
const urlImage = nativeImage.createFromDataURL('https://github.com/vladimiry-playground/electron-quick-start-tray-issue/blob/master/icon.png');
console.log(image)
console.log(urlImage)
tray = new Tray(resolve(__dirname, 'images', 'icon_16x16.png'))
} catch(e) {
console.log(e)
}
// const contextMenu = Menu.buildFromTemplate([
// { label: 'Item1', type: 'radio' },
// { label: 'Item2', type: 'radio' },
// { label: 'Item3', type: 'radio', checked: true },
// { label: 'Item4', type: 'radio' }
// ])
// tray.setToolTip('This is my application.')
// tray.setContextMenu(contextMenu)
/* initiate controls for frontend to use when needed */
initIpcMain();