Browse Source

[ADD] icon fallback

Gogs 6 years ago
parent
commit
2342d718d0
2 changed files with 9 additions and 2 deletions
  1. 9 2
      src/index.js
  2. 0 0
      src/printer.png

+ 9 - 2
src/index.js

@@ -1,4 +1,5 @@
-import { app, ipcMain, BrowserWindow, Menu, Tray } from 'electron'
+import { app, ipcMain, nativeImage, BrowserWindow, Menu, Tray } from 'electron'
+import FileSystem from 'fs'
 import Autolaunch from 'auto-launch'
 import installExtension, { VUEJS_DEVTOOLS } from 'electron-devtools-installer'
 import { enableLiveReload } from 'electron-compile'
@@ -115,7 +116,13 @@ const exitApp = async () => {
  * Create system tray app
  */
 const createTray = async () => {
-    tray = new Tray('printer.png')
+    let icon = `${__dirname}/printer.png`
+
+    if (!FileSystem.existsSync(icon)) {
+        icon = nativeImage.createEmpty()
+    }
+
+    tray = new Tray(icon)
     tray.setToolTip(settings.appName)
 
     const contextMenu = Menu.buildFromTemplate([

+ 0 - 0
printer.png → src/printer.png