main: fix failed to load static path when is production
This commit is contained in:
1 parent
5a2536355b
commit
bca2235211
3 files changed
+18
-12
No files matched your search
@@ -1,16 +1,12 @@
|
|||||||
import { app, BrowserWindow } from 'electron'
|
import { app, BrowserWindow } from 'electron'
|
||||||
import path from 'path'
|
|
||||||
import Constants from './utils/Constants'
|
import Constants from './utils/Constants'
|
||||||
|
import Utils from './utils'
|
||||||
const BROWSER_WINDOW_DEFAULT = {
|
|
||||||
title: Constants.APP_NAME,
|
|
||||||
icon: path.join(__static, Constants.APP_ICON)
|
|
||||||
}
|
|
||||||
|
|
||||||
export default class MainRunner {
|
export default class MainRunner {
|
||||||
static async createMainWindow (mainWindow) {
|
static async createMainWindow (mainWindow) {
|
||||||
mainWindow = new BrowserWindow({
|
mainWindow = new BrowserWindow({
|
||||||
...BROWSER_WINDOW_DEFAULT,
|
title: Constants.APP_NAME,
|
||||||
|
icon: Utils.getAppIcon(),
|
||||||
show: false,
|
show: false,
|
||||||
width: Constants.IS_DEV_ENV ? 1500 : 1200,
|
width: Constants.IS_DEV_ENV ? 1500 : 1200,
|
||||||
height: 650,
|
height: 650,
|
||||||
@@ -52,6 +48,8 @@ export default class MainRunner {
|
|||||||
}
|
}
|
||||||
|
|
||||||
errorWindow = new BrowserWindow({
|
errorWindow = new BrowserWindow({
|
||||||
|
title: Constants.APP_NAME,
|
||||||
|
icon: Utils.getAppIcon(),
|
||||||
show: false,
|
show: false,
|
||||||
resizable: Constants.IS_DEV_ENV,
|
resizable: Constants.IS_DEV_ENV,
|
||||||
webPreferences: Constants.DEFAULT_WEB_PREFERENCES
|
webPreferences: Constants.DEFAULT_WEB_PREFERENCES
|
||||||
|
|||||||
+5
-5
@@ -8,14 +8,14 @@ import * as electronRemote from '@electron/remote/main'
|
|||||||
let mainWindow
|
let mainWindow
|
||||||
let errorWindow
|
let errorWindow
|
||||||
|
|
||||||
if (!Constants.IS_DEV_ENV) {
|
|
||||||
global.__static = path.join(path.dirname(fileURLToPath(import.meta.url)), '/static')
|
|
||||||
.replace(/\\/g, '\\\\')
|
|
||||||
}
|
|
||||||
|
|
||||||
app.on('ready', () => {
|
app.on('ready', () => {
|
||||||
electronRemote.initialize()
|
electronRemote.initialize()
|
||||||
|
|
||||||
|
if (!Constants.IS_DEV_ENV) {
|
||||||
|
global.__static = path.join(path.dirname(fileURLToPath(import.meta.url)), '/static')
|
||||||
|
.replace(/\\/g, '\\\\')
|
||||||
|
}
|
||||||
|
|
||||||
mainWindow = MainRunner.createMainWindow(mainWindow)
|
mainWindow = MainRunner.createMainWindow(mainWindow)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@@ -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)
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in new issue
Block a user