fix: change the public path, fix image resource not loaded in production
This commit is contained in:
1 parent
140d7a8f37
commit
0869610372
5 files changed
+10
-3
No files matched your search
+2
-1
@@ -1,6 +1,7 @@
|
||||
import { app, screen, Menu, Tray, BrowserWindow } from 'electron'
|
||||
import Constants from './utils/Constants'
|
||||
import { debounce } from './utils/Util'
|
||||
import { join } from 'path'
|
||||
let tray
|
||||
let trayOptions
|
||||
|
||||
@@ -11,7 +12,7 @@ export function createTray(window: BrowserWindow, options) {
|
||||
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)
|
||||
if (trayOptions.menu) {
|
||||
const contextMenu = Menu.buildFromTemplate([
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { join, dirname } from 'path'
|
||||
import { join, dirname, resolve } from 'path'
|
||||
import { name, version, debug } from '../../../package.json'
|
||||
import { fileURLToPath } from 'url'
|
||||
|
||||
@@ -21,6 +21,10 @@ export default class Constants {
|
||||
|
||||
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.
|
||||
// Note: For debugging purpose, window won't be closed if click elsewhere, if devtools is open.
|
||||
static IS_DEVTOOLS = true
|
||||
|
||||
File renamed without changes.
Binary file not shown.
|
After Width: | Height: | Size: 1.1 KiB |
+3
-1
@@ -33,8 +33,10 @@ export default defineConfig(({ mode }) => {
|
||||
},
|
||||
vite: {
|
||||
root: resolve('.'),
|
||||
base: './',
|
||||
build: {
|
||||
assetsDir: '.',
|
||||
publicDir: resolve('./src/public'),
|
||||
outDir: 'dist/main',
|
||||
rollupOptions: {
|
||||
external: ['electron', ...builtinModules]
|
||||
@@ -82,7 +84,7 @@ export default defineConfig(({ mode }) => {
|
||||
},
|
||||
base: './',
|
||||
root: resolve('./src/renderer'),
|
||||
publicDir: resolve('./src/renderer/public'),
|
||||
publicDir: resolve('./src/public'),
|
||||
clearScreen: false,
|
||||
build: {
|
||||
sourcemap: isDevEnv,
|
||||
|
||||
Reference in new issue
Block a user