@@ -125,6 +155,37 @@ const kw = ref('')
const dlg = ref(false)
const detail = ref
(null)
+// 月度用量(按账号聚合)
+const month = ref(new Date().toISOString().slice(0, 7))
+const usageDlg = ref(false)
+const usage = ref({})
+
+async function openUsage() {
+ usageDlg.value = true
+ try {
+ usage.value = await api(`/logs/usage/monthly?month=${month.value}`)
+ } catch {
+ usage.value = { items: [] }
+ }
+}
+
+async function exportUsage() {
+ const resp = await fetch(`/logs/usage/monthly/export?month=${month.value}`, {
+ headers: { Authorization: `Bearer ${getToken()}` },
+ })
+ if (!resp.ok) return
+ const blob = await resp.blob()
+ const href = URL.createObjectURL(blob)
+ const a = document.createElement('a')
+ a.href = href
+ a.download = `usage-${month.value}.csv`
+ a.style.display = 'none'
+ document.body.appendChild(a)
+ a.click()
+ a.remove()
+ setTimeout(() => URL.revokeObjectURL(href), 10_000)
+}
+
const failCount = computed(() => rows.value.filter((r) => !r.ok).length)
const avgMs = computed(() => {
const v = rows.value.map((r) => Number(r.latency_ms)).filter((n) => Number.isFinite(n) && n > 0)