fix image url

This commit is contained in:
songtianlun 2025-08-31 13:48:02 +08:00
parent 10edcf44d5
commit e3e37fe515

View File

@ -165,7 +165,7 @@ export default function SimulatorRunPage({ params }: { params: Promise<{ id: str
setRun(data) setRun(data)
// 如果是图片类型,优先使用 generatedFilePath 获取临时URL // 如果是图片类型,优先使用 generatedFilePath 获取临时URL
if (data.outputType === 'image') { if (data.model?.outputType === 'image') {
if (data.generatedFilePath) { if (data.generatedFilePath) {
// 有文件路径获取临时URL // 有文件路径获取临时URL
fetchImageUrl(runId) fetchImageUrl(runId)
@ -435,13 +435,13 @@ export default function SimulatorRunPage({ params }: { params: Promise<{ id: str
// 对于图片类型,不显示 output 作为文本内容 // 对于图片类型,不显示 output 作为文本内容
const currentOutput = (isExecuting && run.status === 'pending') const currentOutput = (isExecuting && run.status === 'pending')
? streamOutput ? streamOutput
: (run?.outputType === 'image' ? '' : run.output) : (run?.model?.outputType === 'image' ? '' : run.output)
// 获取图片数据使用临时URL或提取的URL // 获取图片数据使用临时URL或提取的URL
const imageData = generatedImageUrl const imageData = generatedImageUrl
// 调试:在开发环境中显示图片数据信息 // 调试:在开发环境中显示图片数据信息
if (process.env.NODE_ENV === 'development' && run?.outputType === 'image') { if (process.env.NODE_ENV === 'development' && run?.model?.outputType === 'image') {
console.log('Image data info:', { console.log('Image data info:', {
hasGeneratedFilePath: !!run?.generatedFilePath, hasGeneratedFilePath: !!run?.generatedFilePath,
generatedFilePath: run?.generatedFilePath, generatedFilePath: run?.generatedFilePath,
@ -897,7 +897,7 @@ export default function SimulatorRunPage({ params }: { params: Promise<{ id: str
<span className="text-sm font-medium">{t('generating')}</span> <span className="text-sm font-medium">{t('generating')}</span>
</div> </div>
{/* 只在非图片类型时显示流式输出 */} {/* 只在非图片类型时显示流式输出 */}
{run.outputType !== 'image' && ( {run.model?.outputType !== 'image' && (
<div <div
ref={outputRef} ref={outputRef}
className="bg-muted rounded-md p-4 border min-h-64 max-h-96 overflow-y-auto" className="bg-muted rounded-md p-4 border min-h-64 max-h-96 overflow-y-auto"
@ -909,7 +909,7 @@ export default function SimulatorRunPage({ params }: { params: Promise<{ id: str
</div> </div>
)} )}
{/* 图片类型显示等待状态 */} {/* 图片类型显示等待状态 */}
{run.outputType === 'image' && ( {run.model?.outputType === 'image' && (
<div className="bg-gradient-to-br from-slate-50 via-background to-slate-50 dark:from-slate-900 dark:via-background dark:to-slate-900 rounded-2xl p-12 border shadow-lg"> <div className="bg-gradient-to-br from-slate-50 via-background to-slate-50 dark:from-slate-900 dark:via-background dark:to-slate-900 rounded-2xl p-12 border shadow-lg">
<div className="flex flex-col items-center justify-center space-y-6"> <div className="flex flex-col items-center justify-center space-y-6">
<div className="relative"> <div className="relative">
@ -941,7 +941,7 @@ export default function SimulatorRunPage({ params }: { params: Promise<{ id: str
</div> </div>
</div> </div>
</div> </div>
) : (run.outputType === 'image' && imageData) || (run.outputType !== 'image' && currentOutput) ? ( ) : (run.model?.outputType === 'image' && imageData) || (run.model?.outputType !== 'image' && currentOutput) ? (
<div> <div>
<div className="flex items-center space-x-2 mb-4 text-green-600 dark:text-green-400"> <div className="flex items-center space-x-2 mb-4 text-green-600 dark:text-green-400">
<CheckCircle2 className="h-4 w-4" /> <CheckCircle2 className="h-4 w-4" />
@ -949,7 +949,7 @@ export default function SimulatorRunPage({ params }: { params: Promise<{ id: str
</div> </div>
{/* 图片输出 */} {/* 图片输出 */}
{run.outputType === 'image' && imageData && ( {run.model?.outputType === 'image' && imageData && (
<div className="bg-gradient-to-br from-slate-50 via-background to-slate-50 dark:from-slate-900 dark:via-background dark:to-slate-900 rounded-2xl p-8 border shadow-lg"> <div className="bg-gradient-to-br from-slate-50 via-background to-slate-50 dark:from-slate-900 dark:via-background dark:to-slate-900 rounded-2xl p-8 border shadow-lg">
<div className="text-center mb-6"> <div className="text-center mb-6">
<div className="inline-flex items-center space-x-2 px-3 py-1.5 bg-primary/10 text-primary rounded-full text-sm font-medium mb-4"> <div className="inline-flex items-center space-x-2 px-3 py-1.5 bg-primary/10 text-primary rounded-full text-sm font-medium mb-4">
@ -1032,7 +1032,7 @@ export default function SimulatorRunPage({ params }: { params: Promise<{ id: str
)} )}
{/* 文本输出 - 只在非图片类型时显示 */} {/* 文本输出 - 只在非图片类型时显示 */}
{run.outputType !== 'image' && currentOutput && ( {run.model?.outputType !== 'image' && currentOutput && (
<div className="bg-muted rounded-md p-4 border min-h-32 max-h-96 overflow-y-auto"> <div className="bg-muted rounded-md p-4 border min-h-32 max-h-96 overflow-y-auto">
<div className="text-sm text-foreground whitespace-pre-wrap"> <div className="text-sm text-foreground whitespace-pre-wrap">
{currentOutput} {currentOutput}
@ -1041,7 +1041,7 @@ export default function SimulatorRunPage({ params }: { params: Promise<{ id: str
)} )}
{/* 图片错误状态 */} {/* 图片错误状态 */}
{run.outputType === 'image' && imageData && imageLoadError && ( {run.model?.outputType === 'image' && imageData && imageLoadError && (
<div className="bg-gradient-to-br from-red-50 to-red-100 dark:from-red-950/50 dark:to-red-900/50 rounded-xl p-8 border border-red-200 dark:border-red-800"> <div className="bg-gradient-to-br from-red-50 to-red-100 dark:from-red-950/50 dark:to-red-900/50 rounded-xl p-8 border border-red-200 dark:border-red-800">
<div className="flex flex-col items-center justify-center space-y-4"> <div className="flex flex-col items-center justify-center space-y-4">
<div className="p-3 bg-red-100 dark:bg-red-900 rounded-full"> <div className="p-3 bg-red-100 dark:bg-red-900 rounded-full">
@ -1069,7 +1069,7 @@ export default function SimulatorRunPage({ params }: { params: Promise<{ id: str
)} )}
{/* 图片加载中状态 */} {/* 图片加载中状态 */}
{run.outputType === 'image' && !imageData && isLoadingImage && ( {run.model?.outputType === 'image' && !imageData && isLoadingImage && (
<div className="bg-gradient-to-br from-slate-50 via-background to-slate-50 dark:from-slate-900 dark:via-background dark:to-slate-900 rounded-2xl p-12 border shadow-lg"> <div className="bg-gradient-to-br from-slate-50 via-background to-slate-50 dark:from-slate-900 dark:via-background dark:to-slate-900 rounded-2xl p-12 border shadow-lg">
<div className="flex flex-col items-center justify-center space-y-6"> <div className="flex flex-col items-center justify-center space-y-6">
<div className="relative"> <div className="relative">
@ -1089,7 +1089,7 @@ export default function SimulatorRunPage({ params }: { params: Promise<{ id: str
</div> </div>
)} )}
</div> </div>
) : run.outputType === 'image' && !imageData && !isLoadingImage ? ( ) : run.model?.outputType === 'image' && !imageData && !isLoadingImage ? (
<div className="text-center py-12"> <div className="text-center py-12">
<Eye className="h-16 w-16 text-muted-foreground mx-auto mb-4" /> <Eye className="h-16 w-16 text-muted-foreground mx-auto mb-4" />
<p className="text-muted-foreground"> <p className="text-muted-foreground">