mirror of
https://github.com/kuaifan/dootask.git
synced 2025-12-11 18:42:54 +00:00
防止多开
This commit is contained in:
parent
936dee9da5
commit
7841f54db8
25
electron/electron.js
vendored
25
electron/electron.js
vendored
@ -21,6 +21,9 @@ if (fs.existsSync(devloadCachePath)) {
|
|||||||
devloadUrl = fs.readFileSync(devloadCachePath, 'utf8')
|
devloadUrl = fs.readFileSync(devloadCachePath, 'utf8')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建主窗口
|
||||||
|
*/
|
||||||
function createMainWindow() {
|
function createMainWindow() {
|
||||||
mainWindow = new BrowserWindow({
|
mainWindow = new BrowserWindow({
|
||||||
width: 1280,
|
width: 1280,
|
||||||
@ -61,6 +64,7 @@ function createMainWindow() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* 创建子窗口
|
||||||
* @param args {path, hash, title, titleFixed, force, userAgent, config, webPreferences}
|
* @param args {path, hash, title, titleFixed, force, userAgent, config, webPreferences}
|
||||||
*/
|
*/
|
||||||
function createSubWindow(args) {
|
function createSubWindow(args) {
|
||||||
@ -132,12 +136,25 @@ function createSubWindow(args) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
app.whenReady().then(() => {
|
|
||||||
createMainWindow()
|
|
||||||
|
|
||||||
app.on('activate', () => {
|
const getTheLock = app.requestSingleInstanceLock()
|
||||||
if (BrowserWindow.getAllWindows().length === 0) createMainWindow()
|
if (!getTheLock) {
|
||||||
|
app.quit()
|
||||||
|
} else {
|
||||||
|
app.on('second-instance', () => {
|
||||||
|
if (mainWindow) {
|
||||||
|
if (mainWindow.isMinimized()) {
|
||||||
|
mainWindow.restore()
|
||||||
|
}
|
||||||
|
mainWindow.focus()
|
||||||
|
mainWindow.show()
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
app.on('ready', createMainWindow)
|
||||||
|
}
|
||||||
|
|
||||||
|
app.on('activate', () => {
|
||||||
|
if (BrowserWindow.getAllWindows().length === 0) createMainWindow()
|
||||||
})
|
})
|
||||||
|
|
||||||
app.on('window-all-closed', () => {
|
app.on('window-all-closed', () => {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user