diff --git a/portable/Windows-Start.bat b/portable/Windows-Start.bat index aa503a0..e1da2ca 100644 --- a/portable/Windows-Start.bat +++ b/portable/Windows-Start.bat @@ -79,17 +79,31 @@ if %errorlevel%==0 ( ) echo Starting OpenClaw on port %PORT%... -echo DO NOT close this window! +echo. + +REM Start Config Server in background +echo Starting Config Center on port 18788... +set "CONFIG_SERVER=%UCLAW_DIR%config-server" +start /B "" "%NODE_BIN%" "%CONFIG_SERVER%\server.js" >nul 2>&1 + +REM Wait for config server to start +timeout /t 2 /nobreak >nul + +REM Open both Config Center and Dashboard +echo Opening Config Center and Dashboard... +timeout /t 1 /nobreak >nul + +REM Open Config Center (Node.js web UI) +start "" http://127.0.0.1:18788/ + +REM Open OpenClaw Dashboard +start "" http://127.0.0.1:%PORT%/#token=uclaw + +echo Browsers opened. Starting OpenClaw Gateway on port %PORT%... +echo DO NOT close this window while using U-Claw! echo. cd /d "%CORE_DIR%" - -REM Always open dashboard - it will guide first-time setup -echo 正在打开控制台... -echo Opening dashboard at http://127.0.0.1:%PORT% -timeout /t 2 /nobreak >nul -start "" http://127.0.0.1:%PORT%/#token=uclaw - set "OPENCLAW_MJS=%CORE_DIR%\node_modules\openclaw\openclaw.mjs" "%NODE_BIN%" "%OPENCLAW_MJS%" gateway run --allow-unconfigured --force --port %PORT% diff --git a/portable/config-server/public/index.html b/portable/config-server/public/index.html new file mode 100644 index 0000000..1119b7f --- /dev/null +++ b/portable/config-server/public/index.html @@ -0,0 +1,207 @@ + + + + + +U-Claw 配置中心 + + + +
+

🦞 U-Claw 配置中心

+

简单配置,快速启动

+ + +
+

AI 模型配置

+
+ + +
+
+ + +
+ + + +
+
+ + +
+

QQ 机器人(可选)

+
+ + +
+
+ + +
+ +
+
+ + +
+ + + + diff --git a/portable/config-server/server.js b/portable/config-server/server.js new file mode 100644 index 0000000..63ece20 --- /dev/null +++ b/portable/config-server/server.js @@ -0,0 +1,82 @@ +#!/usr/bin/env node +const http = require('http'); +const fs = require('fs'); +const path = require('path'); + +const PORT = 18788; +const CONFIG_PATH = path.join(__dirname, '../data/.openclaw/openclaw.json'); + +const server = http.createServer((req, res) => { + // CORS headers + res.setHeader('Access-Control-Allow-Origin', '*'); + res.setHeader('Access-Control-Allow-Methods', 'GET, POST, OPTIONS'); + res.setHeader('Access-Control-Allow-Headers', 'Content-Type'); + + if (req.method === 'OPTIONS') { + res.writeHead(200); + res.end(); + return; + } + + // API: Get config + if (req.url === '/api/config' && req.method === 'GET') { + try { + const config = fs.existsSync(CONFIG_PATH) + ? JSON.parse(fs.readFileSync(CONFIG_PATH, 'utf8')) + : {}; + res.writeHead(200, { 'Content-Type': 'application/json' }); + res.end(JSON.stringify(config)); + } catch (err) { + res.writeHead(500, { 'Content-Type': 'application/json' }); + res.end(JSON.stringify({ error: err.message })); + } + return; + } + + // API: Save config + if (req.url === '/api/config' && req.method === 'POST') { + let body = ''; + req.on('data', chunk => body += chunk); + req.on('end', () => { + try { + const config = JSON.parse(body); + const dir = path.dirname(CONFIG_PATH); + if (!fs.existsSync(dir)) fs.mkdirSync(dir, { recursive: true }); + fs.writeFileSync(CONFIG_PATH, JSON.stringify(config, null, 2)); + res.writeHead(200, { 'Content-Type': 'application/json' }); + res.end(JSON.stringify({ ok: true })); + } catch (err) { + res.writeHead(500, { 'Content-Type': 'application/json' }); + res.end(JSON.stringify({ error: err.message })); + } + }); + return; + } + + // Serve static files + const filePath = req.url === '/' + ? path.join(__dirname, 'public/index.html') + : path.join(__dirname, 'public', req.url); + + if (fs.existsSync(filePath) && fs.statSync(filePath).isFile()) { + const ext = path.extname(filePath); + const contentType = { + '.html': 'text/html', + '.css': 'text/css', + '.js': 'application/javascript', + '.json': 'application/json' + }[ext] || 'text/plain'; + + res.writeHead(200, { 'Content-Type': contentType }); + fs.createReadStream(filePath).pipe(res); + } else { + res.writeHead(404); + res.end('Not Found'); + } +}); + +server.listen(PORT, '127.0.0.1', () => { + console.log(`\n🦞 U-Claw Config Center`); + console.log(` http://127.0.0.1:${PORT}`); + console.log(`\n Config file: ${CONFIG_PATH}\n`); +});