Skip to content

Commit

Permalink
侧边栏拖动宽度最小限制
Browse files Browse the repository at this point in the history
  • Loading branch information
MoNaiZi committed Sep 19, 2022
1 parent 83af3f1 commit 7f56846
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/on.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,14 @@ ipcMain.handle('openLeft', (event, bool = true) => {
const webContents = event.sender
const win: any = BrowserWindow.fromWebContents(webContents)
let bounds = win.getBounds()

win.on('will-resize', (event: any, newBounds: { width: number; height: number, x: number, y: number },) => {
const width = newBounds.width
if (width < 700) event.preventDefault()
})
if (bool) {
bounds.width = bounds.width + 350
bounds.x = bounds.x - 350

// bounds = { x: 806, y: 116, width: 701, height: 600 }
} else {
bounds.width = 350
Expand All @@ -36,6 +40,7 @@ ipcMain.handle('openLeft', (event, bool = true) => {
}
// win.setBackgroundColor('#fff')
// win.setBounds(bounds)

console.log('bounds', bounds)
win.flashFrame(false)
win.setSize(bounds.width, 600)
Expand Down

0 comments on commit 7f56846

Please sign in to comment.