mirror of
https://github.com/lWolvesl/antigravity-usage-monitor.git
synced 2026-11-26 17:09:28 +08:00
feat(ui): add interactive spinning & status feedback for refresh button and add release zip guide
This commit is contained in:
@@ -44,27 +44,33 @@ Antigravity 实时测速与官方额度监控侧边栏插件(UI Extension Side
|
||||
git clone https://github.com/yuhuan2498281558/antigravity-usage-monitor.git ~/.gemini/config/plugins/usage-monitor
|
||||
```
|
||||
|
||||
### 方式三:手动下载 ZIP 解压
|
||||
### 方式三:直接下载 Release 安装包 (`usage-monitor.zip`)
|
||||
|
||||
1. 点击本仓库右上角的 **Code** -> **Download ZIP**。
|
||||
2. 解压到全局插件目录,确保目录结构如下:
|
||||
- **Windows**: `C:\Users\<你的用户名>\.gemini\config\plugins\usage-monitor\`
|
||||
- **macOS / Linux**: `~/.gemini/config/plugins/usage-monitor/`
|
||||
```text
|
||||
usage-monitor/
|
||||
├── plugin.json
|
||||
├── README.md
|
||||
├── assets/
|
||||
│ └── logo.svg
|
||||
└── sidecars/
|
||||
└── panel/
|
||||
├── sidecar.json
|
||||
├── package.json
|
||||
├── main.mjs
|
||||
├── index.html
|
||||
├── app.js
|
||||
└── styles.css
|
||||
```
|
||||
1. 直接点击下载打包好的安装包:**[📦 下载 usage-monitor.zip (Latest Release)](https://github.com/yuhuan2498281558/antigravity-usage-monitor/releases/latest/download/usage-monitor.zip)**(也可在仓库右侧 **[Releases](https://github.com/yuhuan2498281558/antigravity-usage-monitor/releases)** 页面下载)。
|
||||
2. 将压缩包解压到全局插件目录 `~/.gemini/config/plugins/` 下(压缩包内已自带 `usage-monitor/` 顶层文件夹):
|
||||
- **Windows PowerShell 一键下载并解压**:
|
||||
```powershell
|
||||
$pluginsDir = "$env:USERPROFILE\.gemini\config\plugins"
|
||||
New-Item -ItemType Directory -Path $pluginsDir -Force | Out-Null
|
||||
Invoke-WebRequest -Uri "https://github.com/yuhuan2498281558/antigravity-usage-monitor/releases/latest/download/usage-monitor.zip" -OutFile "$env:TEMP\usage-monitor.zip"
|
||||
Expand-Archive -Path "$env:TEMP\usage-monitor.zip" -DestinationPath $pluginsDir -Force
|
||||
```
|
||||
- 解压后的目录结构如下:
|
||||
```text
|
||||
~/.gemini/config/plugins/usage-monitor/
|
||||
├── plugin.json
|
||||
├── README.md
|
||||
├── assets/
|
||||
│ └── logo.svg
|
||||
└── sidecars/
|
||||
└── panel/
|
||||
├── sidecar.json
|
||||
├── package.json
|
||||
├── main.mjs
|
||||
├── index.html
|
||||
├── app.js
|
||||
└── styles.css
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
|
||||
+57
-5
@@ -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');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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>
|
||||
|
||||
|
||||
@@ -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) ------------ */
|
||||
|
||||
Reference in New Issue
Block a user