|
| 1 | +<script setup lang="ts"> |
| 2 | +import { computed } from 'vue' |
| 3 | +import { |
| 4 | + Activity, |
| 5 | + BadgeCheck, |
| 6 | + Binary, |
| 7 | + CalendarDays, |
| 8 | + CircleDollarSign, |
| 9 | + Clock3, |
| 10 | + Cpu, |
| 11 | + Gauge, |
| 12 | + ListChecks, |
| 13 | + Network, |
| 14 | + Route, |
| 15 | + ShieldCheck, |
| 16 | + StickyNote, |
| 17 | + TriangleAlert, |
| 18 | + UsersRound |
| 19 | +} from '@lucide/vue' |
| 20 | +import type { AccountDetailItem } from '@shared/types' |
| 21 | +
|
| 22 | +const props = withDefaults(defineProps<{ |
| 23 | + entry: AccountDetailItem |
| 24 | + compact?: boolean |
| 25 | +}>(), { |
| 26 | + compact: false |
| 27 | +}) |
| 28 | +
|
| 29 | +const icon = computed(() => { |
| 30 | + const id = props.entry.id |
| 31 | + if (props.entry.tone === 'danger' && /health|error|cooldown|status/.test(id)) return TriangleAlert |
| 32 | + if (/cost|balance|credit|bill|prepaid|demand|money/.test(id)) return CircleDollarSign |
| 33 | + if (/token/.test(id)) return Binary |
| 34 | + if (/endpoint/.test(id)) return Route |
| 35 | + if (/request/.test(id)) return ListChecks |
| 36 | + if (/model/.test(id)) return Cpu |
| 37 | + if (/history|highest/.test(id)) return CalendarDays |
| 38 | + if (/time|date|expiry|expires|reset|cooldown|period-days/.test(id)) return Clock3 |
| 39 | + if (/health|verify|banned|reauth|status/.test(id)) return ShieldCheck |
| 40 | + if (/proxy|routing|fallback|parent/.test(id)) return Network |
| 41 | + if (/subscription|plan|tier/.test(id)) return BadgeCheck |
| 42 | + if (/group/.test(id)) return UsersRound |
| 43 | + if (/note|reason|error/.test(id)) return StickyNote |
| 44 | + if (/score|priority|load|rate|rpm|concurrency|session/.test(id)) return Gauge |
| 45 | + return Activity |
| 46 | +}) |
| 47 | +
|
| 48 | +const progress = computed(() => Math.max(0, Math.min(100, props.entry.progress || 0))) |
| 49 | +const title = computed(() => [props.entry.label, props.entry.value, props.entry.meta].filter(Boolean).join(' · ')) |
| 50 | +</script> |
| 51 | + |
| 52 | +<template> |
| 53 | + <div |
| 54 | + class="account-detail-visual" |
| 55 | + :class="[ |
| 56 | + `account-detail-visual--${entry.kind || 'metric'}`, |
| 57 | + entry.tone ? `is-${entry.tone}` : '', |
| 58 | + { 'is-compact': compact } |
| 59 | + ]" |
| 60 | + :title="title" |
| 61 | + > |
| 62 | + <span class="account-detail-visual__icon" aria-hidden="true"> |
| 63 | + <component :is="icon" :size="compact ? 12 : 14" :stroke-width="1.9" /> |
| 64 | + </span> |
| 65 | + |
| 66 | + <div class="account-detail-visual__body"> |
| 67 | + <div class="account-detail-visual__heading"> |
| 68 | + <span>{{ entry.label }}</span> |
| 69 | + <strong v-if="entry.kind === 'status'" class="account-detail-visual__status"> |
| 70 | + <i aria-hidden="true" />{{ entry.value }} |
| 71 | + </strong> |
| 72 | + <strong v-else-if="entry.kind !== 'note' && entry.kind !== 'tags'">{{ entry.value }}</strong> |
| 73 | + </div> |
| 74 | + |
| 75 | + <p v-if="entry.kind === 'note'" class="account-detail-visual__note">{{ entry.value }}</p> |
| 76 | + |
| 77 | + <div v-if="entry.kind === 'tags'" class="account-detail-visual__tags"> |
| 78 | + <span v-for="tag in entry.tags || [entry.value]" :key="tag">{{ tag }}</span> |
| 79 | + </div> |
| 80 | + |
| 81 | + <p v-if="entry.meta" class="account-detail-visual__meta">{{ entry.meta }}</p> |
| 82 | + |
| 83 | + <div |
| 84 | + v-if="(entry.kind === 'progress' || entry.kind === 'ranking') && entry.progress !== undefined" |
| 85 | + class="account-detail-visual__track" |
| 86 | + role="meter" |
| 87 | + aria-valuemin="0" |
| 88 | + aria-valuemax="100" |
| 89 | + :aria-valuenow="Math.round(progress)" |
| 90 | + > |
| 91 | + <i :style="{ width: `${progress}%` }" /> |
| 92 | + </div> |
| 93 | + </div> |
| 94 | + </div> |
| 95 | +</template> |
0 commit comments