xudaolong
2021-06-03 10:07:42 +08:00
类似代码,仅做参考
```
const getSize = debounce(() => {
const win = BrowserWindow.getFocusedWindow()
const [width, height] = win.getSize()
return { win, width, height }
}, 500, {
'leading': true,
'trailing': false
})
ipcMain.on('windowMoving', (e, { mouseX, mouseY }) => {
const { x, y } = screen.getCursorScreenPoint()
const { win, width, height } = getSize()
if (win && !win.isMaximized()) {
win.setBounds({
width,
height,
x: x - mouseX,
y: y - mouseY
})
}
})
```