30 lines
683 B
JavaScript
30 lines
683 B
JavaScript
const { app, BrowserWindow, ipcMain } = require('electron')
|
|
const path = require('path')
|
|
|
|
let mainWindow
|
|
|
|
function createWindow() {
|
|
mainWindow = new BrowserWindow({
|
|
width: 300,
|
|
height: 300,
|
|
transparent: true,
|
|
frame: false,
|
|
webPreferences: {
|
|
preload: path.join(__dirname, 'preload.js'),
|
|
contextIsolation: true
|
|
}
|
|
})
|
|
|
|
// 开发模式加载Vite服务器
|
|
if (process.env.NODE_ENV === 'development') {
|
|
mainWindow.loadURL('http://localhost:5173')
|
|
} else {
|
|
mainWindow.loadFile(path.join(__dirname, '../renderer/dist/index.html'))
|
|
}
|
|
|
|
mainWindow.setIgnoreMouseEvents(true, {
|
|
forward: true
|
|
})
|
|
}
|
|
|
|
app.whenReady().then(createWindow) |