mirror of
https://github.com/electron-vite/electron-vite-vue
synced 2025-01-19 11:56:36 +08:00
feat: improve some functions
This commit is contained in:
parent
d13bad26f7
commit
2221092da5
@ -2,6 +2,16 @@ import path from 'path'
|
|||||||
import { app, BrowserWindow } from 'electron'
|
import { app, BrowserWindow } from 'electron'
|
||||||
import { register } from './communication'
|
import { register } from './communication'
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Main Process some code reference https://github.com/cawa-93/vite-electron-builder
|
||||||
|
*/
|
||||||
|
app.disableHardwareAcceleration()
|
||||||
|
|
||||||
|
if (!app.requestSingleInstanceLock()) {
|
||||||
|
app.quit()
|
||||||
|
process.exit(0)
|
||||||
|
}
|
||||||
|
|
||||||
let win: BrowserWindow | null = null
|
let win: BrowserWindow | null = null
|
||||||
|
|
||||||
function bootstrap() {
|
function bootstrap() {
|
||||||
@ -27,5 +37,26 @@ app.whenReady().then(bootstrap)
|
|||||||
|
|
||||||
app.on('window-all-closed', () => {
|
app.on('window-all-closed', () => {
|
||||||
win = null
|
win = null
|
||||||
app.quit()
|
if (process.platform !== 'darwin') {
|
||||||
|
app.quit()
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
app.on('second-instance', () => {
|
||||||
|
if (win) {
|
||||||
|
// someone tried to run a second instance, we should focus our window.
|
||||||
|
if (win.isMinimized()) win.restore()
|
||||||
|
win.focus()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
// auto update
|
||||||
|
if (app.isPackaged) {
|
||||||
|
app.whenReady()
|
||||||
|
.then(() => import('electron-updater'))
|
||||||
|
.then(({ autoUpdater }) => autoUpdater.checkForUpdatesAndNotify())
|
||||||
|
.catch((e) =>
|
||||||
|
// maybe you need to record some log files.
|
||||||
|
console.error('Failed check update:', e)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user