import { getTagColor } from '../../shared/constants'; import { Badge } from '../../components/ui/badge'; import { Button } from '../../components/ui/button'; import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuSeparator, DropdownMenuTrigger } from '../../components/ui/dropdown-menu'; import { Apple, ArrowUpDown, Check, Ellipsis, Eye, Image, Monitor, Pencil, RefreshCw, Smartphone, Tag, User } from 'lucide-vue-next'; import { formatDateFilter, getAvailablePlatforms, getPlatformInfo, timeToText } from '../../shared/utils'; import { i18n } from '../../plugin'; const { t } = i18n.global; const sortButton = ({ column, label, descFirst = false }) => { const resolvedLabel = typeof label === 'function' ? label() : label; return ( ); }; export function getColumns({ onShowAvatarDialog, onContextMenuAction, currentAvatarId }) { return [ { id: 'active', header: () => null, size: 40, enableSorting: false, enableResizing: false, cell: ({ row }) => { const ref = row.original; const isActive = ref.id === currentAvatarId.value; return (
); } }, { id: 'thumbnail', header: () => null, size: 64, enableSorting: false, enableResizing: false, cell: ({ row }) => { const ref = row.original; return ( onShowAvatarDialog(ref.id)} /> ); } }, { id: 'name', accessorKey: 'Name', header: ({ column }) => sortButton({ column, label: () => t('dialog.avatar.info.name') }), size: 200, meta: { label: () => t('dialog.avatar.info.name') }, cell: ({ row }) => { const ref = row.original; return ( { e.stopPropagation(); onShowAvatarDialog(ref.id); }} > {ref.name} ); } }, { id: 'customTags', accessorFn: (row) => (row.$tags || []).map((t) => t.tag).join(', '), header: () => t('dialog.avatar.info.tags'), size: 150, enableSorting: false, meta: { label: () => t('dialog.avatar.info.tags') }, cell: ({ row }) => { const tags = row.original.$tags || []; if (!tags.length) return null; return (
{tags.map((entry) => { const hashColor = getTagColor(entry.tag); const storedColor = typeof entry.color === 'string' ? entry.color : null; const bg = storedColor || hashColor.bg; const text = storedColor ? storedColor.replace(/\/ [\d.]+\)$/, ')') : hashColor.text; return ( {entry.tag} ); })}
); } }, { id: 'platforms', header: () => t('dialog.avatar.info.platform'), size: 120, enableSorting: false, meta: { label: () => t('dialog.avatar.info.platform') }, cell: ({ row }) => { const ref = row.original; const platforms = getAvailablePlatforms(ref.unityPackages); return (
{platforms.isPC && ( )} {platforms.isQuest && ( )} {platforms.isIos && ( )}
); } }, { id: 'visibility', accessorKey: 'releaseStatus', header: () => t('dialog.avatar.info.visibility'), size: 120, meta: { label: () => t('dialog.avatar.info.visibility') }, cell: ({ row }) => { const ref = row.original; return ( {ref.releaseStatus === 'public' ? t('dialog.avatar.tags.public') : t('dialog.avatar.tags.private')} ); } }, { id: 'timeSpent', accessorFn: (row) => row?.$timeSpent ?? 0, header: ({ column }) => sortButton({ column, label: () => t('dialog.avatar.info.time_spent'), descFirst: true }), size: 140, meta: { class: 'text-right', label: () => t('dialog.avatar.info.time_spent') }, cell: ({ row }) => { const time = row.original?.$timeSpent; return time ? {timeToText(time)} : -; } }, { id: 'version', accessorKey: 'version', header: ({ column }) => sortButton({ column, label: () => t('dialog.avatar.info.version'), descFirst: true }), size: 90, meta: { class: 'text-right', label: () => t('dialog.avatar.info.version') }, cell: ({ row }) => {row.original.version ?? '-'} }, { id: 'pcPerf', accessorFn: (row) => getPlatformInfo(row.unityPackages)?.pc?.performanceRating ?? '', header: ({ column }) => sortButton({ column, label: () => t('dialog.avatar.info.pc_performance') }), size: 140, meta: { label: () => t('dialog.avatar.info.pc_performance') }, cell: ({ row }) => { const perf = getPlatformInfo(row.original.unityPackages)?.pc ?.performanceRating; return perf ? ( {perf} ) : ( - ); } }, { id: 'androidPerf', accessorFn: (row) => getPlatformInfo(row.unityPackages)?.android ?.performanceRating ?? '', header: ({ column }) => sortButton({ column, label: () => t('dialog.avatar.info.android_performance') }), size: 140, meta: { label: () => t('dialog.avatar.info.android_performance') }, cell: ({ row }) => { const perf = getPlatformInfo(row.original.unityPackages) ?.android?.performanceRating; return perf ? ( {perf} ) : ( - ); } }, { id: 'iosPerf', accessorFn: (row) => getPlatformInfo(row.unityPackages)?.ios?.performanceRating ?? '', header: ({ column }) => sortButton({ column, label: () => t('dialog.avatar.info.ios_performance') }), size: 140, meta: { label: () => t('dialog.avatar.info.ios_performance') }, cell: ({ row }) => { const perf = getPlatformInfo(row.original.unityPackages)?.ios ?.performanceRating; return perf ? ( {perf} ) : ( - ); } }, { id: 'updated_at', accessorKey: 'updated_at', header: ({ column }) => sortButton({ column, label: () => t('dialog.avatar.info.last_updated'), descFirst: true }), size: 160, meta: { label: () => t('dialog.avatar.info.last_updated') }, cell: ({ row }) => { const ref = row.original; return {formatDateFilter(ref.updated_at, 'long')}; } }, { id: 'created_at', accessorKey: 'created_at', header: ({ column }) => sortButton({ column, label: () => t('dialog.avatar.info.created_at'), descFirst: true }), size: 160, meta: { label: () => t('dialog.avatar.info.created_at') }, cell: ({ row }) => { const ref = row.original; return {formatDateFilter(ref.created_at, 'long')}; } }, { id: 'actions', header: () => null, size: 100, enableSorting: false, enableResizing: false, cell: ({ row }) => { const ref = row.original; return (
e.stopPropagation()} > onShowAvatarDialog(ref.id)} > {t('dialog.avatar.actions.view_details')} onContextMenuAction('manageTags', ref) } > {t('dialog.avatar.actions.manage_tags')} {ref.releaseStatus === 'public' ? ( onContextMenuAction( 'makePrivate', ref ) } > {t( 'dialog.avatar.actions.make_private' )} ) : ( onContextMenuAction( 'makePublic', ref ) } > {t('dialog.avatar.actions.make_public')} )} onContextMenuAction('rename', ref) } > {t('dialog.avatar.actions.rename')} onContextMenuAction( 'changeDescription', ref ) } > {t( 'dialog.avatar.actions.change_description' )} onContextMenuAction('changeTags', ref) } > {t( 'dialog.avatar.actions.change_content_tags' )} onContextMenuAction('changeStyles', ref) } > {t( 'dialog.avatar.actions.change_styles_author_tags' )} onContextMenuAction('changeImage', ref) } > {t('dialog.avatar.actions.change_image')} onContextMenuAction( 'createImpostor', ref ) } > {t('dialog.avatar.actions.create_impostor')}
); } } ]; }