From 820bf5f2900178f954332b53b1ed6a258f8ae72b Mon Sep 17 00:00:00 2001
From: hit-cxf <2024111082@stu.hit.edu.cn>
Date: Sun, 07 Jun 2026 17:26:52 +0800
Subject: [PATCH] Optimize page layout and button rendering logic
---
video-claw/video-claw/frontend/components/stages/ReferenceStage.tsx | 49 +++++++++++++++++++++++--------------------------
1 files changed, 23 insertions(+), 26 deletions(-)
diff --git a/video-claw/video-claw/frontend/components/stages/ReferenceStage.tsx b/video-claw/video-claw/frontend/components/stages/ReferenceStage.tsx
index 3422b31..8b41d39 100644
--- a/video-claw/video-claw/frontend/components/stages/ReferenceStage.tsx
+++ b/video-claw/video-claw/frontend/components/stages/ReferenceStage.tsx
@@ -87,7 +87,7 @@
<img
src={assetUrl(path)}
alt={`v${i + 1}`}
- className="h-28 w-auto object-cover"
+ className="h-32 w-auto object-cover"
onError={(e) => { (e.target as HTMLImageElement).style.display = 'none'; }}
/>
<button
@@ -107,7 +107,7 @@
);
})}
{showPlaceholder && (
- <div className="flex-shrink-0 flex items-center justify-center h-28 aspect-video bg-gray-50 rounded-lg border border-dashed border-gray-200">
+ <div className="flex-shrink-0 flex items-center justify-center h-32 aspect-video bg-gray-50 rounded-lg border border-dashed border-gray-200">
<div className="flex items-center gap-2 text-gray-400 text-xs">
<Loader className="w-4 h-4 animate-spin" />
<span>生成中...</span>
@@ -167,6 +167,7 @@
const isFailed = scene.status === 'failed' && !isRegenerating;
const hasImage = Boolean(getSelected(scene)) || scene.versions.length > 0;
const canGenerateMissing = Boolean(allowMissingGenerate) && !hasImage && !isRunning && !isRegenerating;
+ const canShowRegenerate = !isRunning && !isPending && (hasImage || isFailed || canGenerateMissing);
const hasChanges = editDesc !== scene.description;
return (
@@ -237,31 +238,27 @@
<p className="text-xs text-gray-600 leading-relaxed whitespace-pre-wrap">{scene.description}</p>
</div>
)}
- {/* 已有图片显示重新生成;失败/旧数据空资源允许补生成。 */}
- {!isStageRunning && (hasImage || isFailed || canGenerateMissing) && (
- <button
- onClick={onRegenerate}
- disabled={isRegenerating}
- className={`mt-3 flex items-center gap-1.5 self-start px-3 py-1.5 rounded-lg text-xs font-medium transition-colors ${
- isRegenerating
- ? 'text-gray-400 bg-gray-100 cursor-not-allowed'
- : isFailed
+ <div className="mt-3 flex flex-wrap items-center gap-2">
+ {canShowRegenerate && (
+ <button
+ onClick={onRegenerate}
+ className={`inline-flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-xs font-medium transition-colors ${
+ isFailed
? 'text-red-600 bg-red-50 hover:bg-red-100'
: 'text-emerald-600 bg-emerald-50 hover:bg-emerald-100'
- }`}
- >
- <RefreshCw className={`w-3 h-3 ${isRegenerating ? 'animate-spin' : ''}`} />
- {isRegenerating ? '生成中...' : isFailed ? '点击重试' : hasImage ? '重新生成' : '生成'}
- </button>
- )}
- {!isStageRunning && (
- <label className={`mt-2 ml-auto inline-flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-xs font-medium transition-colors ${
+ }`}
+ >
+ <RefreshCw className="w-3 h-3" />
+ {isFailed ? '点击重试' : hasImage ? '重新生成' : '生成'}
+ </button>
+ )}
+ <label className={`ml-auto inline-flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-xs font-medium transition-colors ${
isUploading
? 'text-gray-400 bg-gray-100 cursor-wait'
: 'text-gray-600 bg-gray-100 hover:bg-gray-200 cursor-pointer'
}`}>
{isUploading ? <Loader className="w-3 h-3 animate-spin" /> : <Upload className="w-3 h-3" />}
- {isUploading ? '上传中...' : '上传图片'}
+ {isUploading ? '上传中...' : '上传照片'}
<input
type="file"
accept="image/*"
@@ -274,26 +271,26 @@
}}
/>
</label>
- )}
+ </div>
</div>
{/* 右侧: 图片画廊 / 占位 */}
<div className="flex-1 min-w-0 p-3 flex items-center">
{isRunning && !hasImage ? (
- <div className="flex items-center justify-center h-28 aspect-video bg-gray-50 rounded-lg border border-dashed border-gray-200">
+ <div className="flex items-center justify-center h-32 aspect-video bg-gray-50 rounded-lg border border-dashed border-gray-200">
<div className="flex items-center gap-2 text-gray-400 text-xs">
<Loader className="w-4 h-4 animate-spin" />
<span>正在生成...</span>
</div>
</div>
) : !hasImage ? (
- <div className="flex items-center justify-center h-28 aspect-video bg-gray-50/60 rounded-lg border border-dashed border-gray-200">
+ <div className="flex items-center justify-center h-32 aspect-video bg-gray-50/60 rounded-lg border border-dashed border-gray-200">
<div className="flex flex-col items-center gap-1 text-gray-400 text-xs">
{isFailed ? (
<>
<AlertCircle className="w-4 h-4" />
<span>生成失败</span>
- {!isStageRunning && (
+ {!isRunning && (
<button
onClick={onRegenerate}
disabled={isRegenerating}
@@ -308,7 +305,7 @@
<>
<ImagePlus className="w-4 h-4" />
<span>{isPending ? '等待生成...' : '暂无图片'}</span>
- {!isStageRunning && canGenerateMissing && (
+ {canGenerateMissing && (
<button
onClick={onRegenerate}
disabled={isRegenerating}
@@ -328,7 +325,7 @@
versions={scene.versions}
selected={getSelected(scene)}
onSelect={onSelectVersion}
- showPlaceholder={isRegenerating}
+ showPlaceholder={isRunning}
/>
{isFailed && (
<button
--
Gitblit v1.8.0