Initial commit

This commit is contained in:
2022-08-06 14:17:27 -04:00
commit d8ebc770be
7 changed files with 106 additions and 0 deletions

34
src/main.ts Normal file
View File

@ -0,0 +1,34 @@
import {app, BrowserWindow} from "electron";
import * as path from "path";
// Window factory
function createWindow() {
const window = new BrowserWindow({
height: 600,
width: 800,
webPreferences: {
preload: path.join(__dirname, "preload.js")
}
});
window.loadFile(path.join(__dirname, "../index.html"));
window.webContents.openDevTools();
}
// Start
app.on("ready", () => {
createWindow();
// OSX convention - (resume the session)
app.on("activate", function () {
if (BrowserWindow.getAllWindows().length === 0) createWindow();
});
});
// Stop
app.on("window-all-closed", () => {
// OSX convention (stay running in dock)
if (process.platform !== "darwin") app.quit();
});
// You can put anything else you want in the main thread here

12
src/preload.ts Normal file
View File

@ -0,0 +1,12 @@
// All of the Node.js APIs are available in the preload process (sandboxed).
window.addEventListener("DOMContentLoaded", () => {
const replaceText = (selector: string, text: string) => {
const element = document.getElementById(selector);
if(element) element.innerText = text;
};
replaceText('chrome-version', process.versions['chrome']);
replaceText('electron-version', process.versions['electron']);
replaceText('node-version', process.versions['node']);
});

4
src/renderer.ts Normal file
View File

@ -0,0 +1,4 @@
/*
This file is imported by index.html, you can put any code you want to run afer
page load, here.
*/