mirror of
https://github.com/lWolvesl/antigravity-usage-monitor.git
synced 2026-11-27 01:19:25 +08:00
feat(panel): live task cards, interactive usage trend chart, and Gemini 4 Carbon support (v1.4.2)
This commit is contained in:
@@ -4,13 +4,6 @@
|
||||
* reactive subscriptions, and lifecycle cleanup.
|
||||
*/
|
||||
|
||||
const globalEmitListeners = new Set();
|
||||
|
||||
export function onComponentEmit(listener) {
|
||||
globalEmitListeners.add(listener);
|
||||
return () => globalEmitListeners.delete(listener);
|
||||
}
|
||||
|
||||
export function defineComponent({ name, setup }) {
|
||||
return function createInstance(initialProps = {}) {
|
||||
let props = { ...initialProps };
|
||||
@@ -41,14 +34,6 @@ export function defineComponent({ name, setup }) {
|
||||
fn(payload);
|
||||
}
|
||||
}
|
||||
for (const observer of globalEmitListeners) {
|
||||
observer({
|
||||
component: name || 'AnonymousComponent',
|
||||
event,
|
||||
payload,
|
||||
timestamp: Date.now(),
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function onCleanup(fn) {
|
||||
@@ -88,6 +73,7 @@ export function defineComponent({ name, setup }) {
|
||||
console.error(`[${name}] cleanup error:`, err);
|
||||
}
|
||||
}
|
||||
eventHandlers.clear();
|
||||
if (setupResult.el?.parentNode) {
|
||||
setupResult.el.parentNode.removeChild(setupResult.el);
|
||||
}
|
||||
|
||||
@@ -87,10 +87,15 @@ export function formatCompactDateTime(ms) {
|
||||
return `${d.getFullYear()}-${pad(d.getMonth() + 1)}-${pad(d.getDate())} ${pad(d.getHours())}:${pad(d.getMinutes())}`;
|
||||
}
|
||||
|
||||
export function escapeHtml(str) {
|
||||
return String(str || '')
|
||||
.replace(/&/g, '&')
|
||||
.replace(/</g, '<')
|
||||
.replace(/>/g, '>')
|
||||
.replace(/"/g, '"');
|
||||
export function formatElapsedSec(seconds) {
|
||||
const s = Math.max(0, Math.floor(Number(seconds) || 0));
|
||||
if (s < 60) return `${s}s`;
|
||||
const m = Math.floor(s / 60);
|
||||
const remS = s % 60;
|
||||
if (m < 60) {
|
||||
return `${m}m ${String(remS).padStart(2, '0')}s`;
|
||||
}
|
||||
const h = Math.floor(m / 60);
|
||||
const remM = m % 60;
|
||||
return `${h}h ${remM}m`;
|
||||
}
|
||||
|
||||
@@ -15,14 +15,15 @@ export async function callSidecarApi(path, { method = 'GET', body, abortKey = ''
|
||||
}
|
||||
|
||||
let signal;
|
||||
let requestController = null;
|
||||
if (abortKey && typeof AbortController !== 'undefined') {
|
||||
const prev = activeControllers.get(abortKey);
|
||||
if (prev) {
|
||||
prev.abort();
|
||||
}
|
||||
const controller = new AbortController();
|
||||
activeControllers.set(abortKey, controller);
|
||||
signal = controller.signal;
|
||||
requestController = new AbortController();
|
||||
activeControllers.set(abortKey, requestController);
|
||||
signal = requestController.signal;
|
||||
}
|
||||
|
||||
const runRequest = async () => {
|
||||
@@ -58,6 +59,9 @@ export async function callSidecarApi(path, { method = 'GET', body, abortKey = ''
|
||||
if (dedupKey) {
|
||||
inFlightGets.delete(dedupKey);
|
||||
}
|
||||
if (abortKey && requestController && activeControllers.get(abortKey) === requestController) {
|
||||
activeControllers.delete(abortKey);
|
||||
}
|
||||
});
|
||||
|
||||
if (dedupKey) {
|
||||
|
||||
Reference in New Issue
Block a user