fix: 修复详情页

This commit is contained in:
root 2025-07-11 12:39:43 +08:00
parent b88ce5c0ab
commit 0b2dcecc70
2 changed files with 110 additions and 103 deletions

View File

@ -88,98 +88,105 @@ const ProjectMaterialsCenter: React.FC<ProjectMaterialsCenterProps> = ({
return (
<div className="h-full flex flex-col bg-white rounded-lg shadow-sm border border-gray-200">
{/* 头部 */}
<div className="p-6 border-b border-gray-200">
<div className="flex items-center justify-between mb-4">
<h2 className="text-xl font-bold text-gray-900"></h2>
<div className="text-sm text-gray-600">
{filteredMaterials.length} / {materials.length}
</div>
</div>
{/* 搜索栏 */}
<div className="relative mb-4">
<Search className="absolute left-3 top-1/2 transform -translate-y-1/2 text-gray-400" size={20} />
{/* 顶部搜索栏 */}
<div className="p-4 border-b border-gray-200 bg-gray-50">
<div className="relative">
<Search className="absolute left-3 top-1/2 transform -translate-y-1/2 text-gray-400" size={18} />
<input
type="text"
placeholder="搜索素材名称或标签..."
value={searchTerm}
onChange={(e) => setSearchTerm(e.target.value)}
className="pl-10 pr-4 py-3 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent w-full"
className="pl-10 pr-4 py-2.5 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent w-full text-sm"
/>
</div>
</div>
{/* 模特筛选标签 */}
<div className="mb-4">
<div className="flex items-center mb-2">
<User size={16} className="text-gray-400 mr-2" />
<span className="text-sm font-medium text-gray-700">:</span>
</div>
<div className="flex flex-wrap gap-2">
{models.map((model) => (
<button
key={model.id}
onClick={() => handleModelToggle(model.id)}
className={`px-3 py-1 text-sm rounded-full border transition-colors ${
selectedModelIds.includes(model.id)
? 'bg-blue-600 text-white border-blue-600'
: 'bg-white text-gray-700 border-gray-300 hover:border-blue-400'
}`}
>
{model.model_number}
</button>
))}
{selectedModelIds.length > 0 && (
<button
onClick={() => setSelectedModelIds([])}
className="px-3 py-1 text-sm bg-red-100 text-red-700 rounded-full hover:bg-red-200 transition-colors"
>
</button>
)}
{/* 筛选和标题区域 */}
<div className="p-4 border-b border-gray-200">
<div className="flex items-center justify-between mb-3">
<h2 className="text-lg font-semibold text-gray-900"></h2>
<div className="text-sm text-gray-600">
{filteredMaterials.length} / {materials.length}
</div>
</div>
{/* 类型过滤 */}
<div className="flex items-center space-x-4">
<div className="flex items-center">
<Filter size={16} className="text-gray-400 mr-2" />
<span className="text-sm font-medium text-gray-700">:</span>
</div>
<div className="flex space-x-2">
{[
{ value: 'all', label: '全部' },
{ value: 'original', label: '原始素材' },
{ value: 'segmented', label: '已分镜头' }
].map((option) => (
<button
key={option.value}
onClick={() => setFilterType(option.value as any)}
className={`px-3 py-1 text-sm rounded-lg transition-colors ${
filterType === option.value
? 'bg-blue-100 text-blue-700'
: 'bg-gray-100 text-gray-600 hover:bg-gray-200'
}`}
>
{option.label}
</button>
))}
{/* 筛选器 - 紧凑布局 */}
<div className="space-y-3">
{/* 模特筛选 */}
{models.length > 0 && (
<div>
<div className="flex items-center mb-2">
<User size={14} className="text-gray-400 mr-1" />
<span className="text-xs font-medium text-gray-700">:</span>
</div>
<div className="flex flex-wrap gap-1.5">
{models.map((model) => (
<button
key={model.id}
onClick={() => handleModelToggle(model.id)}
className={`px-2 py-1 text-xs rounded-full border transition-colors ${
selectedModelIds.includes(model.id)
? 'bg-blue-600 text-white border-blue-600'
: 'bg-white text-gray-700 border-gray-300 hover:border-blue-400'
}`}
>
{model.model_number}
</button>
))}
{selectedModelIds.length > 0 && (
<button
onClick={() => setSelectedModelIds([])}
className="px-2 py-1 text-xs bg-red-100 text-red-700 rounded-full hover:bg-red-200 transition-colors"
>
</button>
)}
</div>
</div>
)}
{/* 类型过滤 */}
<div className="flex items-center space-x-3">
<div className="flex items-center">
<Filter size={14} className="text-gray-400 mr-1" />
<span className="text-xs font-medium text-gray-700">:</span>
</div>
<div className="flex space-x-1.5">
{[
{ value: 'all', label: '全部' },
{ value: 'original', label: '原始' },
{ value: 'segmented', label: '分镜' }
].map((option) => (
<button
key={option.value}
onClick={() => setFilterType(option.value as any)}
className={`px-2 py-1 text-xs rounded transition-colors ${
filterType === option.value
? 'bg-blue-100 text-blue-700'
: 'bg-gray-100 text-gray-600 hover:bg-gray-200'
}`}
>
{option.label}
</button>
))}
</div>
</div>
</div>
</div>
{/* 素材网格 */}
<div className="flex-1 overflow-y-auto p-6">
<div className="flex-1 overflow-y-auto p-4">
{filteredMaterials.length === 0 ? (
<div className="text-center py-12">
<Video className="mx-auto text-gray-400 mb-4" size={64} />
<h3 className="text-lg font-medium text-gray-900 mb-2">
<div className="text-center py-8">
<Video className="mx-auto text-gray-400 mb-3" size={48} />
<h3 className="text-base font-medium text-gray-900 mb-1">
{searchTerm || selectedModelIds.length > 0 || filterType !== 'all'
? '没有找到匹配的素材'
: '暂无项目素材'
}
</h3>
<p className="text-gray-600">
<p className="text-sm text-gray-600">
{searchTerm || selectedModelIds.length > 0 || filterType !== 'all'
? '尝试调整搜索条件或筛选器'
: `上传包含"${project.product_name}"标签的视频素材`
@ -187,11 +194,11 @@ const ProjectMaterialsCenter: React.FC<ProjectMaterialsCenterProps> = ({
</p>
</div>
) : (
<div className="grid grid-cols-1 lg:grid-cols-2 xl:grid-cols-3 gap-6">
<div className="grid grid-cols-1 lg:grid-cols-2 xl:grid-cols-3 2xl:grid-cols-4 gap-4">
{filteredMaterials.map((material) => (
<div key={material.id} className="bg-gray-50 rounded-lg overflow-hidden hover:shadow-md transition-shadow border border-gray-200">
{/* 视频缩略图 */}
<div className="relative h-40 bg-gray-100">
<div className="relative h-32 bg-gray-100">
{material.thumbnail_path ? (
<img
src={material.thumbnail_path}
@ -200,7 +207,7 @@ const ProjectMaterialsCenter: React.FC<ProjectMaterialsCenterProps> = ({
/>
) : (
<div className="w-full h-full flex items-center justify-center">
<Video size={32} className="text-gray-400" />
<Video size={28} className="text-gray-400" />
</div>
)}
@ -208,15 +215,15 @@ const ProjectMaterialsCenter: React.FC<ProjectMaterialsCenterProps> = ({
<div className="absolute inset-0 bg-black bg-opacity-0 hover:bg-opacity-30 transition-all flex items-center justify-center">
<button
onClick={() => handlePlayMaterial(material)}
className="p-3 bg-white/80 rounded-full hover:bg-white transition-colors opacity-0 hover:opacity-100"
className="p-2 bg-white/80 rounded-full hover:bg-white transition-colors opacity-0 hover:opacity-100"
>
<Play size={24} className="text-gray-800" />
<Play size={20} className="text-gray-800" />
</button>
</div>
{/* 类型标识 */}
<div className="absolute top-2 left-2">
<span className={`px-2 py-1 text-xs rounded-full ${
<div className="absolute top-1.5 left-1.5">
<span className={`px-1.5 py-0.5 text-xs rounded ${
material.segment_index === 0
? 'bg-green-100 text-green-800'
: 'bg-purple-100 text-purple-800'
@ -226,62 +233,62 @@ const ProjectMaterialsCenter: React.FC<ProjectMaterialsCenterProps> = ({
</div>
{/* 使用次数 */}
<div className="absolute top-2 right-2">
<span className="px-2 py-1 text-xs bg-black/50 text-white rounded-full">
使 {material.use_count}
<div className="absolute top-1.5 right-1.5">
<span className="px-1.5 py-0.5 text-xs bg-black/60 text-white rounded">
{material.use_count}
</span>
</div>
</div>
{/* 素材信息 */}
<div className="p-4">
<h4 className="font-medium text-gray-900 mb-2 truncate" title={material.filename}>
<div className="p-3">
<h4 className="font-medium text-gray-900 mb-1.5 truncate text-sm" title={material.filename}>
{material.filename}
</h4>
{/* 基本信息 */}
<div className="flex items-center text-sm text-gray-600 mb-3">
<Clock size={14} className="mr-1" />
<div className="flex items-center text-xs text-gray-600 mb-2">
<Clock size={12} className="mr-1" />
<span>{formatDuration(material.duration)}</span>
<span className="mx-2"></span>
<HardDrive size={14} className="mr-1" />
<span className="mx-1.5"></span>
<HardDrive size={12} className="mr-1" />
<span>{formatFileSize(material.file_size)}</span>
</div>
{/* 标签 */}
<div className="flex flex-wrap gap-1 mb-3">
{(material.tags || []).slice(0, 3).map((tag, index) => (
<div className="flex flex-wrap gap-1 mb-2">
{(material.tags || []).slice(0, 2).map((tag, index) => (
<span
key={index}
className={`inline-flex items-center px-2 py-1 text-xs rounded-full ${
className={`inline-flex items-center px-1.5 py-0.5 text-xs rounded ${
tag === project.product_name
? 'bg-blue-100 text-blue-800'
: 'bg-gray-100 text-gray-700'
}`}
>
<Tag size={10} className="mr-1" />
<Tag size={8} className="mr-0.5" />
{tag}
</span>
))}
{(material.tags || []).length > 3 && (
<span className="text-xs text-gray-500">+{(material.tags || []).length - 3}</span>
{(material.tags || []).length > 2 && (
<span className="text-xs text-gray-500">+{(material.tags || []).length - 2}</span>
)}
</div>
{/* 操作按钮 */}
<div className="flex items-center justify-between">
<div className="flex items-center justify-between gap-2">
<button
onClick={() => handlePlayMaterial(material)}
className="flex items-center px-3 py-1 text-sm text-blue-600 hover:text-blue-700 transition-colors"
className="flex items-center px-2 py-1 text-xs text-blue-600 hover:text-blue-700 transition-colors"
>
<Eye size={14} className="mr-1" />
<Eye size={12} className="mr-1" />
</button>
<button
onClick={() => handleUseMaterial(material)}
className="px-4 py-2 bg-blue-600 text-white text-sm rounded-lg hover:bg-blue-700 transition-colors"
className="px-3 py-1.5 bg-blue-600 text-white text-xs rounded hover:bg-blue-700 transition-colors"
>
使
使
</button>
</div>
</div>

View File

@ -149,7 +149,7 @@ const ProjectDetailPage: React.FC = () => {
{/* 主要内容区域 - 三栏布局 */}
<div className="flex h-[calc(100vh-120px)]">
{/* 中间主要区域 - 项目素材管理 */}
<div className="flex-1 px-6 py-4 overflow-hidden">
<div className="flex-1 px-4 py-3 overflow-hidden">
<ProjectMaterialsCenter
project={project}
materials={projectMaterials}