feat(ui): add interactive spinning & status feedback for refresh button and add release zip guide

This commit is contained in:
yuhuan2498281558
2026-10-14 03:54:43 +08:00
parent dcf01649ad
commit 25276f47ba
4 changed files with 122 additions and 28 deletions
+57 -5
View File
@@ -177,14 +177,19 @@ function applyTelemetryToDom(data) {
const livePill = $('live-status-pill');
const speedDot = $('speed-dot');
if (active.isRunning) {
livePill.textContent = '生成中…';
livePill.classList.add('running');
speedDot.classList.add('pulsing');
} else {
livePill.textContent = '实时 2s';
livePill.classList.remove('running');
speedDot.classList.remove('pulsing');
}
if (!manualRefreshFeedbackTimer) {
if (active.isRunning) {
livePill.textContent = '生成中…';
livePill.classList.add('running');
} else {
livePill.textContent = '实时 2s';
livePill.classList.remove('running');
}
}
// 2. Status strip metrics
$('tok-per-sec').textContent = `${Number(active.latestTokPerSec || 0).toFixed(1)} tok/s`;
@@ -267,17 +272,64 @@ function applyTelemetryToDom(data) {
renderTables(active, data.modelBreakdown);
}
let manualRefreshFeedbackTimer = null;
async function refreshTelemetry(force = false) {
const btn = $('refresh-btn');
const livePill = $('live-status-pill');
const startMs = Date.now();
if (force && btn) {
btn.classList.add('refreshing');
if (livePill) {
livePill.textContent = '同步中…';
livePill.classList.remove('running');
livePill.classList.add('synced');
}
}
try {
const params = new URLSearchParams();
if (selectedConversationId) params.set('conversationId', selectedConversationId);
if (force === true) params.set('force', '1');
const qs = params.toString();
const data = await callApi(`/api/telemetry${qs ? `?${qs}` : ''}`);
if (force) {
const elapsed = Date.now() - startMs;
if (elapsed < 320) {
await new Promise((r) => setTimeout(r, 320 - elapsed));
}
}
applyTelemetryToDom(data);
if (force && livePill) {
if (manualRefreshFeedbackTimer) clearTimeout(manualRefreshFeedbackTimer);
livePill.textContent = '✓ 已刷新';
livePill.classList.remove('running');
livePill.classList.add('synced');
manualRefreshFeedbackTimer = setTimeout(() => {
manualRefreshFeedbackTimer = null;
livePill.classList.remove('synced');
if (latestTelemetry?.activeConversation?.isRunning) {
livePill.textContent = '生成中…';
livePill.classList.add('running');
} else {
livePill.textContent = '实时 2s';
}
}, 1200);
}
} catch (err) {
console.error('Telemetry refresh failed:', err);
$('live-status-pill').textContent = '连接重试中';
if (livePill) {
livePill.classList.remove('synced');
livePill.textContent = '连接重试中';
}
} finally {
if (force && btn) {
btn.classList.remove('refreshing');
}
}
}
+3 -1
View File
@@ -17,7 +17,9 @@
</div>
<div class="session-pill-right">
<span id="live-status-pill" class="live-pill">实时 2s</span>
<button id="refresh-btn" class="icon-btn" type="button" title="立即刷新">↻</button>
<button id="refresh-btn" class="icon-btn" type="button" title="立即强制同步官方额度与测速">
<span class="refresh-glyph">↻</span>
</button>
</div>
</div>
+36 -2
View File
@@ -108,20 +108,54 @@ body {
color: var(--speed-accent);
}
.live-pill.synced {
background: color-mix(in srgb, #2563eb 16%, transparent);
color: var(--model-blue);
}
.icon-btn {
padding: 2px 7px;
display: inline-flex;
align-items: center;
justify-content: center;
width: 24px;
height: 22px;
padding: 0;
font-size: 13px;
line-height: 1.2;
line-height: 1;
color: var(--muted-foreground, #5f6368);
background: transparent;
border: 1px solid var(--border, #d8dee4);
border-radius: 5px;
cursor: pointer;
user-select: none;
transition: transform 0.12s ease, background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.icon-btn:hover {
background: var(--secondary, #eef1f4);
color: var(--foreground, #1f2328);
border-color: var(--muted-foreground, #8c959f);
}
.icon-btn:active {
transform: scale(0.88);
}
.icon-btn.refreshing {
color: var(--model-blue);
border-color: var(--model-blue);
background: color-mix(in srgb, var(--model-blue) 10%, transparent);
pointer-events: none;
}
.icon-btn.refreshing .refresh-glyph {
display: inline-block;
animation: spin-refresh 0.55s linear infinite;
}
@keyframes spin-refresh {
from { transform: rotate(0deg); }
to { transform: rotate(360deg); }
}
/* 2. Compact Status Strip Card (Left status bar in screenshot) ------------ */