import type { ColumnDef } from "@tanstack/react-table" import { Badge } from "@/components/ui/badge" import type { User, UserTier } from "@/types/user" const TIER_LABELS: Record = { free: "免费", pro: "Pro", proplus: "Pro+", } const TIER_VARIANTS: Record = { free: "secondary", pro: "default", proplus: "destructive", } const AUTH_TYPE_LABELS: Record = { huawei: "华为", guest: "游客", phone: "手机", apple: "Apple", google: "Google", } export function getColumns(): ColumnDef[] { return [ { accessorKey: "nickname", header: "昵称", cell: ({ row }) => { const nickname = row.getValue("nickname") as string | null return ( {nickname || 未设置} ) }, }, { accessorKey: "authType", header: "登录方式", cell: ({ row }) => { const authType = row.getValue("authType") as string return ( {AUTH_TYPE_LABELS[authType] ?? authType} ) }, }, { accessorKey: "tier", header: "订阅", cell: ({ row }) => { const tier = row.getValue("tier") as UserTier return {TIER_LABELS[tier]} }, }, { accessorKey: "xpTotal", header: "总 XP", cell: ({ row }) => ( {(row.getValue("xpTotal") as number).toLocaleString()} ), }, { accessorKey: "streakDays", header: "连续天数", cell: ({ row }) => ( {row.getValue("streakDays")} 天 ), }, { accessorKey: "heartsRemaining", header: "红心", cell: ({ row }) => ( {row.getValue("heartsRemaining")} ), }, { accessorKey: "createdAt", header: "注册时间", cell: ({ row }) => ( {new Date(row.getValue("createdAt") as string).toLocaleDateString("zh-CN")} ), }, ] }