fix placeholder actions and admin overview refresh
This commit is contained in:
1 parent
8a65109c80
commit
c05c987e4c
2 files changed
+17
-6
No files matched your search
@@ -60,9 +60,13 @@ const selectedUsage = ref<UsageAuditRecord | null>(null)
|
||||
const usageNote = ref('')
|
||||
const usageDeleteTarget = ref<string | null>(null)
|
||||
const usageBulkDeleteOpen = ref(false)
|
||||
const auditEvents = ref<Array<{ time: string; actor: string; action: string; target: string; source: string; level: string }>>([])
|
||||
const overviewRefreshing = ref(false)
|
||||
const settings = reactive({ inviteOnly: false, emailSignup: false, phoneSignup: false, automaticCredit: false, maintenanceNotice: false, auditRetention: false })
|
||||
|
||||
onMounted(async () => {
|
||||
async function refreshOverviewData(notifyOnSuccess = false) {
|
||||
if (overviewRefreshing.value) return
|
||||
overviewRefreshing.value = true
|
||||
try {
|
||||
const [providerResult, modelResult, userResult, auditResult] = await Promise.all([catalogClient.listAdminProviders(), catalogClient.listAdminModels(), catalogClient.listAdminUsers(), catalogClient.listAdminAudit()])
|
||||
providers.value = mapProviders(providerResult.providers, modelResult.models)
|
||||
@@ -70,9 +74,17 @@ onMounted(async () => {
|
||||
users.value = userResult.users.map(mapUser)
|
||||
auditEvents.value = auditResult.events.map(mapAudit)
|
||||
catalogConnected.value = true
|
||||
} catch {
|
||||
if (notifyOnSuccess) emit('notify', '数据已刷新')
|
||||
} catch (error) {
|
||||
catalogConnected.value = false
|
||||
emit('notify', error instanceof Error ? error.message : '刷新数据失败')
|
||||
} finally {
|
||||
overviewRefreshing.value = false
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(async () => {
|
||||
await refreshOverviewData()
|
||||
void refreshUsage()
|
||||
})
|
||||
|
||||
@@ -148,7 +160,6 @@ function formatUsagePayload(value: unknown) {
|
||||
|
||||
const queueGroups: Array<{ name: string; type: string; running: number; limit: number; queued: number; wait: string; status: string }> = []
|
||||
const pricing: Array<{ model: string; unit: string; base: string; output: string; rule: string; status: string }> = []
|
||||
const auditEvents = ref<Array<{ time: string; actor: string; action: string; target: string; source: string; level: string }>>([])
|
||||
const filteredAudits = computed(() => {
|
||||
const query = auditQuery.value.trim().toLowerCase()
|
||||
return query ? auditEvents.value.filter((event) => `${event.actor} ${event.action} ${event.target}`.toLowerCase().includes(query)) : auditEvents.value
|
||||
@@ -210,7 +221,7 @@ function mapModels(items: CatalogModel[], providersList: CatalogProvider[]): Mod
|
||||
<template>
|
||||
<div class="page-stack admin-pages">
|
||||
<template v-if="view === 'admin-overview'">
|
||||
<section class="page-heading compact"><div><span>ADMIN OVERVIEW</span><h1>管理总览</h1><p>掌握平台供给、用户、容量和风险状态。</p></div><div class="heading-actions"><span class="health-badge"><i></i>核心服务正常</span><button class="button secondary" @click="emit('notify', '数据已刷新')"><Activity :size="16" />刷新数据</button></div></section>
|
||||
<section class="page-heading compact"><div><span>ADMIN OVERVIEW</span><h1>管理总览</h1><p>掌握平台供给、用户、容量和风险状态。</p></div><div class="heading-actions"><span class="health-badge"><i></i>核心服务正常</span><button class="button secondary" :disabled="overviewRefreshing" @click="refreshOverviewData(true)"><Activity :size="16" />{{ overviewRefreshing ? '刷新中…' : '刷新数据' }}</button></div></section>
|
||||
<section class="metric-grid"><article class="metric-card"><span class="icon-tile violet"><Users :size="18" /></span><div><small>用户总数</small><strong>{{ users.length }}</strong><em>来自认证服务</em></div></article><article class="metric-card"><span class="icon-tile cyan"><Cloud :size="18" /></span><div><small>在线模型</small><strong>{{ models.length }}</strong><em>{{ providers.length }} 个供应商</em></div></article><article class="metric-card"><span class="icon-tile orange"><Gauge :size="18" /></span><div><small>等待任务</small><strong>--</strong><em>容量监控尚未接入</em></div></article><article class="metric-card"><span class="icon-tile green"><CircleDollarSign :size="18" /></span><div><small>今日额度消耗</small><strong>--</strong><em>计费账本尚未接入</em></div></article></section>
|
||||
<section class="two-column equal"><article class="panel chart-panel"><header class="panel-header"><div><span>PLATFORM TRAFFIC</span><h3>平台请求趋势</h3></div><span class="select-button static">最近 7 天</span></header><div class="empty-state compact"><BarChart3 :size="22" /><strong>暂无平台流量数据</strong><span>接入调用记录后会在这里形成趋势</span></div></article><article class="panel health-panel"><header class="panel-header"><div><span>GATEWAY HEALTH</span><h3>模型供给状态</h3></div><button class="text-link" @click="emit('navigate', 'admin-routing')">管理渠道<ArrowRight :size="14" /></button></header><div v-if="providers.length" class="health-list"><div v-for="provider in providers.slice(0, 3)" :key="provider.id"><span class="provider-mark">{{ provider.name.slice(0, 1) }}</span><p><strong>{{ provider.name }}</strong><small>{{ provider.capability }} · {{ provider.latency }}</small></p><b>{{ provider.successRate }}</b><span class="status-chip" :class="provider.status === '健康' ? 'success' : 'warning'"><i></i>{{ provider.status }}</span></div></div><div v-else class="empty-state compact"><Cloud :size="22" /><strong>暂无供应商</strong><span>由管理员登记上游渠道后显示</span></div></article></section>
|
||||
<section class="two-column narrow-left"><article class="panel quick-credit"><header class="panel-header"><div><span>CREDIT OPERATIONS</span><h3>额度分配</h3></div><ShieldCheck :size="18" /></header><p>人民币额度余额与发放流水</p><button class="button primary full" @click="emit('navigate', 'admin-users')"><Users :size="16" />查看用户</button></article><article class="panel activity-panel"><header class="panel-header"><div><span>RECENT EVENTS</span><h3>最近运营事件</h3></div><button class="text-link" @click="emit('navigate', 'admin-audit')">审计日志<ArrowRight :size="14" /></button></header><div v-if="auditEvents.length" class="activity-list"><div v-for="event in auditEvents.slice(0, 3)" :key="`${event.time}-${event.action}`"><span class="activity-dot cyan"><ShieldCheck :size="14" /></span><p><strong>{{ event.action }}</strong><small>{{ event.actor }} · {{ event.target }}</small></p><time>{{ event.time }}</time></div></div><div v-else class="empty-state compact"><ShieldCheck :size="22" /><strong>暂无运营事件</strong><span>真实管理操作发生后会显示审计记录</span></div></article></section>
|
||||
|
||||
Reference in new issue
Block a user