Skip to content

Instantly share code, notes, and snippets.

@aprilandjan
Created February 15, 2022 05:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aprilandjan/ea01484a19030c73825e8f6569102875 to your computer and use it in GitHub Desktop.
Save aprilandjan/ea01484a19030c73825e8f6569102875 to your computer and use it in GitHub Desktop.
const {app, BrowserWindow} = require('electron')
const path = require('path')
const url = require('url')
let window = null
// Wait until the app is ready
app.once('ready', () => {
// Create a new window
window = new BrowserWindow({
// Set the initial width to 500px
width: 500,
// Set the initial height to 400px
height: 400,
// set the title bar style
titleBarStyle: 'hiddenInset',
// set the background color to black
backgroundColor: "#111",
// Don't show the window until it's ready, this prevents any white flickering
show: false,
resizable: false,
maximizable: false,
fullscreenable: true,
})
window.loadURL(url.format({
pathname: path.join(__dirname, 'index.html'),
protocol: 'file:',
slashes: true
}))
function showWindowProps() {
console.log(`win resizable=${window.resizable}; isMaximizable=${window.isMaximizable()}; isFullScreenable=${window.isFullScreenable()}`);
}
window.once('ready-to-show', () => {
window.show()
showWindowProps();
// win resizable=false; isMaximizable=false; isFullScreenable=true
// The `zoom/fullscreen` button is disabled in window title bar, which mismatched the `isFullScreenable` value
window.setResizable(true)
showWindowProps();
// win resizable=true; isMaximizable=false; isFullScreenable=false
// The `zoom/fullscreen` button is disabled in window title bar
window.setMaximizable(true)
showWindowProps();
// win resizable=true; isMaximizable=true; isFullScreenable=false
// The `zoom/fullscreen` button is enabled in window title bar, which mismatched the `isFullScreenable` value
})
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment