diff --git a/public/admin.html b/public/admin.html new file mode 100644 index 0000000..c5c6d31 --- /dev/null +++ b/public/admin.html @@ -0,0 +1,127 @@ + + + + + +OC Monitor Admin + + + +
+← Dashboard +

⚙️ Admin Panel

+
管理节点、Token、Agent 安装
+ + + + +
已复制
+
+ diff --git a/public/index.html b/public/index.html index ea013bf..f35033b 100644 --- a/public/index.html +++ b/public/index.html @@ -61,7 +61,7 @@ td{padding:6px 10px;border-bottom:1px solid rgba(26,39,64,.5)}
-

🐾 OpenClaw Mission Control

+

🐾 OpenClaw Mission Control ⚙️ Admin

Loading...
diff --git a/server/index.js b/server/index.js index bb8fa8c..b344c5b 100644 --- a/server/index.js +++ b/server/index.js @@ -95,8 +95,15 @@ const server = http.createServer((req, res) => { return true; }; - // Static files + // Static files + agent.sh download if (method === 'GET' && !url.pathname.startsWith('/api/')) { + if (url.pathname === '/agent.sh') { + const agentPath = path.join(__dirname, '..', 'agent', 'agent.sh'); + if (fs.existsSync(agentPath)) { + res.writeHead(200, {'Content-Type':'text/plain'}); + return fs.createReadStream(agentPath).pipe(res); + } + } let fp = path.join(PUBLIC, url.pathname === '/' ? 'index.html' : url.pathname); if (!fs.existsSync(fp)) fp = path.join(PUBLIC, 'index.html'); const ext = path.extname(fp); @@ -154,6 +161,13 @@ const server = http.createServer((req, res) => { return json(200, { ok: true }); } + // GET /api/admin/info + if (url.pathname === '/api/admin/info' && method === 'GET') { + if (!auth()) return; + const nodes = getNodes.all(); + return json(200, { token: AUTH_TOKEN, nodes }); + } + // DELETE /api/node/:id if (url.pathname.startsWith('/api/node/') && method === 'DELETE') { if (!auth()) return;