From e433e94c898c5fe98dcccc48dce878181b9835f3 Mon Sep 17 00:00:00 2001 From: AskaEth Date: Tue, 23 Jun 2026 19:17:32 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=85=A8=E9=93=BE=E8=B7=AF=E8=BF=BD?= =?UTF-8?q?=E8=B8=AA=E6=97=B6=E9=97=B4=E6=98=BE=E7=A4=BA=20=E2=80=94=20UTC?= =?UTF-8?q?=E2=86=92UTC+8=20=E6=9C=AC=E5=9C=B0=E6=97=B6=E9=97=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 新增 formatLocalTime() 替换 toISOString() - 追踪面板时间显示为北京时间 Co-Authored-By: Claude --- ethend/src/index.js | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/ethend/src/index.js b/ethend/src/index.js index ce16d5c..8d05f03 100644 --- a/ethend/src/index.js +++ b/ethend/src/index.js @@ -1304,7 +1304,7 @@ app.get('/api/trace/recent', async (req, res) => { const groupName = entry.group_name ? ` (${entry.group_name})` : ''; traces.push({ id: `msg-${ts}-${Math.random().toString(36).slice(2, 6)}`, - timestamp: new Date(ts).toISOString(), ts, + timestamp: formatLocalTime(ts), ts, service: 'platform-bridge', hop, label: `${icon} ${isIncoming ? '收到' : '发送'}消息 · ${entry.platform || '?'}${groupName}`, @@ -1322,7 +1322,7 @@ app.get('/api/trace/recent', async (req, res) => { const ts = call.time ? new Date(call.time).getTime() : Date.now(); traces.push({ id: `llm-${ts}-${Math.random().toString(36).slice(2, 6)}`, - timestamp: new Date(ts).toISOString(), ts, + timestamp: formatLocalTime(ts), ts, service: 'ai-core', hop: 'llm_call', label: `🧠 LLM: ${call.model || 'unknown'}`, status: call.success ? 'success' : 'error', @@ -1355,7 +1355,7 @@ app.get('/api/trace/recent', async (req, res) => { const ts = ev.timestamp ? new Date(ev.timestamp).getTime() : Date.now(); traces.push({ id: ev.id || `trace-${ts}`, - timestamp: new Date(ts).toISOString(), ts, + timestamp: formatLocalTime(ts), ts, service: 'ai-core', hop: ev.hop || 'trace', label: ev.label || '', @@ -1373,7 +1373,7 @@ app.get('/api/trace/recent', async (req, res) => { const ts = s.last_activity ? new Date(s.last_activity).getTime() : Date.now(); traces.push({ id: `session-${s.session_id || ''}`, - timestamp: new Date(ts).toISOString(), ts, + timestamp: formatLocalTime(ts), ts, service: 'gateway', hop: 'session', label: `👤 会话: ${userID}`, status: s.state === 'streaming' ? 'running' : 'success', @@ -1907,6 +1907,14 @@ server.listen(ETHEND_PORT, () => { } }); +// 时间格式化:UTC+8 本地时间 +function formatLocalTime(ts) { + var d = new Date(ts); + var pad = function(n) { return n < 10 ? '0' + n : '' + n; }; + return d.getFullYear() + '-' + pad(d.getMonth()+1) + '-' + pad(d.getDate()) + ' ' + + pad(d.getHours()) + ':' + pad(d.getMinutes()) + ':' + pad(d.getSeconds()); +} + // 优雅退出 process.on('SIGINT', async () => { console.log('\n关闭所有服务...');