main: fix failed to load static path when is production

This commit is contained in:
leejooy96 committed 2022-06-29 10:01:42 +09:00
1 parent 5a2536355b
commit bca2235211
3 files changed
+16 -10

No files matched your search

+5 -7
View File
@@ -1,16 +1,12 @@
import { app, BrowserWindow } from 'electron'
import path from 'path'
import Constants from './utils/Constants'
const BROWSER_WINDOW_DEFAULT = {
title: Constants.APP_NAME,
icon: path.join(__static, Constants.APP_ICON)
}
import Utils from './utils'
export default class MainRunner {
static async createMainWindow (mainWindow) {
mainWindow = new BrowserWindow({
...BROWSER_WINDOW_DEFAULT,
title: Constants.APP_NAME,
icon: Utils.getAppIcon(),
show: false,
width: Constants.IS_DEV_ENV ? 1500 : 1200,
height: 650,
@@ -52,6 +48,8 @@ export default class MainRunner {
}
errorWindow = new BrowserWindow({
title: Constants.APP_NAME,
icon: Utils.getAppIcon(),
show: false,
resizable: Constants.IS_DEV_ENV,
webPreferences: Constants.DEFAULT_WEB_PREFERENCES
+3 -3
View File
@@ -8,14 +8,14 @@ import * as electronRemote from '@electron/remote/main'
let mainWindow
let errorWindow
app.on('ready', () => {
electronRemote.initialize()
if (!Constants.IS_DEV_ENV) {
global.__static = path.join(path.dirname(fileURLToPath(import.meta.url)), '/static')
.replace(/\\/g, '\\\\')
}
app.on('ready', () => {
electronRemote.initialize()
mainWindow = MainRunner.createMainWindow(mainWindow)
})
+8
View File
@@ -0,0 +1,8 @@
import path from 'path'
import Constants from './Constants'
export default class Utils {
static getAppIcon () {
return path.join(__static, Constants.APP_ICON)
}
}