fix: show claw_id in activation box, remove noisy startup logs
Made-with: Cursor
This commit is contained in:
@@ -18,10 +18,7 @@ class ClawClient {
|
||||
}
|
||||
|
||||
start() {
|
||||
console.log(`[clawd] 启动中...`);
|
||||
console.log(`[clawd] box_id = ${this._boxId}`);
|
||||
console.log(`[clawd] 服务器 = ${this._cfg.server}`);
|
||||
console.log(`[clawd] 配置文件 = ${config.getConfigPath()}`);
|
||||
console.log(`[clawd] 启动中... 服务器 = ${this._cfg.server}`);
|
||||
this._connect();
|
||||
}
|
||||
|
||||
@@ -96,8 +93,14 @@ class ClawClient {
|
||||
break;
|
||||
case 'error':
|
||||
console.error(`[clawd] 服务器错误: ${msg.msg}`);
|
||||
// 若是鉴权失败,清空本地凭证后重连
|
||||
if (msg.msg && msg.msg.includes('invalid')) {
|
||||
if (msg.msg === 'hardware_mismatch') {
|
||||
// box_id 与库中不符:硬件变更或凭证泄露
|
||||
// 清空本地凭证,下次重连走全新注册流程
|
||||
console.warn('[clawd] 硬件指纹与服务器不符(硬件变更或凭证泄露),清除本地凭证重新注册...');
|
||||
this._cfg.claw_id = null;
|
||||
this._cfg.token = null;
|
||||
config.save(this._cfg);
|
||||
} else if (msg.msg && msg.msg.includes('invalid')) {
|
||||
console.warn('[clawd] 凭证无效,清除本地凭证并重新注册...');
|
||||
this._cfg.claw_id = null;
|
||||
this._cfg.token = null;
|
||||
@@ -122,15 +125,18 @@ class ClawClient {
|
||||
}
|
||||
|
||||
if (msg.status === 'inactive') {
|
||||
const id = String(msg.claw_id).padEnd(6);
|
||||
const pin = String(msg.pin);
|
||||
console.log('');
|
||||
console.log('╔══════════════════════════════════╗');
|
||||
console.log(`║ 激活 PIN 码: ${msg.pin} ║`);
|
||||
console.log('║ 请在管理后台或前台输入此 PIN 码 ║');
|
||||
console.log('╚══════════════════════════════════╝');
|
||||
console.log('╔════════════════════════════════════╗');
|
||||
console.log(`║ Claw ID : ${id} ║`);
|
||||
console.log(`║ PIN 码 : ${pin} ║`);
|
||||
console.log('║ 请在网页前台「添加设备」中输入 ║');
|
||||
console.log('╚════════════════════════════════════╝');
|
||||
console.log('');
|
||||
console.log('[clawd] 等待激活中,心跳正常运行...');
|
||||
console.log('[clawd] 等待激活,心跳正常运行...');
|
||||
} else {
|
||||
console.log(`[clawd] 设备已激活,claw_id = ${msg.claw_id}`);
|
||||
console.log(`[clawd] 已激活 claw_id = ${msg.claw_id}`);
|
||||
}
|
||||
|
||||
// 开始心跳
|
||||
|
||||
Reference in New Issue
Block a user