import { Checkbox, Empty, Image, Space, Tag, Typography } from 'antd'; import { ProductAsset, ProductDetail } from '@/services/product'; const { Text } = Typography; const GROUP_NAME: Record = { main: '主图', sku: 'SKU 图', detail: '详情图', video: '视频', param: '参数图', generated: '生成图', }; const STATUS_TAG: Record = { pending: { color: 'default', text: '待下载' }, downloading: { color: 'processing', text: '下载中' }, uploaded: { color: 'green', text: '已就绪' }, failed: { color: 'red', text: '失败' }, }; interface Props { assets: ProductAsset[]; product: ProductDetail; onSave: (p: Partial) => void; onRefresh: () => void; } export default function ImagePanel({ assets, product, onSave }: Props) { const selected = (product.images ?? []) as string[]; const toggle = (url: string) => { const next = selected.includes(url) ? selected.filter((u) => u !== url) : [...selected, url]; onSave({ images: next }); }; const groups = [...new Set(assets.map((a) => a.group_key))]; return (
勾选图片加入发布主图(images 数组,顺序即 Ozon 展示顺序)。 {groups.length === 0 && } {groups.map((g) => (
{GROUP_NAME[g] ?? g}
{assets .filter((a) => a.group_key === g) .map((a) => { const url = a.stored_url || a.source_url; const tag = STATUS_TAG[a.status] ?? STATUS_TAG.pending; const usable = a.status === 'uploaded'; return (
{tag.text} {a.variant_name && {a.variant_name}} {usable && a.stored_url && ( toggle(a.stored_url!)} > 加入主图 )}
); })}
))}
); }