From f8ca8827a7da7be7258de4f4a531b70d203b2823 Mon Sep 17 00:00:00 2001
From: AkiraFukushima
Date: Sat, 22 May 2021 21:50:45 +0900
Subject: [PATCH] refs #2459 Fix icon path for tray and about window
---
.electron-vue/webpack.renderer.config.js | 3 +--
.electron-vue/webpack.web.config.js | 6 ++++--
package.json | 3 ++-
src/main/index.ts | 10 +++++++---
4 files changed, 14 insertions(+), 8 deletions(-)
diff --git a/.electron-vue/webpack.renderer.config.js b/.electron-vue/webpack.renderer.config.js
index 5ee35dc5..c43579df 100644
--- a/.electron-vue/webpack.renderer.config.js
+++ b/.electron-vue/webpack.renderer.config.js
@@ -12,7 +12,6 @@ const HtmlWebpackPlugin = require('html-webpack-plugin')
const { VueLoaderPlugin } = require('vue-loader')
let rendererConfig = {
- devtool: 'eval-cheap-module-source-map',
entry: {
renderer: path.join(__dirname, '../src/renderer/main.ts')
},
@@ -211,13 +210,13 @@ if (process.env.NODE_ENV !== 'production') {
__static: `"${path.join(__dirname, '../static').replace(/\\/g, '\\\\')}"`
})
)
+ rendererConfig.devtool = 'eval-cheap-module-source-map'
}
/**
* Adjust rendererConfig for production settings
*/
if (process.env.NODE_ENV === 'production') {
- rendererConfig.devtool = ''
rendererConfig.mode = 'production'
rendererConfig.plugins.push(
new CopyWebpackPlugin({
diff --git a/.electron-vue/webpack.web.config.js b/.electron-vue/webpack.web.config.js
index 0d62329a..33bee6cc 100644
--- a/.electron-vue/webpack.web.config.js
+++ b/.electron-vue/webpack.web.config.js
@@ -11,7 +11,6 @@ const HtmlWebpackPlugin = require('html-webpack-plugin')
const { VueLoaderPlugin } = require('vue-loader')
let webConfig = {
- devtool: '#cheap-module-eval-source-map',
entry: {
web: path.join(__dirname, '../src/renderer/main.js')
},
@@ -123,11 +122,14 @@ let webConfig = {
target: 'web'
}
+if (process.env.NODE_ENV !== 'production') {
+ webConfig.devtool = 'eval-cheap-module-source-map'
+}
+
/**
* Adjust webConfig for production settings
*/
if (process.env.NODE_ENV === 'production') {
- webConfig.devtool = ''
webConfig.mode = 'production'
webConfig.plugins.push(
new CopyWebpackPlugin({
diff --git a/package.json b/package.json
index 1741e992..24cf45e7 100644
--- a/package.json
+++ b/package.json
@@ -50,7 +50,8 @@
"output": "build"
},
"extraResources": [
- "build/sounds/*"
+ "build/sounds/*",
+ "build/icons/*"
],
"files": [
"dist/electron/**/*",
diff --git a/src/main/index.ts b/src/main/index.ts
index f66102c8..8aa58d3c 100644
--- a/src/main/index.ts
+++ b/src/main/index.ts
@@ -151,6 +151,10 @@ const accountCache = new AccountCache(accountCachePath)
const soundBasePath =
process.env.NODE_ENV === 'development' ? path.join(__dirname, '../../build/sounds/') : path.join(process.resourcesPath!, 'build/sounds/')
+const iconBasePath =
+ process.env.NODE_ENV === 'development'
+ ? path.resolve(__dirname, '../../build/icons/')
+ : path.resolve(process.resourcesPath!, 'build/icons/')
let launcher: AutoLaunch | null = null
const proxyConfiguration = new ProxyConfiguration(preferencesDBPath)
@@ -309,7 +313,7 @@ async function createWindow() {
height: mainWindowState.height,
backgroundColor: '#fff',
useContentSize: true,
- icon: path.resolve(__dirname, '../../build/icons/256x256.png'),
+ icon: path.join(iconBasePath, '256x256.png'),
autoHideMenuBar: autoHideMenuBar,
webPreferences: {
// It is required to use ipcRenderer in renderer process.
@@ -355,7 +359,7 @@ async function createWindow() {
// Show tray icon only linux and windows.
if (process.platform !== 'darwin') {
// Show tray icon
- tray = new Tray(path.join(__dirname, '../../build/icons/tray_icon.png'))
+ tray = new Tray(path.join(iconBasePath, 'tray_icon.png'))
const trayMenu = TrayMenu(accountsChange, i18next)
tray.setContextMenu(trayMenu)
@@ -1303,7 +1307,7 @@ const ApplicationMenu = (accountsChange: Array, menu
role: 'about',
click: () => {
openAboutWindow({
- icon_path: path.resolve(__dirname, '../../build/icons/256x256.png'),
+ icon_path: path.join(iconBasePath, '256x256.png'),
copyright: 'Copyright (c) 2020 AkiraFukushima',
package_json_dir: path.resolve(__dirname, '../../'),
open_devtools: process.env.NODE_ENV !== 'production'