feat(portable): bug 一键上报 + 自动崩溃上报 + openclaw 升级 2026.6.6

Bug 上报(方便服务器侧排查便携版问题):
- 新增 lib/report-bug.mjs:算设备指纹→sk-uc apiKey,收集 openclaw 版本/
  系统信息/最近日志(gzip+base64),POST 到 api.u-claw.org/recharge/bug/submit。
  静默失败,绝不影响主流程。复用 fingerprint.mjs + xiapan-client.mjs。
- config-server 加 POST /api/report-bug:本地补齐信息后转发,配置中心加
  「🐛 报 Bug」表单(标题/描述/是否附日志)。
- Windows-Start.bat / Mac-Start.command:gateway 端口耗尽或异常退出时
  自动后台上报(Ctrl+C 正常停止不上报)。

openclaw 升级:
- OPENCLAW_VERSION 2026.4.29 → 2026.6.6(X 盘真实 USB 实测 gateway
  启动/ready、Dashboard 200、旧配置兼容、虾盘云 status 均通过)。

便携性改进(借鉴 OpenClaw-Windows-Portable):
- setup.sh / 启动脚本的 npm install 设 npm_config_cache 指向盘内
  app/.npm-cache,避免污染系统缓存,拔盘不留痕。

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
hfshfg
2026-06-15 10:52:17 +08:00
parent d9dd98d650
commit 6eb54f8ea3
7 changed files with 316 additions and 4 deletions

View File

@@ -410,6 +410,26 @@ input:focus { border-color: #ff6b35; }
</div>
</div>
</div>
<div class="section active skills-section" style="display:block; margin-top: 8px;">
<h2>🐛 反馈 / 报 Bug</h2>
<p class="desc">遇到问题?一键反馈给我们,会自动附带版本号和最近日志(不含你的 API Key方便我们排查。</p>
<div class="form-group">
<label>问题标题 <span style="color:#888;font-weight:normal">(必填,简短描述)</span></label>
<input type="text" id="bugTitle" placeholder="例如:点击打开 Dashboard 没反应" maxlength="200">
</div>
<div class="form-group">
<label>详细描述 <span style="color:#888;font-weight:normal">(可选)</span></label>
<textarea id="bugDesc" rows="4" placeholder="发生了什么?做了哪些操作?" style="width:100%;padding:12px;border-radius:8px;background:#1a1a1a;border:1px solid #333;color:#eee;font-family:inherit;font-size:0.95em;box-sizing:border-box;resize:vertical"></textarea>
</div>
<div class="form-group" style="display:flex;align-items:center;gap:8px">
<input type="checkbox" id="bugLogs" checked style="width:auto;margin:0">
<label for="bugLogs" style="margin:0;font-weight:normal">附带最近运行日志(推荐,帮助定位问题)</label>
</div>
<div class="btn-row">
<button class="btn btn-primary" id="bugSubmitBtn" onclick="submitBug()">提交反馈</button>
</div>
</div>
</div>
<div class="toast" id="toast"></div>
@@ -706,6 +726,32 @@ async function viewConfig() {
}
}
// --- Bug report ---
async function submitBug() {
var title = document.getElementById('bugTitle').value.trim();
if (title.length < 3) { showToast('请填写问题标题(至少 3 个字)', true); return; }
var desc = document.getElementById('bugDesc').value.trim();
var includeLogs = document.getElementById('bugLogs').checked;
var btn = document.getElementById('bugSubmitBtn');
btn.disabled = true; btn.textContent = '提交中…';
try {
var res = await fetch('/api/report-bug', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ title: title, description: desc, includeLogs: includeLogs })
});
var data = await res.json();
if (!res.ok || !data.ok) throw new Error(data.reason || data.error || '提交失败');
showToast('反馈已提交,编号 #' + data.id + ',谢谢!');
document.getElementById('bugTitle').value = '';
document.getElementById('bugDesc').value = '';
} catch (e) {
showToast('提交失败:' + e.message, true);
} finally {
btn.disabled = false; btn.textContent = '提交反馈';
}
}
// --- Toast ---
function showToast(msg, isError) {
var t = document.getElementById('toast');

View File

@@ -524,6 +524,37 @@ const server = http.createServer((req, res) => {
return;
}
// API: Report a bug — user fills title/description in the web UI; this endpoint
// attaches fingerprint/version/logs locally and forwards to api.u-claw.org.
if (req.url === '/api/report-bug' && req.method === 'POST') {
let body = '';
req.on('data', chunk => {
body += chunk;
if (body.length > 2 * 1024 * 1024) req.destroy(); // 2MB cap on user input
});
req.on('end', () => {
(async () => {
try {
const data = body ? JSON.parse(body) : {};
const mod = await import('../lib/report-bug.mjs');
const portableRoot = path.join(__dirname, '..');
const result = await mod.submitBugReport({
title: data.title,
description: data.description,
appRoot: portableRoot,
includeLogs: data.includeLogs !== false, // 默认带日志,用户可勾掉
});
res.writeHead(result.ok ? 200 : 400, { 'Content-Type': 'application/json' });
res.end(JSON.stringify(result));
} catch (err) {
res.writeHead(500, { 'Content-Type': 'application/json' });
res.end(JSON.stringify({ ok: false, error: err.message }));
}
})();
});
return;
}
// Serve static files
const filePath = req.url === '/'
? path.join(__dirname, 'public/index.html')