|
@@ -1,4 +1,5 @@
|
|
|
import { app, BrowserWindow,screen } from 'electron'
|
|
|
+import express from "express"
|
|
|
|
|
|
const electron = require('electron')
|
|
|
const ipc = electron.ipcMain
|
|
@@ -12,10 +13,10 @@ if (process.env.NODE_ENV !== 'development') {
|
|
|
}
|
|
|
|
|
|
let mainWindow
|
|
|
-const winURL = process.env.NODE_ENV === 'development' ? `http://localhost:9080` : `file://${__dirname}/index.html`
|
|
|
+const winURL = process.env.NODE_ENV === 'development' ? `http://localhost:9080` : `http://localhost:8888/index.html`
|
|
|
|
|
|
app.commandLine.appendSwitch('ppapi-flash-path',app.getPath('pepperFlashSystemPlugin'))
|
|
|
-app.commandLine.appendSwitch('ppapi-flash-version', '32.0.0.363')
|
|
|
+// app.commandLine.appendSwitch('ppapi-flash-version', '32.0.0.363')
|
|
|
|
|
|
function createWindow () {
|
|
|
|
|
@@ -34,7 +35,7 @@ function createWindow () {
|
|
|
autoHideMenuBar: true,
|
|
|
webPreferences: {
|
|
|
// 使用插件
|
|
|
- 'plugins': true,
|
|
|
+ plugins: true,
|
|
|
// 允许跨域
|
|
|
webSecurity: false,
|
|
|
// 渲染进程是否使用node
|
|
@@ -59,8 +60,12 @@ function createWindow () {
|
|
|
})
|
|
|
|
|
|
mainWindow.on('closed', () => {
|
|
|
- mainWindow = null
|
|
|
+ mainWindow = null
|
|
|
})
|
|
|
+
|
|
|
+ if (process.env.NODE_ENV === "production") {
|
|
|
+ localServer()
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
app.on('ready', createWindow)
|
|
@@ -86,3 +91,9 @@ ipc.on('window-min',function(){
|
|
|
ipc.on('window-close',function() {
|
|
|
mainWindow.close()
|
|
|
})
|
|
|
+
|
|
|
+function localServer() {
|
|
|
+ let server = express()
|
|
|
+ server.use(express.static(__dirname))
|
|
|
+ server.listen(8888)
|
|
|
+}
|