mkdir typing-tool && cd typing-tool
npm init -y
npm install --save-dev electron
"main": "main.js",
"scripts": { "start": "electron ." }
const { app, BrowserWindow } = require('electron');
const path = require('path');
function createWindow() {
const win = new BrowserWindow({
width: 900,
height: 600,
webPreferences: {
preload: path.join(__dirname, 'preload.js'),
},
});
win.loadFile('index.html');
}
app.whenReady().then(createWindow);
app.on('window-all-closed', () => {
if (process.platform !== 'darwin') app.quit();
});
<h1>타이핑 연습</h1>
<p id="target">오늘도 한 줄씩 코드를 쌓아 올린다</p>
<input id="input" placeholder="위 문장을 따라 입력하세요" />
<div>
타수: <b id="cpm">0</b> · 정확도: <b id="acc">100</b>%
</div>
<script src="renderer.js"></script>
const target = document.getElementById('target').textContent;
const input = document.getElementById('input');
let start = null;
input.addEventListener('input', () => {
if (!start) start = Date.now();
const typed = input.value;
const min = (Date.now() - start) / 60000;
let ok = 0;
for (let i = 0; i < typed.length; i++) {
if (typed[i] === target[i]) ok++;
}
document.getElementById('cpm').textContent =
Math.round(typed.length / Math.max(min, 1 / 60));
document.getElementById('acc').textContent =
typed.length ? Math.round((ok / typed.length) * 100) : 100;
});
npm start
창에서 Ctrl+Shift+I (Mac: ⌥⌘I)
— 크롬과 똑같이 디버깅
npm install --save-dev electron-builder
"build": {
"appId": "com.ttj.typingtool",
"productName": "TypingTool",
"win": { "target": "nsis" },
"mac": { "target": "dmg" }
},
"scripts": { "start": "electron .", "dist": "electron-builder" }
npm run dist → dist 폴더| OS | 결과 파일 | 빌드 위치 |
|---|---|---|
| 🪟 Windows | TypingTool Setup 1.0.0.exe | Windows PC에서 빌드 |
| 🍎 Mac | TypingTool-1.0.0.dmg | Mac에서 빌드 |
업종별 · 난이도별
연습 문장 추가
Main에서 파일 저장
→ 성장 그래프
새 기능을 고객 PC에
자동 배포 (다음 강)
4-3 — 자동 업데이트
기능 탑재하기