Simple Todo App - Electron Typing CST Test
Loading…
Simple Todo App — Electron Code
Demonstrates a simple Electron app with a Todo list, adding tasks and displaying them using HTML, CSS, and JavaScript with Node.js integration.
// main.js
const { app, BrowserWindow } = require('electron');
function createWindow() {
const win = new BrowserWindow({ width: 800, height: 600, webPreferences: { nodeIntegration: true } });
win.loadFile('index.html');
}
app.whenReady().then(createWindow);
// index.html
<!DOCTYPE html>
<html>
<body>
<h1>Todo App</h1>
<input id='todoInput' placeholder='New Todo'/>
<button id='addBtn'>Add</button>
<ul id='todoList'></ul>
<script>
const addBtn = document.getElementById('addBtn');
const input = document.getElementById('todoInput');
const list = document.getElementById('todoList');
addBtn.addEventListener('click', () => {
if(input.value.trim()){
const li = document.createElement('li');
li.textContent = input.value;
list.appendChild(li);
input.value = '';
}
});
</script>
</body>
</html>Electron Language Guide
Electron is an open-source framework for building cross-platform desktop applications using web technologies (HTML, CSS, JS) with Node.js integration and Chromium-based rendering. It allows developers to create desktop apps for Windows, macOS, and Linux with a single codebase.
Primary Use Cases
- ▸Cross-platform desktop apps for Windows, macOS, and Linux
- ▸Rapid development using web technologies
- ▸Internal enterprise tools
- ▸Consumer desktop apps (Slack, VS Code, Discord)
- ▸Apps requiring integration with Node.js modules
Notable Features
- ▸Cross-platform support with a single codebase
- ▸Full access to Node.js APIs
- ▸Chromium-based rendering for web-like UI
- ▸Automatic updates via electron-updater
- ▸Extensive ecosystem of plugins and libraries
Origin & Creator
Created by GitHub in 2013 (originally as Atom Shell) to power the Atom text editor, Electron has grown into a popular framework for desktop apps.
Industrial Note
Best suited for cross-platform desktop apps where rapid development with web technologies is prioritized over binary size or raw performance.