40 lines
832 B
TypeScript
40 lines
832 B
TypeScript
import { app, globalShortcut, BrowserWindow } from 'electron'
|
|
import { join } from "path"
|
|
|
|
function createWindow() {
|
|
const win = new BrowserWindow({
|
|
fullscreen: true,
|
|
frame: false,
|
|
webPreferences: {
|
|
nodeIntegration: true,
|
|
preload: join(__dirname, 'preload.js')
|
|
}
|
|
})
|
|
|
|
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()
|
|
|
|
// 屏蔽 F11 进入/退出全屏功能
|
|
globalShortcut.register('F11', () => {return})
|
|
})
|
|
|
|
app.on('window-all-closed', () => {
|
|
if (process.platform !== 'darwin') {
|
|
app.quit()
|
|
}
|
|
})
|
|
|
|
app.on('activate', () => {
|
|
if (BrowserWindow.getAllWindows().length === 0) {
|
|
createWindow()
|
|
}
|
|
})
|