From: Enrique H. Oliva Date: Thu, 29 Jul 2021 14:04:35 +0000 (-0500) Subject: WIP: tray icon image X-Git-Tag: v2.0.1~8^2~1 X-Git-Url: https://andrewgundersen.net/repos?a=commitdiff_plain;h=refs%2Fheads%2Ftray_menu;p=mime-chat WIP: tray icon image --- diff --git a/package.json b/package.json index b11c9db..3cc50ff 100644 --- a/package.json +++ b/package.json @@ -55,7 +55,7 @@ "@vue/eslint-config-typescript": "^5.0.2", "@vue/test-utils": "^2.0.0-0", "@wasm-tool/wasm-pack-plugin": "^1.3.1", - "electron": "^9.0.0", + "electron": "^8.3.3", "electron-devtools-installer": "^3.1.0", "electron-log": "^4.3.4", "eslint": "^6.7.2", diff --git a/src/images/icon.png b/src/images/icon.png new file mode 100644 index 0000000..b925c06 Binary files /dev/null and b/src/images/icon.png differ diff --git a/src/images/icon@2x.png b/src/images/icon@2x.png new file mode 100644 index 0000000..7bf880c Binary files /dev/null and b/src/images/icon@2x.png differ diff --git a/src/images/icon_32x32.png b/src/images/icon_32x32.png new file mode 100644 index 0000000..7bf880c Binary files /dev/null and b/src/images/icon_32x32.png differ diff --git a/src/images/icon_32x32@2x.png b/src/images/icon_32x32@2x.png new file mode 100644 index 0000000..2a9f925 Binary files /dev/null and b/src/images/icon_32x32@2x.png differ diff --git a/src/main.ts b/src/main.ts index 334a6fe..2cb205c 100644 --- a/src/main.ts +++ b/src/main.ts @@ -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(); diff --git a/yarn.lock b/yarn.lock index e79f19f..55fa251 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5077,10 +5077,10 @@ electron-updater@^4.3.8: lodash.isequal "^4.5.0" semver "^7.3.4" -electron@^9.0.0: - version "9.3.3" - resolved "https://registry.yarnpkg.com/electron/-/electron-9.3.3.tgz#99a6619d5df68f97697a5d1d82ef3a8a63fcdf36" - integrity sha512-xghKeUY1qgnEcJ5w2rXo/toH+8NT2Dktx2aAxBNPV7CIJr3mejJJAPwLbycwtddzr37tgKxHeHlc8ivfKtMkJQ== +electron@^8.3.3: + version "8.5.5" + resolved "https://registry.yarnpkg.com/electron/-/electron-8.5.5.tgz#17b12bd70139c0099f750fc5de0d480bf03acb96" + integrity sha512-e355H+tRDial0m+X2v+l+0SnaATAPw4sNjv9qmdk/6MJz/glteVJwVJEnxTjPfEELIJSChrBWDBVpjdDvoBF4Q== dependencies: "@electron/get" "^1.0.1" "@types/node" "^12.0.12"