mirror of
https://github.com/kuaifan/dootask.git
synced 2025-12-11 18:42:54 +00:00
no message
This commit is contained in:
parent
38c1a768fc
commit
e0a3259765
19
electron/electron.js
vendored
19
electron/electron.js
vendored
@ -59,7 +59,15 @@ function createMainWindow() {
|
||||
|
||||
mainWindow.on('close', event => {
|
||||
if (!willQuitApp) {
|
||||
utils.onBeforeUnload(event, app)
|
||||
utils.onBeforeUnload(event).then(() => {
|
||||
if (process.platform === 'win32') {
|
||||
mainWindow.hide()
|
||||
} else if (process.platform === 'darwin') {
|
||||
app.hide()
|
||||
} else {
|
||||
app.quit()
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
@ -110,7 +118,9 @@ function createSubWindow(args) {
|
||||
})
|
||||
|
||||
browser.on('close', event => {
|
||||
utils.onBeforeUnload(event)
|
||||
utils.onBeforeUnload(event).then(() => {
|
||||
event.sender.destroy()
|
||||
})
|
||||
})
|
||||
|
||||
browser.on('closed', () => {
|
||||
@ -149,10 +159,13 @@ if (!getTheLock) {
|
||||
createMainWindow()
|
||||
// 创建托盘
|
||||
if (['darwin', 'win32'].includes(process.platform)) {
|
||||
mainTray = new Tray(process.platform === 'darwin' ? config.build.mac.trayIcon : config.build.win.icon);
|
||||
mainTray = new Tray(process.platform === 'darwin' ? config.trayIcon.mac : config.trayIcon.win);
|
||||
mainTray.on('click', () => {
|
||||
utils.setShowWindow(mainWindow)
|
||||
})
|
||||
mainTray.on('double-click', () => {
|
||||
utils.setShowWindow(mainWindow)
|
||||
})
|
||||
mainTray.setToolTip(config.name)
|
||||
if (process.platform === 'win32') {
|
||||
const trayMenu = Menu.buildFromTemplate([{
|
||||
|
||||
@ -47,6 +47,10 @@
|
||||
"fs-extra": "^10.0.1",
|
||||
"pdf-lib": "^1.17.1"
|
||||
},
|
||||
"trayIcon": {
|
||||
"mac": "../resources/assets/statics/public/images/tray/logo-trayTemplate.png",
|
||||
"win": "../resources/assets/statics/public/images/logo-app.ico"
|
||||
},
|
||||
"build": {
|
||||
"appId": "com.dootask.task",
|
||||
"artifactName": "${productName}-v${version}-${os}-${arch}.${ext}",
|
||||
@ -65,7 +69,6 @@
|
||||
"afterSign": "./notarize.js",
|
||||
"mac": {
|
||||
"icon": "../resources/assets/statics/public/images/logo-app.png",
|
||||
"trayIcon": "../resources/assets/statics/public/images/tray/logo-trayTemplate.png",
|
||||
"entitlements": "entitlements.plist",
|
||||
"entitlementsInherit": "entitlements.plist",
|
||||
"category": "public.app-category.productivity",
|
||||
|
||||
41
electron/utils.js
vendored
41
electron/utils.js
vendored
@ -290,33 +290,24 @@ module.exports = {
|
||||
* @param app
|
||||
*/
|
||||
onBeforeUnload(event, app) {
|
||||
const sender = event.sender
|
||||
const contents = sender.webContents
|
||||
if (contents != null) {
|
||||
const destroy = () => {
|
||||
if (typeof app === "undefined") {
|
||||
sender.destroy()
|
||||
} else {
|
||||
if (['darwin', 'win32'].includes(process.platform)) {
|
||||
app.hide()
|
||||
} else {
|
||||
app.quit()
|
||||
return new Promise(resolve => {
|
||||
const sender = event.sender
|
||||
const contents = sender.webContents
|
||||
if (contents != null) {
|
||||
contents.executeJavaScript('if(typeof window.__onBeforeUnload === \'function\'){window.__onBeforeUnload()}', true).then(options => {
|
||||
if (this.isJson(options)) {
|
||||
let choice = dialog.showMessageBoxSync(sender, options)
|
||||
if (choice === 1) {
|
||||
contents.executeJavaScript('if(typeof window.__removeBeforeUnload === \'function\'){window.__removeBeforeUnload()}', true).catch(() => {});
|
||||
resolve()
|
||||
}
|
||||
} else if (options !== true) {
|
||||
resolve()
|
||||
}
|
||||
}
|
||||
})
|
||||
event.preventDefault()
|
||||
}
|
||||
contents.executeJavaScript('if(typeof window.__onBeforeUnload === \'function\'){window.__onBeforeUnload()}', true).then(options => {
|
||||
if (this.isJson(options)) {
|
||||
let choice = dialog.showMessageBoxSync(sender, options)
|
||||
if (choice === 1) {
|
||||
contents.executeJavaScript('if(typeof window.__removeBeforeUnload === \'function\'){window.__removeBeforeUnload()}', true).catch(() => {});
|
||||
destroy()
|
||||
}
|
||||
} else if (options !== true) {
|
||||
destroy()
|
||||
}
|
||||
})
|
||||
event.preventDefault()
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user