Skip to content

Instantly share code, notes, and snippets.

@lakshyamunjal
Created October 21, 2021 08:38
Show Gist options
  • Save lakshyamunjal/a8f3fe14d88142354f52fc50daaf6bf3 to your computer and use it in GitHub Desktop.
Save lakshyamunjal/a8f3fe14d88142354f52fc50daaf6bf3 to your computer and use it in GitHub Desktop.
Window resize issue in Windows System
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<!-- https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP -->
<meta
http-equiv="Content-Security-Policy"
content="default-src 'self'; script-src 'self'"
/>
<meta
http-equiv="X-Content-Security-Policy"
content="default-src 'self'; script-src 'self'"
/>
<title>Hello World!</title>
</head>
<body>
<h1>Hello World!</h1>
We are using Node.js <span id="node-version"></span>, Chromium
<span id="chrome-version"></span>, and Electron
<span id="electron-version"></span>.
<h2>Steps to reproduce:</h2>
<ol>
<li>Click on Maximize button.</li>
<li>Try to resize the window.</li>
</ol>
<strong>Note:</strong>
<span>Unable to resize the window.</span>
<!-- You can also require other files to run in this process -->
<script src="./renderer.js"></script>
</body>
</html>
const { app, BrowserWindow } = require('electron');
const createWindow = () => {
const win = new BrowserWindow({
width: 700,
height: 500,
maximizable: true,
minimizable: true,
maxWidth: 1040,
maxHeight: 900,
fullscreenable: false,
});
win.setAspectRatio(1);
win.loadFile('index.html');
};
app
.whenReady()
.then(() => {
createWindow();
})
.catch((e) => {
console.log('error : ', e);
});
{
"name": "actual-umbrella-reply-zdhft",
"productName": "actual-umbrella-reply-zdhft",
"description": "My Electron application description",
"keywords": [],
"main": "./main.js",
"version": "1.0.0",
"author": "lakshya",
"scripts": {
"start": "electron ."
},
"dependencies": {},
"devDependencies": {
"electron": "13.1.2"
}
}
// All of the Node.js APIs are available in the preload process.
// It has the same sandbox as a Chrome extension.
window.addEventListener('DOMContentLoaded', () => {
const replaceText = (selector, text) => {
const element = document.getElementById(selector)
if (element) element.innerText = text
}
for (const type of ['chrome', 'node', 'electron']) {
replaceText(`${type}-version`, process.versions[type])
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment