fix: change the public path, fix image resource not loaded in production

This commit is contained in:
leejooy96 committed 2025-04-26 22:13:48 +09:00
1 parent 140d7a8f37
commit 0869610372
5 files changed
+10 -3

No files matched your search

+2 -1
View File
@@ -1,6 +1,7 @@
import { app, screen, Menu, Tray, BrowserWindow } from 'electron' import { app, screen, Menu, Tray, BrowserWindow } from 'electron'
import Constants from './utils/Constants' import Constants from './utils/Constants'
import { debounce } from './utils/Util' import { debounce } from './utils/Util'
import { join } from 'path'
let tray let tray
let trayOptions let trayOptions
@@ -11,7 +12,7 @@ export function createTray(window: BrowserWindow, options) {
trayOptions.menu = false trayOptions.menu = false
} }
tray = new Tray('buildAssets/icons/icon16.png') tray = new Tray(join(Constants.PUBLIC_PATH, 'images/vutron-tray-icon.png'))
tray.setToolTip(trayOptions.tooltip) tray.setToolTip(trayOptions.tooltip)
if (trayOptions.menu) { if (trayOptions.menu) {
const contextMenu = Menu.buildFromTemplate([ const contextMenu = Menu.buildFromTemplate([
+5 -1
View File
@@ -1,4 +1,4 @@
import { join, dirname } from 'path' import { join, dirname, resolve } from 'path'
import { name, version, debug } from '../../../package.json' import { name, version, debug } from '../../../package.json'
import { fileURLToPath } from 'url' import { fileURLToPath } from 'url'
@@ -21,6 +21,10 @@ export default class Constants {
static IS_DEV_ENV = process.env.NODE_ENV === 'development' static IS_DEV_ENV = process.env.NODE_ENV === 'development'
static PUBLIC_PATH = Constants.IS_DEV_ENV
? resolve(__dirname, '../../src/public')
: resolve(__dirname, '..')
// To show devtools at startup. It requires IS_DEV_ENV=true. // To show devtools at startup. It requires IS_DEV_ENV=true.
// Note: For debugging purpose, window won't be closed if click elsewhere, if devtools is open. // Note: For debugging purpose, window won't be closed if click elsewhere, if devtools is open.
static IS_DEVTOOLS = true static IS_DEVTOOLS = true
Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

+3 -1
View File
@@ -33,8 +33,10 @@ export default defineConfig(({ mode }) => {
}, },
vite: { vite: {
root: resolve('.'), root: resolve('.'),
base: './',
build: { build: {
assetsDir: '.', assetsDir: '.',
publicDir: resolve('./src/public'),
outDir: 'dist/main', outDir: 'dist/main',
rollupOptions: { rollupOptions: {
external: ['electron', ...builtinModules] external: ['electron', ...builtinModules]
@@ -82,7 +84,7 @@ export default defineConfig(({ mode }) => {
}, },
base: './', base: './',
root: resolve('./src/renderer'), root: resolve('./src/renderer'),
publicDir: resolve('./src/renderer/public'), publicDir: resolve('./src/public'),
clearScreen: false, clearScreen: false,
build: { build: {
sourcemap: isDevEnv, sourcemap: isDevEnv,