fix(fitting): 生成完成预览图不切换——@Builder 内方法调用不被状态追踪,改 @State resultSrc 直绑
ArkUI build 内 Image(this.previewSrc()) 方法体内部读取的 @State 不参与依赖更新, statusText 刷新但预览图停在旧帧。改为 resultSrc @State 直绑三元;生成提交即用 OSS URL 展示,转存完成后切本机副本。真机 21:05 全链路成功一次(生成+转存+对比); 此后服务端 ComfyUI 持续 503,直绑修复的默认效果图展示待服务稳定后复验。
This commit is contained in:
@@ -69,6 +69,7 @@ struct FittingRoomPage {
|
|||||||
@State statusText: string = ''
|
@State statusText: string = ''
|
||||||
@State resultUrl: string = ''
|
@State resultUrl: string = ''
|
||||||
@State resultLocalPath: string = '' // 本机留存副本:展示与保存优先走它
|
@State resultLocalPath: string = '' // 本机留存副本:展示与保存优先走它
|
||||||
|
@State resultSrc: string = '' // 结果图就绪后的直绑图源(@Builder 内方法调用不被状态追踪,禁用)
|
||||||
@State lastLocalPath: string = '' // 「上次结果」卡数据源
|
@State lastLocalPath: string = '' // 「上次结果」卡数据源
|
||||||
@State showOriginal: boolean = false
|
@State showOriginal: boolean = false
|
||||||
@State showLeaveConfirm: boolean = false // 生成中离开的挽留确认
|
@State showLeaveConfirm: boolean = false // 生成中离开的挽留确认
|
||||||
@@ -348,6 +349,7 @@ struct FittingRoomPage {
|
|||||||
return // 已被取消/离开,丢弃迟到结果
|
return // 已被取消/离开,丢弃迟到结果
|
||||||
}
|
}
|
||||||
this.resultUrl = url
|
this.resultUrl = url
|
||||||
|
this.resultSrc = url // 先用 OSS URL 展示,转存完成后切本机副本
|
||||||
this.statusText = '生成完成,正在留存到本机…'
|
this.statusText = '生成完成,正在留存到本机…'
|
||||||
const saved: boolean = await this.persistResult(url)
|
const saved: boolean = await this.persistResult(url)
|
||||||
if (gen !== this.genSeq) {
|
if (gen !== this.genSeq) {
|
||||||
@@ -425,6 +427,7 @@ struct FittingRoomPage {
|
|||||||
task.on('fail', (err: number) => reject(new Error(`download fail: ${err}`)))
|
task.on('fail', (err: number) => reject(new Error(`download fail: ${err}`)))
|
||||||
})
|
})
|
||||||
this.resultLocalPath = path
|
this.resultLocalPath = path
|
||||||
|
this.resultSrc = fileUri.getUriFromPath(path)
|
||||||
this.lastLocalPath = path
|
this.lastLocalPath = path
|
||||||
return true
|
return true
|
||||||
} catch (_e) {
|
} catch (_e) {
|
||||||
@@ -571,7 +574,7 @@ struct FittingRoomPage {
|
|||||||
|
|
||||||
// 左上「模特/效果图」角标(黑 60% 胶囊,白字 12,距边 12)
|
// 左上「模特/效果图」角标(黑 60% 胶囊,白字 12,距边 12)
|
||||||
if (this.humanUri.length > 0) {
|
if (this.humanUri.length > 0) {
|
||||||
Text(this.previewBadge())
|
Text(this.showOriginal || this.resultSrc === '' ? '模特' : '效果图')
|
||||||
.fontSize(12)
|
.fontSize(12)
|
||||||
.fontColor(Color.White)
|
.fontColor(Color.White)
|
||||||
.padding({ left: 12, right: 12, top: 8, bottom: 8 })
|
.padding({ left: 12, right: 12, top: 8, bottom: 8 })
|
||||||
|
|||||||
Reference in New Issue
Block a user