Skip to content

Instantly share code, notes, and snippets.

@ajafff
Created March 28, 2023 10:06
Show Gist options
  • Save ajafff/8d9e8eb8cc0a7ec2297f2445c54f5526 to your computer and use it in GitHub Desktop.
Save ajafff/8d9e8eb8cc0a7ec2297f2445c54f5526 to your computer and use it in GitHub Desktop.
plain text background
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Hello World!</title>
</head>
<body>
<h1>Hello World!</h1>
<a href="./plain.txt" target="_blank">click me</a>
</body>
</html>
// Modules to control application life and create native browser window
const {app, BrowserWindow, nativeTheme} = require('electron')
const fs = require('fs');
nativeTheme.themeSource = "dark";
fs.writeFileSync("plain.txt", "hello world");
app.on('web-contents-created', (_, wc) => {
// comment out this line to make dark background work
wc.setWindowOpenHandler(() => ({action: 'allow'}))
})
function createWindow () {
// Create the browser window.
const mainWindow = new BrowserWindow({
width: 800,
height: 600,
})
// and load the index.html of the app.
mainWindow.loadFile('index.html')
}
app.whenReady().then(() => {
createWindow()
})
{
"name": "encouraging-bottle-accept-nhaux",
"productName": "encouraging-bottle-accept-nhaux",
"description": "My Electron application description",
"keywords": [],
"main": "./main.js",
"version": "1.0.0",
"author": "klaus.meinhardt",
"scripts": {
"start": "electron ."
},
"dependencies": {},
"devDependencies": {
"electron": "22.0.0"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment