Commit ef81aeb4 authored by shaw's avatar shaw
Browse files

fix: 修复dashboard页面用户名的显示bug

parent 22414326
...@@ -541,7 +541,7 @@ export interface ModelStat { ...@@ -541,7 +541,7 @@ export interface ModelStat {
export interface UserUsageTrendPoint { export interface UserUsageTrendPoint {
date: string; date: string;
user_id: number; user_id: number;
username: string; email: string;
requests: number; requests: number;
tokens: number; tokens: number;
cost: number; // 标准计费 cost: number; // 标准计费
......
...@@ -462,13 +462,21 @@ const trendChartData = computed(() => { ...@@ -462,13 +462,21 @@ const trendChartData = computed(() => {
const userTrendChartData = computed(() => { const userTrendChartData = computed(() => {
if (!userTrend.value?.length) return null if (!userTrend.value?.length) return null
// Extract display name from email (part before @)
const getDisplayName = (email: string, userId: number): string => {
if (email && email.includes('@')) {
return email.split('@')[0]
}
return `User #${userId}`
}
// Group by user // Group by user
const userGroups = new Map<string, { name: string; data: Map<string, number> }>() const userGroups = new Map<string, { name: string; data: Map<string, number> }>()
const allDates = new Set<string>() const allDates = new Set<string>()
userTrend.value.forEach(point => { userTrend.value.forEach(point => {
allDates.add(point.date) allDates.add(point.date)
const key = point.username || `User #${point.user_id}` const key = getDisplayName(point.email, point.user_id)
if (!userGroups.has(key)) { if (!userGroups.has(key)) {
userGroups.set(key, { name: key, data: new Map() }) userGroups.set(key, { name: key, data: new Map() })
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment