fix: 修复排名页跳转用户详情数据为0的问题

排名页使用 display_name(中文名)作为链接参数,但详情查询用
username(英文)过滤,导致 SQL 匹配不到数据全部返回0。

- 排名 API 额外返回 username 字段
- 跳转链接改用 username 作为参数
- 详情 API 返回 display_name 用于页面标题展示
This commit is contained in:
2026-04-08 20:08:08 +08:00
parent 13805a47be
commit c809ab16e6
3 changed files with 14 additions and 4 deletions

View File

@@ -13,7 +13,7 @@ type Tab = "user" | "model" | "channel";
type SortKey = "calls" | "prompt_tokens" | "completion_tokens" | "total_tokens";
interface RankItem {
rank: number; name: string; id?: number; calls: number;
rank: number; name: string; username?: string; id?: number; calls: number;
prompt_tokens: number; completion_tokens: number; total_tokens: number;
}
@@ -45,7 +45,7 @@ export default function RankingsPage() {
function detailHref(item: RankItem): string {
if (tab === "channel") return `/detail/channel/${item.id}`;
if (tab === "model") return `/detail/model/${encodeURIComponent(item.name)}`;
return `/detail/user/${encodeURIComponent(item.name)}`;
return `/detail/user/${encodeURIComponent(item.username || item.name)}`;
}
function handleSort(key: SortKey) {