修改打包
parent
4aad547a7a
commit
526c7f88a4
@ -1,14 +1,26 @@
|
||||
const { app, BrowserWindow } = require('electron');
|
||||
import { app, BrowserWindow } from 'electron'
|
||||
import path from 'path'
|
||||
import { fileURLToPath } from 'url'
|
||||
|
||||
const __filename = fileURLToPath(import.meta.url)
|
||||
const __dirname = path.dirname(__filename)
|
||||
|
||||
function createWindow() {
|
||||
const win = new BrowserWindow({
|
||||
width: 1000,
|
||||
height: 700,
|
||||
width: 800,
|
||||
height: 600,
|
||||
webPreferences: {
|
||||
nodeIntegration: true
|
||||
preload: path.join(__dirname, 'preload.js'), // preload 文件
|
||||
contextIsolation: true,
|
||||
nodeIntegration: false
|
||||
}
|
||||
});
|
||||
win.loadFile('dist/index.html'); // Vue 打包后的文件
|
||||
})
|
||||
|
||||
if (process.env.NODE_ENV === 'development') {
|
||||
win.loadURL('http://localhost:5173')
|
||||
} else {
|
||||
win.loadFile(path.join(__dirname, 'dist/index.html'))
|
||||
}
|
||||
}
|
||||
|
||||
app.whenReady().then(createWindow);
|
||||
app.whenReady().then(createWindow)
|
||||
|
@ -0,0 +1,6 @@
|
||||
const { contextBridge, ipcRenderer } = require('electron')
|
||||
|
||||
contextBridge.exposeInMainWorld('electronAPI', {
|
||||
send: (channel, data) => ipcRenderer.send(channel, data),
|
||||
on: (channel, func) => ipcRenderer.on(channel, (event, ...args) => func(...args))
|
||||
})
|
Loading…
Reference in New Issue