init: 智慧农业大数据可视化控制中心 v0.1.0(Electron + React 19 + TS 重写版)

This commit is contained in:
2026-08-23 10:57:14 +08:00
commit 2c90205766
61 changed files with 14564 additions and 0 deletions
+37
View File
@@ -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}`);
});