| | |
| | | <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 |
| | |
| | | ); |
| | | })} |
| | | {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> |
| | |
| | | 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 ( |
| | |
| | | <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/*" |
| | |
| | | }} |
| | | /> |
| | | </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} |
| | |
| | | <> |
| | | <ImagePlus className="w-4 h-4" /> |
| | | <span>{isPending ? '等待生成...' : '暂无图片'}</span> |
| | | {!isStageRunning && canGenerateMissing && ( |
| | | {canGenerateMissing && ( |
| | | <button |
| | | onClick={onRegenerate} |
| | | disabled={isRegenerating} |
| | |
| | | versions={scene.versions} |
| | | selected={getSelected(scene)} |
| | | onSelect={onSelectVersion} |
| | | showPlaceholder={isRegenerating} |
| | | showPlaceholder={isRunning} |
| | | /> |
| | | {isFailed && ( |
| | | <button |