refactor(frontend): comprehensive split of large view files into modular components
- Split UsersView.vue into UserCreateModal, UserEditModal, UserApiKeysModal, etc.
- Split UsageView.vue into UsageStatsCards, UsageFilters, UsageTable, etc.
- Split DashboardView.vue into UserDashboardStats, UserDashboardCharts, etc.
- Split AccountsView.vue into AccountTableActions, AccountTableFilters, etc.
- Standardized TypeScript types across new components to resolve implicit 'any' and 'never[]' errors.
- Improved overall frontend maintainability and code clarity.
2026-01-04 22:17:27 +08:00
|
|
|
<template>
|
|
|
|
|
<div class="grid grid-cols-2 gap-4 lg:grid-cols-4">
|
|
|
|
|
<div class="card p-4 flex items-center gap-3">
|
refactor(frontend): 完成所有组件的内联SVG统一替换为Icon组件
- 扩展 Icon.vue 组件,新增 60+ 图标路径
- 导航类: arrowRight, arrowLeft, arrowUp, arrowDown, chevronUp, externalLink
- 状态类: checkCircle, xCircle, exclamationCircle, exclamationTriangle, infoCircle
- 用户类: user, userCircle, userPlus, users
- 文档类: document, clipboard, copy, inbox
- 操作类: download, upload, filter, sort
- 安全类: key, lock, shield
- UI类: menu, calendar, home, terminal, gift, creditCard, mail
- 数据类: chartBar, trendingUp, database, cube
- 其他: bolt, sparkles, cloud, server, sun, moon, book 等
- 重构 56 个 Vue 组件,用 Icon 组件替换内联 SVG
- 净减少约 2200 行代码
- 提升代码可维护性和一致性
- 统一图标样式和尺寸管理
2026-01-05 20:22:48 +08:00
|
|
|
<div class="rounded-lg bg-blue-100 p-2 dark:bg-blue-900/30 text-blue-600">
|
|
|
|
|
<Icon name="document" size="md" />
|
|
|
|
|
</div>
|
2026-01-06 22:19:07 +08:00
|
|
|
<div>
|
|
|
|
|
<p class="text-xs font-medium text-gray-500">{{ t('usage.totalRequests') }}</p>
|
|
|
|
|
<p class="text-xl font-bold">{{ stats?.total_requests?.toLocaleString() || '0' }}</p>
|
|
|
|
|
<p class="text-xs text-gray-400">{{ t('usage.inSelectedRange') }}</p>
|
|
|
|
|
</div>
|
refactor(frontend): comprehensive split of large view files into modular components
- Split UsersView.vue into UserCreateModal, UserEditModal, UserApiKeysModal, etc.
- Split UsageView.vue into UsageStatsCards, UsageFilters, UsageTable, etc.
- Split DashboardView.vue into UserDashboardStats, UserDashboardCharts, etc.
- Split AccountsView.vue into AccountTableActions, AccountTableFilters, etc.
- Standardized TypeScript types across new components to resolve implicit 'any' and 'never[]' errors.
- Improved overall frontend maintainability and code clarity.
2026-01-04 22:17:27 +08:00
|
|
|
</div>
|
|
|
|
|
<div class="card p-4 flex items-center gap-3">
|
|
|
|
|
<div class="rounded-lg bg-amber-100 p-2 dark:bg-amber-900/30 text-amber-600"><svg class="h-5 w-5" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="m21 7.5-9-5.25L3 7.5m18 0-9 5.25m9-5.25v9l-9 5.25M3 7.5l9 5.25M3 7.5v9l9 5.25m0-9v9" /></svg></div>
|
2026-01-06 22:19:07 +08:00
|
|
|
<div>
|
|
|
|
|
<p class="text-xs font-medium text-gray-500">{{ t('usage.totalTokens') }}</p>
|
|
|
|
|
<p class="text-xl font-bold">{{ formatTokens(stats?.total_tokens || 0) }}</p>
|
|
|
|
|
<p class="text-xs text-gray-500">
|
|
|
|
|
{{ t('usage.in') }}: {{ formatTokens(stats?.total_input_tokens || 0) }} /
|
|
|
|
|
{{ t('usage.out') }}: {{ formatTokens(stats?.total_output_tokens || 0) }}
|
|
|
|
|
</p>
|
|
|
|
|
</div>
|
refactor(frontend): comprehensive split of large view files into modular components
- Split UsersView.vue into UserCreateModal, UserEditModal, UserApiKeysModal, etc.
- Split UsageView.vue into UsageStatsCards, UsageFilters, UsageTable, etc.
- Split DashboardView.vue into UserDashboardStats, UserDashboardCharts, etc.
- Split AccountsView.vue into AccountTableActions, AccountTableFilters, etc.
- Standardized TypeScript types across new components to resolve implicit 'any' and 'never[]' errors.
- Improved overall frontend maintainability and code clarity.
2026-01-04 22:17:27 +08:00
|
|
|
</div>
|
|
|
|
|
<div class="card p-4 flex items-center gap-3">
|
refactor(frontend): 完成所有组件的内联SVG统一替换为Icon组件
- 扩展 Icon.vue 组件,新增 60+ 图标路径
- 导航类: arrowRight, arrowLeft, arrowUp, arrowDown, chevronUp, externalLink
- 状态类: checkCircle, xCircle, exclamationCircle, exclamationTriangle, infoCircle
- 用户类: user, userCircle, userPlus, users
- 文档类: document, clipboard, copy, inbox
- 操作类: download, upload, filter, sort
- 安全类: key, lock, shield
- UI类: menu, calendar, home, terminal, gift, creditCard, mail
- 数据类: chartBar, trendingUp, database, cube
- 其他: bolt, sparkles, cloud, server, sun, moon, book 等
- 重构 56 个 Vue 组件,用 Icon 组件替换内联 SVG
- 净减少约 2200 行代码
- 提升代码可维护性和一致性
- 统一图标样式和尺寸管理
2026-01-05 20:22:48 +08:00
|
|
|
<div class="rounded-lg bg-green-100 p-2 dark:bg-green-900/30 text-green-600">
|
|
|
|
|
<Icon name="dollar" size="md" />
|
|
|
|
|
</div>
|
2026-01-06 22:19:07 +08:00
|
|
|
<div class="min-w-0 flex-1">
|
|
|
|
|
<p class="text-xs font-medium text-gray-500">{{ t('usage.totalCost') }}</p>
|
2026-01-14 16:12:08 +08:00
|
|
|
<p class="text-xl font-bold text-green-600">
|
|
|
|
|
${{ ((stats?.total_account_cost ?? stats?.total_actual_cost) || 0).toFixed(4) }}
|
|
|
|
|
</p>
|
|
|
|
|
<p class="text-xs text-gray-400" v-if="stats?.total_account_cost != null">
|
|
|
|
|
{{ t('usage.userBilled') }}:
|
|
|
|
|
<span class="text-gray-300">${{ (stats?.total_actual_cost || 0).toFixed(4) }}</span>
|
|
|
|
|
· {{ t('usage.standardCost') }}:
|
|
|
|
|
<span class="text-gray-300">${{ (stats?.total_cost || 0).toFixed(4) }}</span>
|
|
|
|
|
</p>
|
|
|
|
|
<p class="text-xs text-gray-400" v-else>
|
|
|
|
|
{{ t('usage.standardCost') }}:
|
|
|
|
|
<span class="line-through">${{ (stats?.total_cost || 0).toFixed(4) }}</span>
|
2026-01-06 22:19:07 +08:00
|
|
|
</p>
|
|
|
|
|
</div>
|
refactor(frontend): comprehensive split of large view files into modular components
- Split UsersView.vue into UserCreateModal, UserEditModal, UserApiKeysModal, etc.
- Split UsageView.vue into UsageStatsCards, UsageFilters, UsageTable, etc.
- Split DashboardView.vue into UserDashboardStats, UserDashboardCharts, etc.
- Split AccountsView.vue into AccountTableActions, AccountTableFilters, etc.
- Standardized TypeScript types across new components to resolve implicit 'any' and 'never[]' errors.
- Improved overall frontend maintainability and code clarity.
2026-01-04 22:17:27 +08:00
|
|
|
</div>
|
|
|
|
|
<div class="card p-4 flex items-center gap-3">
|
refactor(frontend): 完成所有组件的内联SVG统一替换为Icon组件
- 扩展 Icon.vue 组件,新增 60+ 图标路径
- 导航类: arrowRight, arrowLeft, arrowUp, arrowDown, chevronUp, externalLink
- 状态类: checkCircle, xCircle, exclamationCircle, exclamationTriangle, infoCircle
- 用户类: user, userCircle, userPlus, users
- 文档类: document, clipboard, copy, inbox
- 操作类: download, upload, filter, sort
- 安全类: key, lock, shield
- UI类: menu, calendar, home, terminal, gift, creditCard, mail
- 数据类: chartBar, trendingUp, database, cube
- 其他: bolt, sparkles, cloud, server, sun, moon, book 等
- 重构 56 个 Vue 组件,用 Icon 组件替换内联 SVG
- 净减少约 2200 行代码
- 提升代码可维护性和一致性
- 统一图标样式和尺寸管理
2026-01-05 20:22:48 +08:00
|
|
|
<div class="rounded-lg bg-purple-100 p-2 dark:bg-purple-900/30 text-purple-600">
|
|
|
|
|
<Icon name="clock" size="md" />
|
|
|
|
|
</div>
|
refactor(frontend): comprehensive split of large view files into modular components
- Split UsersView.vue into UserCreateModal, UserEditModal, UserApiKeysModal, etc.
- Split UsageView.vue into UsageStatsCards, UsageFilters, UsageTable, etc.
- Split DashboardView.vue into UserDashboardStats, UserDashboardCharts, etc.
- Split AccountsView.vue into AccountTableActions, AccountTableFilters, etc.
- Standardized TypeScript types across new components to resolve implicit 'any' and 'never[]' errors.
- Improved overall frontend maintainability and code clarity.
2026-01-04 22:17:27 +08:00
|
|
|
<div><p class="text-xs font-medium text-gray-500">{{ t('usage.avgDuration') }}</p><p class="text-xl font-bold">{{ formatDuration(stats?.average_duration_ms || 0) }}</p></div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script setup lang="ts">
|
refactor(frontend): 完成所有组件的内联SVG统一替换为Icon组件
- 扩展 Icon.vue 组件,新增 60+ 图标路径
- 导航类: arrowRight, arrowLeft, arrowUp, arrowDown, chevronUp, externalLink
- 状态类: checkCircle, xCircle, exclamationCircle, exclamationTriangle, infoCircle
- 用户类: user, userCircle, userPlus, users
- 文档类: document, clipboard, copy, inbox
- 操作类: download, upload, filter, sort
- 安全类: key, lock, shield
- UI类: menu, calendar, home, terminal, gift, creditCard, mail
- 数据类: chartBar, trendingUp, database, cube
- 其他: bolt, sparkles, cloud, server, sun, moon, book 等
- 重构 56 个 Vue 组件,用 Icon 组件替换内联 SVG
- 净减少约 2200 行代码
- 提升代码可维护性和一致性
- 统一图标样式和尺寸管理
2026-01-05 20:22:48 +08:00
|
|
|
import { useI18n } from 'vue-i18n'
|
|
|
|
|
import type { AdminUsageStatsResponse } from '@/api/admin/usage'
|
|
|
|
|
import Icon from '@/components/icons/Icon.vue'
|
|
|
|
|
|
|
|
|
|
defineProps<{ stats: AdminUsageStatsResponse | null }>()
|
|
|
|
|
|
|
|
|
|
const { t } = useI18n()
|
|
|
|
|
|
|
|
|
|
const formatDuration = (ms: number) =>
|
|
|
|
|
ms < 1000 ? `${ms.toFixed(0)}ms` : `${(ms / 1000).toFixed(2)}s`
|
|
|
|
|
|
|
|
|
|
const formatTokens = (value: number) => {
|
|
|
|
|
if (value >= 1e9) return (value / 1e9).toFixed(2) + 'B'
|
|
|
|
|
if (value >= 1e6) return (value / 1e6).toFixed(2) + 'M'
|
|
|
|
|
if (value >= 1e3) return (value / 1e3).toFixed(2) + 'K'
|
|
|
|
|
return value.toLocaleString()
|
|
|
|
|
}
|
|
|
|
|
</script>
|