Skip to content

Commit

Permalink
no message
Browse files Browse the repository at this point in the history
  • Loading branch information
kuaifan committed Apr 1, 2022
1 parent e0a3259 commit 91f4b2f
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 9 deletions.
36 changes: 29 additions & 7 deletions electron/electron.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,17 +158,19 @@ if (!getTheLock) {
// 创建主窗口
createMainWindow()
// 创建托盘
if (['darwin', 'win32'].includes(process.platform)) {
mainTray = new Tray(process.platform === 'darwin' ? config.trayIcon.mac : config.trayIcon.win);
if (['darwin', 'win32'].includes(process.platform) && utils.isJson(config.trayIcon)) {
mainTray = new Tray(path.join(__dirname, config.trayIcon[devloadUrl ? 'dev' : 'prod'][process.platform === 'darwin' ? 'mac' : '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([{
label: '显示',
click: () => {
utils.setShowWindow(mainWindow)
}
}, {
label: '退出',
click: () => {
app.quit()
Expand Down Expand Up @@ -221,7 +223,7 @@ ipcMain.on('windowRouter', (event, args) => {
})

/**
* 隐藏窗口(mac|win隐藏,其他关闭)
* 隐藏窗口(macwin隐藏,其他关闭)
*/
ipcMain.on('windowHidden', (event) => {
if (['darwin', 'win32'].includes(process.platform)) {
Expand All @@ -242,14 +244,34 @@ ipcMain.on('windowClose', (event) => {
})

/**
* 关闭窗口(强制)
* 销毁窗口
*/
ipcMain.on('windowDestroy', (event) => {
const win = BrowserWindow.fromWebContents(event.sender);
win.destroy()
event.returnValue = "ok"
})

/**
* 关闭所有子窗口
*/
ipcMain.on('subWindowCloseAll', () => {
subWindow.some(item => {
item.close()
})
event.returnValue = "ok"
})

/**
* 销毁所有子窗口
*/
ipcMain.on('subWindowDestroyAll', () => {
subWindow.some(item => {
item.destroy()
})
event.returnValue = "ok"
})

/**
* 设置窗口尺寸
* @param args {width, height, autoZoom, minWidth, minHeight, maxWidth, maxHeight}
Expand Down
10 changes: 8 additions & 2 deletions electron/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,14 @@
"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"
"dev": {
"mac": "../resources/assets/statics/public/images/tray/logo-trayTemplate.png",
"win": "../resources/assets/statics/public/images/logo-app.ico"
},
"prod": {
"mac": "./public/images/tray/logo-trayTemplate.png",
"win": "./public/images/logo-app.ico"
}
},
"build": {
"appId": "com.dootask.task",
Expand Down
4 changes: 4 additions & 0 deletions resources/assets/js/pages/login.vue
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,10 @@ export default {
},
activated() {
this.loginType = 'login'
//
if (this.$Electron) {
this.$Electron.sendMessage('subWindowDestroyAll')
}
},
deactivated() {
this.loginJump = false;
Expand Down

0 comments on commit 91f4b2f

Please sign in to comment.