Commit fa295967 authored by netyouli's avatar netyouli

优化AI图生图功能

parent a05f35b4
...@@ -189,12 +189,21 @@ class AIDrawImageResultController extends GetxController { ...@@ -189,12 +189,21 @@ class AIDrawImageResultController extends GetxController {
} }
Map<String, dynamic> jsonMap = jsonDecode("${event.data}"); Map<String, dynamic> jsonMap = jsonDecode("${event.data}");
final model = MidJourneyImageModel.fromJson(jsonMap); final model = MidJourneyImageModel.fromJson(jsonMap);
final progressStr = model.progressStr ?? "";
if (progressStr.isNotEmpty) {
showProgressView.value = false;
EasyLoading.showError("AI生成图片错误:$progressStr");
return;
}
if (model.response?.buttonMessageId != null) { if (model.response?.buttonMessageId != null) {
_buttonMessageId = model.response?.buttonMessageId ?? ""; _buttonMessageId = model.response?.buttonMessageId ?? "";
} }
progress.value = model.progress ?? 0; progress.value = model.progress ?? 0;
if (model.progress == 100) { if (model.progress == 100) {
showProgressView.value = false; showProgressView.value = false;
if (model.response?.imageUrl == null) {
EasyLoading.showError("AI生成图片错误:imageUrl为null");
}
} }
final progressBase64 = model.progressBase64 ?? ""; final progressBase64 = model.progressBase64 ?? "";
if (model.response?.imageUrl != null) { if (model.response?.imageUrl != null) {
......
...@@ -26,13 +26,15 @@ class MidJourneyModel { ...@@ -26,13 +26,15 @@ class MidJourneyModel {
class MidJourneyImageModel { class MidJourneyImageModel {
int? progress; int? progress;
String? progressImageUrl; String? progressImageUrl;
String? progressStr;
String? progressBase64; String? progressBase64;
MidJourneyImageResponse? response; MidJourneyImageResponse? response;
MidJourneyImageModel({this.progress, this.progressImageUrl, this.response, this.progressBase64,}); MidJourneyImageModel({this.progress, this.progressStr, this.progressImageUrl, this.response, this.progressBase64,});
MidJourneyImageModel.fromJson(Map<String, dynamic> json) { MidJourneyImageModel.fromJson(Map<String, dynamic> json) {
progress = json['progress']; progress = json['progress'];
progressStr = json['progressStr'];
progressImageUrl = json['progressImageUrl']; progressImageUrl = json['progressImageUrl'];
response = json['response'] != null response = json['response'] != null
? new MidJourneyImageResponse.fromJson(json['response']) ? new MidJourneyImageResponse.fromJson(json['response'])
...@@ -43,6 +45,7 @@ class MidJourneyImageModel { ...@@ -43,6 +45,7 @@ class MidJourneyImageModel {
Map<String, dynamic> toJson() { Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>(); final Map<String, dynamic> data = new Map<String, dynamic>();
data['progress'] = this.progress; data['progress'] = this.progress;
data['progressStr'] = this.progressStr;
data['progressImageUrl'] = this.progressImageUrl; data['progressImageUrl'] = this.progressImageUrl;
if (this.response != null) { if (this.response != null) {
data['response'] = this.response?.toJson(); data['response'] = this.response?.toJson();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment