Created
May 23, 2022 14:03
-
-
Save cupools/9336a79b76ef5da2b61105a63c796824 to your computer and use it in GitHub Desktop.
crashReporter.crash demo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!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>. | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { app, BrowserWindow, crashReporter } = require('electron') | |
const path = require('path') | |
const child_process = require('child_process') | |
const createWindow = () => { | |
const mainWindow = new BrowserWindow({ | |
width: 800, | |
height: 600, | |
}) | |
mainWindow.loadFile('index.html') | |
} | |
app.whenReady().then(() => { | |
console.time('crashReporter') | |
crashReporter.start({ submitURL: 'https://your-domain.com/url-to-submit' }) | |
console.timeEnd('crashReporter') | |
// => crashReporter: 762.32ms | |
console.time('spawn') | |
child_process.spawn('ls') | |
console.timeEnd('spawn') | |
// => spawn: 3.836ms | |
console.time('spawnSync') | |
child_process.spawnSync('ls') | |
console.timeEnd('spawnSync') | |
// => spawnSync: 8.794ms | |
createWindow() | |
app.on('activate', () => { | |
if (BrowserWindow.getAllWindows().length === 0) createWindow() | |
}) | |
}) | |
app.on('window-all-closed', () => { | |
if (process.platform !== 'darwin') app.quit() | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "electron-test", | |
"version": "1.0.0", | |
"description": "", | |
"main": "main.js", | |
"scripts": { | |
"start": "electron ." | |
}, | |
"author": "", | |
"license": "ISC", | |
"dependencies": { | |
"electron": "^18.2.4" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment