mirror of
https://github.com/Kuingsmile/PicList.git
synced 2026-09-07 08:26:57 +08:00
Fixed: #128 || tray window display bug in multi screen
This commit is contained in:
+6
-19
@@ -102,7 +102,7 @@ function createTray () {
|
|||||||
}
|
}
|
||||||
tray.popUpContextMenu(contextMenu)
|
tray.popUpContextMenu(contextMenu)
|
||||||
})
|
})
|
||||||
tray.on('click', () => {
|
tray.on('click', (event, bounds) => {
|
||||||
if (process.platform === 'darwin') {
|
if (process.platform === 'darwin') {
|
||||||
let img = clipboard.readImage()
|
let img = clipboard.readImage()
|
||||||
let obj = []
|
let obj = []
|
||||||
@@ -115,7 +115,7 @@ function createTray () {
|
|||||||
imgUrl
|
imgUrl
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
toggleWindow()
|
toggleWindow(bounds)
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
window.webContents.send('clipboardFiles', obj)
|
window.webContents.send('clipboardFiles', obj)
|
||||||
}, 0)
|
}, 0)
|
||||||
@@ -301,29 +301,16 @@ const createMenu = () => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const getWindowPosition = () => {
|
const toggleWindow = (bounds) => {
|
||||||
const windowBounds = window.getBounds()
|
|
||||||
const trayBounds = tray.getBounds()
|
|
||||||
const x = Math.round(trayBounds.x + (trayBounds.width / 2) - (windowBounds.width / 2))
|
|
||||||
const y = Math.round(trayBounds.y + trayBounds.height - 10)
|
|
||||||
|
|
||||||
return {
|
|
||||||
x,
|
|
||||||
y
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const toggleWindow = () => {
|
|
||||||
if (window.isVisible()) {
|
if (window.isVisible()) {
|
||||||
window.hide()
|
window.hide()
|
||||||
} else {
|
} else {
|
||||||
showWindow()
|
showWindow(bounds)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const showWindow = () => {
|
const showWindow = (bounds) => {
|
||||||
const position = getWindowPosition()
|
window.setPosition(bounds.x - 98 + 11, bounds.y, false)
|
||||||
window.setPosition(position.x, position.y, false)
|
|
||||||
window.webContents.send('updateFiles')
|
window.webContents.send('updateFiles')
|
||||||
window.show()
|
window.show()
|
||||||
window.focus()
|
window.focus()
|
||||||
|
|||||||
Reference in New Issue
Block a user