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

View File

@ -149,7 +149,7 @@ const ProjectDetailPage: React.FC = () => {
{/* 主要内容区域 - 三栏布局 */} {/* 主要内容区域 - 三栏布局 */}
<div className="flex h-[calc(100vh-120px)]"> <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 <ProjectMaterialsCenter
project={project} project={project}
materials={projectMaterials} materials={projectMaterials}