fix image url
This commit is contained in:
parent
10edcf44d5
commit
e3e37fe515
@ -165,7 +165,7 @@ export default function SimulatorRunPage({ params }: { params: Promise<{ id: str
|
||||
setRun(data)
|
||||
|
||||
// 如果是图片类型,优先使用 generatedFilePath 获取临时URL
|
||||
if (data.outputType === 'image') {
|
||||
if (data.model?.outputType === 'image') {
|
||||
if (data.generatedFilePath) {
|
||||
// 有文件路径,获取临时URL
|
||||
fetchImageUrl(runId)
|
||||
@ -435,13 +435,13 @@ export default function SimulatorRunPage({ params }: { params: Promise<{ id: str
|
||||
// 对于图片类型,不显示 output 作为文本内容
|
||||
const currentOutput = (isExecuting && run.status === 'pending')
|
||||
? streamOutput
|
||||
: (run?.outputType === 'image' ? '' : run.output)
|
||||
: (run?.model?.outputType === 'image' ? '' : run.output)
|
||||
|
||||
// 获取图片数据(使用临时URL或提取的URL)
|
||||
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:', {
|
||||
hasGeneratedFilePath: !!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>
|
||||
</div>
|
||||
{/* 只在非图片类型时显示流式输出 */}
|
||||
{run.outputType !== 'image' && (
|
||||
{run.model?.outputType !== 'image' && (
|
||||
<div
|
||||
ref={outputRef}
|
||||
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>
|
||||
)}
|
||||
{/* 图片类型显示等待状态 */}
|
||||
{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="flex flex-col items-center justify-center space-y-6">
|
||||
<div className="relative">
|
||||
@ -941,7 +941,7 @@ export default function SimulatorRunPage({ params }: { params: Promise<{ id: str
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
) : (run.outputType === 'image' && imageData) || (run.outputType !== 'image' && currentOutput) ? (
|
||||
) : (run.model?.outputType === 'image' && imageData) || (run.model?.outputType !== 'image' && currentOutput) ? (
|
||||
<div>
|
||||
<div className="flex items-center space-x-2 mb-4 text-green-600 dark:text-green-400">
|
||||
<CheckCircle2 className="h-4 w-4" />
|
||||
@ -949,7 +949,7 @@ export default function SimulatorRunPage({ params }: { params: Promise<{ id: str
|
||||
</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="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">
|
||||
@ -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="text-sm text-foreground whitespace-pre-wrap">
|
||||
{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="flex flex-col items-center justify-center space-y-4">
|
||||
<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="flex flex-col items-center justify-center space-y-6">
|
||||
<div className="relative">
|
||||
@ -1089,7 +1089,7 @@ export default function SimulatorRunPage({ params }: { params: Promise<{ id: str
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
) : run.outputType === 'image' && !imageData && !isLoadingImage ? (
|
||||
) : run.model?.outputType === 'image' && !imageData && !isLoadingImage ? (
|
||||
<div className="text-center py-12">
|
||||
<Eye className="h-16 w-16 text-muted-foreground mx-auto mb-4" />
|
||||
<p className="text-muted-foreground">
|
||||
|
Loading…
Reference in New Issue
Block a user