初始提交:实习工作日志系统(设计方案 + Vue3 应用 + Electron 打包)
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
const { app, BrowserWindow, Menu, shell } = require('electron')
|
||||
const path = require('path')
|
||||
|
||||
const DEV_URL = process.env.VITE_DEV_SERVER_URL || ''
|
||||
|
||||
function createWindow() {
|
||||
const win = new BrowserWindow({
|
||||
width: 1240,
|
||||
height: 820,
|
||||
minWidth: 940,
|
||||
minHeight: 620,
|
||||
title: '实习工作日志',
|
||||
icon: path.join(__dirname, '..', 'build', 'icon.png'),
|
||||
autoHideMenuBar: true,
|
||||
backgroundColor: '#FFFFFF',
|
||||
webPreferences: {
|
||||
contextIsolation: true,
|
||||
nodeIntegration: false,
|
||||
spellcheck: false
|
||||
}
|
||||
})
|
||||
Menu.setApplicationMenu(null)
|
||||
win.webContents.setWindowOpenHandler(({ url }) => {
|
||||
if (/^https?:/i.test(url)) shell.openExternal(url)
|
||||
return { action: 'deny' }
|
||||
})
|
||||
if (DEV_URL) {
|
||||
win.loadURL(DEV_URL)
|
||||
} else {
|
||||
win.loadFile(path.join(__dirname, '..', 'dist', 'index.html'))
|
||||
}
|
||||
}
|
||||
|
||||
app.whenReady().then(() => {
|
||||
createWindow()
|
||||
app.on('activate', () => {
|
||||
if (BrowserWindow.getAllWindows().length === 0) createWindow()
|
||||
})
|
||||
})
|
||||
|
||||
app.on('window-all-closed', () => {
|
||||
if (process.platform !== 'darwin') app.quit()
|
||||
})
|
||||
Reference in New Issue
Block a user