显示加载本地文件

This commit is contained in:
叶志超
2021-12-09 15:06:40 +08:00
parent ef9328dc59
commit 35c016bd06
3 changed files with 24 additions and 21 deletions

View File

@@ -1,31 +1,34 @@
import { app, BrowserWindow } from 'electron'
import { join } from "path"
const URL = (process.env.NODE_ENV === 'development') ? 'http://localhost:3000/' : 'http://gnss.cesium.hwasmart.com/'
function createWindow() {
const win = new BrowserWindow({
fullscreen: true,
frame: false,
webPreferences: {
nodeIntegration: true,
preload: join(__dirname, 'preload.js')
}
})
const win = new BrowserWindow({
fullscreen: true,
frame: false,
webPreferences: {
nodeIntegration: true,
preload: join(__dirname, 'preload.js')
}
})
win.loadURL(URL)
if (process.env.NODE_ENV === 'development') {
win.loadURL('http://localhost:3000/')
win.webContents.openDevTools()
} else {
win.loadFile('dist/render/index.html')
}
}
app.whenReady().then(createWindow)
app.on('window-all-closed', () => {
if (process.platform !== 'darwin') {
app.quit()
}
if (process.platform !== 'darwin') {
app.quit()
}
})
app.on('activate', () => {
if (BrowserWindow.getAllWindows().length === 0) {
createWindow()
}
})
if (BrowserWindow.getAllWindows().length === 0) {
createWindow()
}
})