- Add rawEnvironment field to preserve extracted environment name - Display rawEnvironment (e.g., 'timeshift') instead of 'other' in badge Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
96 lines
3.1 KiB
TypeScript
96 lines
3.1 KiB
TypeScript
'use client';
|
|
|
|
import { formatFileSize, formatDateTime } from '@/lib/utils';
|
|
import { type ApkEnvironment } from '@/lib/apk-parser';
|
|
|
|
interface Apk {
|
|
name: string;
|
|
environment: ApkEnvironment;
|
|
rawEnvironment: string;
|
|
commit: string | null;
|
|
size: number;
|
|
modifiedAt: string;
|
|
downloadUrl: string;
|
|
}
|
|
|
|
interface ApkTableProps {
|
|
apks: Apk[];
|
|
}
|
|
|
|
function getEnvironmentBadgeClass(env: ApkEnvironment): string {
|
|
switch (env) {
|
|
case 'product':
|
|
return 'bg-blue-100 text-blue-800';
|
|
case 'dev':
|
|
case 'sandbox':
|
|
return 'bg-green-100 text-green-800';
|
|
default:
|
|
return 'bg-gray-100 text-gray-800';
|
|
}
|
|
}
|
|
|
|
export default function ApkTable({ apks }: ApkTableProps) {
|
|
if (!apks || apks.length === 0) {
|
|
return (
|
|
<div className="bg-white rounded-lg shadow-md p-12 text-center">
|
|
<p className="text-gray-500">暂无 APK 文件</p>
|
|
</div>
|
|
);
|
|
}
|
|
|
|
return (
|
|
<div className="bg-white rounded-lg shadow-md overflow-hidden">
|
|
<table className="w-full">
|
|
<thead className="bg-gray-50 border-b border-gray-200">
|
|
<tr>
|
|
<th className="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
|
|
Commit ID
|
|
</th>
|
|
<th className="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
|
|
文件大小
|
|
</th>
|
|
<th className="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
|
|
创建时间
|
|
</th>
|
|
<th className="px-6 py-3 text-right text-xs font-medium text-gray-500 uppercase tracking-wider">
|
|
操作
|
|
</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody className="bg-white divide-y divide-gray-200">
|
|
{apks.map((apk) => (
|
|
<tr key={apk.name} className="hover:bg-gray-50">
|
|
<td className="px-6 py-4 whitespace-nowrap">
|
|
<div className="flex items-center gap-2">
|
|
<span className="font-mono text-sm text-gray-900">
|
|
{apk.commit || '-'}
|
|
</span>
|
|
<span className={`px-2 py-0.5 text-xs font-medium rounded ${getEnvironmentBadgeClass(apk.environment)}`}>
|
|
{apk.rawEnvironment}
|
|
</span>
|
|
</div>
|
|
</td>
|
|
<td className="px-6 py-4 whitespace-nowrap text-sm text-gray-900">
|
|
{formatFileSize(apk.size)}
|
|
</td>
|
|
<td className="px-6 py-4 whitespace-nowrap text-sm text-gray-900">
|
|
{formatDateTime(new Date(apk.modifiedAt))}
|
|
</td>
|
|
<td className="px-6 py-4 whitespace-nowrap text-right text-sm font-medium">
|
|
<a
|
|
href={apk.downloadUrl}
|
|
download
|
|
rel="noopener noreferrer"
|
|
className="inline-flex items-center px-4 py-2 bg-green-600 text-white rounded-md hover:bg-green-700 transition-colors"
|
|
>
|
|
下载
|
|
</a>
|
|
</td>
|
|
</tr>
|
|
))}
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
);
|
|
}
|