init: 鏅烘収鍐滀笟澶ф暟鎹彲瑙嗗寲鎺у埗涓績 v0.1.0锛圗lectron + React 19 + TS 閲嶅啓鐗堬級
- 缂栬緫鍣細椤圭洰鏂板缓/鎵撳紑/淇濆瓨/鍙﹀瓨涓猴紙璁颁綇鏈€鍚庢枃浠跺す锛夈€侀〉闈㈠鍒?鍓嶆彃/绉诲姩/澶嶅埗/鎴浘/椤甸潰閲嶆帓銆丅ase64 棰勮鍥俱€? 椤归〉闈㈠睘鎬?- 鍙戝竷鍣細棰勮鏈〉/鍗曞睆鍙戝竷(杞挱)/澶氬睆鍙戝竷(alsoMain)/鍋滄杞挱/鍏抽棴鎵€鏈?妫€娴嬪睆骞曪紝蹇嵎閿綋绯?1-9闀挎寜闃堝€?鈫戔啌/Esc/F5/閿佸畾閿? - 閰嶇疆鍣細椤圭洰淇℃伅/閬ユ帶璁剧疆/蹇嵎鏂瑰紡x3/鍙戝竷璁剧疆/璁惧娴嬭瘯/鍏充簬 6 鑿滃崟 - 鏁版嵁瀹夊叏锛欽SON 宸ョ▼ AES-256-GCM 瀵嗙爜鍔犲瘑 - 鐗堟湰鍙峰崟涓€鏉ユ簮(package.json)锛岀豢鑹茬増 zip 鎵撳寘(electron-builder) - 闄勫甫锛氶渶姹傛枃妗?v2.0銆佹寚浠ゆ竻鍗曘€乸rototype 澶у睆鍘熷瀷
This commit is contained in:
Vendored
+37
@@ -0,0 +1,37 @@
|
||||
const http = require('http');
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
|
||||
const ROOT = __dirname;
|
||||
const PORT = 8777;
|
||||
|
||||
const MIME = {
|
||||
'.html': 'text/html; charset=utf-8',
|
||||
'.js': 'text/javascript; charset=utf-8',
|
||||
'.css': 'text/css; charset=utf-8',
|
||||
'.json': 'application/json; charset=utf-8',
|
||||
'.png': 'image/png',
|
||||
'.jpg': 'image/jpeg',
|
||||
'.svg': 'image/svg+xml',
|
||||
'.ico': 'image/x-icon',
|
||||
};
|
||||
|
||||
http.createServer((req, res) => {
|
||||
let urlPath = decodeURIComponent(req.url.split('?')[0]);
|
||||
if (urlPath === '/') urlPath = '/index.html';
|
||||
const filePath = path.join(ROOT, urlPath);
|
||||
if (!filePath.startsWith(ROOT)) {
|
||||
res.writeHead(403); res.end('Forbidden'); return;
|
||||
}
|
||||
fs.readFile(filePath, (err, data) => {
|
||||
if (err) {
|
||||
res.writeHead(404, { 'Content-Type': 'text/plain; charset=utf-8' });
|
||||
res.end('404 Not Found: ' + urlPath);
|
||||
return;
|
||||
}
|
||||
res.writeHead(200, { 'Content-Type': MIME[path.extname(filePath)] || 'application/octet-stream' });
|
||||
res.end(data);
|
||||
});
|
||||
}).listen(PORT, () => {
|
||||
console.log(`Static server running at http://localhost:${PORT}`);
|
||||
});
|
||||
Reference in New Issue
Block a user