diff --git a/.gitignore b/.gitignore index 8488565a8..71edb63c8 100644 --- a/.gitignore +++ b/.gitignore @@ -24,6 +24,10 @@ pyinstaller/electron/version-data.json pyinstaller/electron/downloadloc.js pyinstaller/electron/node_modules pyinstaller/electron/dist +pyinstaller/electron/fonts +pyinstaller/electron/typography.css +pyinstaller/electron/output.css + .DS_Store .coverage cypress/videos diff --git a/pyinstaller/electron/assets/icon.png b/pyinstaller/electron/assets-dev/app_icon.png similarity index 100% rename from pyinstaller/electron/assets/icon.png rename to pyinstaller/electron/assets-dev/app_icon.png diff --git a/pyinstaller/electron/assets-dev/dock_icon_macos.png b/pyinstaller/electron/assets-dev/dock_icon_macos.png new file mode 100644 index 000000000..5a684b037 Binary files /dev/null and b/pyinstaller/electron/assets-dev/dock_icon_macos.png differ diff --git a/pyinstaller/electron/assets/bitcoin-logo.svg b/pyinstaller/electron/assets/bitcoin-logo.svg deleted file mode 100644 index ed9b3b449..000000000 --- a/pyinstaller/electron/assets/bitcoin-logo.svg +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/pyinstaller/electron/assets/menu_icon.png b/pyinstaller/electron/assets/menu_icon.png new file mode 100644 index 000000000..5a684b037 Binary files /dev/null and b/pyinstaller/electron/assets/menu_icon.png differ diff --git a/pyinstaller/electron/icons/icon.icns b/pyinstaller/electron/icons/icon.icns new file mode 100644 index 000000000..4139c5a20 Binary files /dev/null and b/pyinstaller/electron/icons/icon.icns differ diff --git a/pyinstaller/electron/icons/icon.ico b/pyinstaller/electron/icons/icon.ico new file mode 100644 index 000000000..dd924fbd5 Binary files /dev/null and b/pyinstaller/electron/icons/icon.ico differ diff --git a/pyinstaller/electron/icons/icon.iconset/icon_512x512.png b/pyinstaller/electron/icons/icon.iconset/icon_512x512.png new file mode 100644 index 000000000..304360021 Binary files /dev/null and b/pyinstaller/electron/icons/icon.iconset/icon_512x512.png differ diff --git a/pyinstaller/electron/icons/icon.png b/pyinstaller/electron/icons/icon.png new file mode 100644 index 000000000..5a684b037 Binary files /dev/null and b/pyinstaller/electron/icons/icon.png differ diff --git a/pyinstaller/electron/icons/v1-icons/icon-v1.icns b/pyinstaller/electron/icons/v1-icons/icon-v1.icns new file mode 100644 index 000000000..5f1480a73 Binary files /dev/null and b/pyinstaller/electron/icons/v1-icons/icon-v1.icns differ diff --git a/pyinstaller/icons/icon.ico b/pyinstaller/electron/icons/v1-icons/icon-v1.ico similarity index 100% rename from pyinstaller/icons/icon.ico rename to pyinstaller/electron/icons/v1-icons/icon-v1.ico diff --git a/pyinstaller/electron/main.js b/pyinstaller/electron/main.js index 1ea361ede..18963d8e1 100644 --- a/pyinstaller/electron/main.js +++ b/pyinstaller/electron/main.js @@ -25,6 +25,7 @@ ipcMain.handle("showMessageBoxSync", (e, message, buttons) => { // Helper const isMac = process.platform === 'darwin' +const isDev = process.env.NODE_ENV !== "production" // Logging const {transports, format, createLogger } = require('winston') @@ -49,6 +50,11 @@ const winstonOptions = { } const logger = createLogger(winstonOptions) +if (isDev) { + logger.info('Running the Electron app in dev mode.') +} + +logger.info(process.env) let appSettings = getAppSettings() let dimensions = { widIth: 1500, height: 1000 }; @@ -56,13 +62,12 @@ let dimensions = { widIth: 1500, height: 1000 }; const contextMenu = require('electron-context-menu'); const { options } = require('request') -const icon = nativeImage.createFromPath( - app.getAppPath() + "/assets/icon.png" -); - -// Set the dock icon (MacOS only) -if (isMac) { - app.dock.setIcon(icon) +// Set the dock icon (MacOS and for development only) +if (isMac && isDev) { + const dockIcon = nativeImage.createFromPath( + app.getAppPath() + "/assets-dev/dock_icon_macos.png" + ); + app.dock.setIcon(dockIcon) } contextMenu({ @@ -171,8 +176,6 @@ function createWindow (specterURL) { } mainWindow.loadURL(specterURL + '?mode=remote') - // Open the DevTools. - // mainWindow.webContents.openDevTools() } // This method will be called when Electron has finished @@ -208,7 +211,10 @@ app.whenReady().then(() => { nativeTheme.on('updated', updateTrayIcon) } else { - tray = new Tray(icon) + const trayIcon = nativeImage.createFromPath( + app.getAppPath() + "/assets/menu_icon.png" + ); + tray = new Tray(trayIcon) } trayMenu = [ @@ -269,10 +275,13 @@ app.whenReady().then(() => { }) function initMainWindow() { + // In production we use the icons from the build folder + // Note: On MacOS setting an icon here as no effect + const iconPath = isDev ? path.join(__dirname, 'assets-dev/app_icon.png') : "" mainWindow = new BrowserWindow({ width: parseInt(dimensions.width * 0.8), height: parseInt(dimensions.height * 0.8), - icon: path.join(__dirname, 'assets/icon.png'), + icon: iconPath, webPreferences }) diff --git a/pyinstaller/electron/package.json b/pyinstaller/electron/package.json index bf41342b7..feea342d2 100644 --- a/pyinstaller/electron/package.json +++ b/pyinstaller/electron/package.json @@ -1,11 +1,12 @@ { "name": "Specter", "description": "Specter Desktop Electron application", + "version": "v0.0.0", "main": "main.js", "scripts": { "start": "cp -R ../../src/cryptoadvance/specter/static/fonts ../../src/cryptoadvance/specter/static/output.css ../../src/cryptoadvance/specter/static/typography.css . && electron .", "pack": "electron-builder --dir", - "dist": "electron-builder --publish=never", + "dist": "export NODE_ENV=production && electron-builder --publish=never", "postinstall": "electron-builder install-app-deps" }, "repository": "https://github.com/cryptoadvance/specter-desktop", @@ -30,15 +31,17 @@ "identity": "Kim Neunert (FWV59JHV83)", "entitlements": "./build/entitlements.mac.plist", "entitlementsInherit": "./build/entitlements.mac.plist", - "hardenedRuntime": true + "hardenedRuntime": true, + "icon": "./icons/icon.icns" }, "win": { - "icon": "../icons/icon.ico" + "icon": "./icons/icon.ico" }, "linux": { "target": [ "AppImage" - ] + ], + "icon": "./icons/icon.png" } }, "dependencies": {