Parcourir la source

补充图片,下一步去掉后台生成

kln il y a 3 semaines
Parent
commit
6ef3ec94f6

+ 22 - 0
AICalendarWallpaper/Assets.xcassets/Common/generation_failed.imageset/Contents.json

@@ -0,0 +1,22 @@
+{
+  "images" : [
+    {
+      "idiom" : "universal",
+      "scale" : "1x"
+    },
+    {
+      "filename" : "generation_failed@2x.png",
+      "idiom" : "universal",
+      "scale" : "2x"
+    },
+    {
+      "filename" : "generation_failed@3x.png",
+      "idiom" : "universal",
+      "scale" : "3x"
+    }
+  ],
+  "info" : {
+    "author" : "xcode",
+    "version" : 1
+  }
+}

BIN
AICalendarWallpaper/Assets.xcassets/Common/generation_failed.imageset/generation_failed@2x.png


BIN
AICalendarWallpaper/Assets.xcassets/Common/generation_failed.imageset/generation_failed@3x.png


+ 2 - 2
AICalendarWallpaper/Assets.xcassets/Common/text_Input_hint.imageset/Contents.json

@@ -5,12 +5,12 @@
       "scale" : "1x"
     },
     {
-      "filename" : "text_input_hint@2x.png",
+      "filename" : "text_Input_hint@2x.png",
       "idiom" : "universal",
       "scale" : "2x"
     },
     {
-      "filename" : "text_input_hint@3x.png",
+      "filename" : "text_Input_hint@3x.png",
       "idiom" : "universal",
       "scale" : "3x"
     }

+ 2 - 2
AICalendarWallpaper/Business/ASAIGeneratorVC/ASGeneratorView/ASGeneratorErrorView.swift

@@ -85,7 +85,7 @@ extension ASGeneratorErrorView {
     func sensitiveErrorView() {
         submitBtn.setTitle(isUploadImage ? "Reselect photos".localized : "Got it".localized, for: .normal)
 //        errorImageView.image = UIImage(named: "yellow_warning")
-        errorImageView.image = UIImage(named: "failed_big")
+        errorImageView.image = .generationFailed
         errorImageView.snp.updateConstraints { make in
             make.width.height.equalTo(56)
         }
@@ -96,7 +96,7 @@ extension ASGeneratorErrorView {
     
     func generalErrorView() {
         submitBtn.setTitle("Got it".localized, for: .normal)
-        errorImageView.image = UIImage(named: "failed_big")
+        errorImageView.image = .generationFailed
         
         errorImageView.snp.updateConstraints { make in
             make.width.height.equalTo(120)

+ 0 - 13
AICalendarWallpaper/Business/ASAIGeneratorVC/ASGeneratorView/ASGeneratorLoadingView.swift

@@ -47,11 +47,6 @@ class ASGeneratorLoadingView : AIBaseView {
         return textLabel
     }()
     
-//    lazy var progressView: TSRingProgressView = {
-//        let progressView = TSRingProgressView()
-//        return progressView
-//    }()
-    
     lazy var textLabel: UILabel = {
         let textLabel = UILabel.createLabel(font: .font(size: 18),textColor: .white,textAlignment: .center,numberOfLines: 0)
         textLabel.isHidden = true
@@ -103,13 +98,6 @@ class ASGeneratorLoadingView : AIBaseView {
         
         cusStackView.addSpacing(length: 12.0)
         
-//        cusStackView.addArrangedSubview(progressView)
-//        progressView.snp.makeConstraints { make in
-//            make.leading.equalTo(40)
-//            make.trailing.equalTo(-40)
-//        }
-//        
-//        cusStackView.addSpacing(length: 8.0)
         cusStackView.addArrangedSubview(textLabel)
         textLabel.snp.makeConstraints { make in
             make.leading.equalTo(kTextLeading)
@@ -162,7 +150,6 @@ extension ASGeneratorLoadingView {
     func setProgressText(progress:Float, text:String) {
         textLabel.text = text
         textLabel.isHidden = text.isEmpty
-//        progressView.setProgress(progress: progress)
     }
 
 }

+ 5 - 84
AICalendarWallpaper/Business/OperationQueue/AIGenerate/ASGenerateTTPOperation.swift

@@ -106,88 +106,25 @@ class ASGenerateTTPOperation:ASGenerateBaseOperation , @unchecked Sendable{
         }
     }
     
-
-    /**
-        1.用户上传图片
-        2.调用生成接口
-        3.后台返回查询 id,根据 id 不断查询进度和结果.(此时才允许进度后台)
-     
-        利用3后台返回的ASActionRequestModel中存着关键的请求接口数据,请求数据
-     
-     */
-    
     private var uploadRequest:Request?
     private var creatRequest:Request?
     
     func createActionInfoModel(generateStyleModel:ASGenerateStyleModel) ->ASActionInfoModel{
-
-//        guard let upLoadImageUrl = generateStyleModel.upLoadImageUrl else { return nil }
-
         let infoModel = ASActionInfoModel()
         infoModel.id = Date.timestampInt
         infoModel.request = ASActionRequestModel()
 
         infoModel.request.prompt = generateStyleModel.prompt
         infoModel.request.inputText = generateStyleModel.inputText
-        
-//        infoModel.request.style = generateStyleModel.style
-//        infoModel.request.advance = generateStyleModel.advance
-//        infoModel.request.imageUrl = upLoadImageUrl
-//        infoModel.request.imageUrlTimestamp = Date.timestampInt
-        
-        
         return infoModel
     }
     
-//    func uploadImage(generateStyleModel:ASGenerateStyleModel,complete:@escaping (ASActionInfoModel?)->Void) {
-//        
-//        guard let upLoadImage = generateStyleModel.upLoadImage else { return  }
-//        if let imageUrl = generateStyleModel.upLoadImageUrl,imageUrl.contains("http") {
-//            complete(createActionInfoModel(generateStyleModel: generateStyleModel))
-//            return
-//        }
-//        
-//        stopNetwork = false
-//        stateDatauPblished = (.start,nil)
-//        
-//        stateDatauPblished = (.progressString(uploadingPhoto(progress: 0.0)),currentActionInfoModel)
-//        uploadRequest =AINetworkManager.uploadImage(upLoadImage: upLoadImage, maxKb: imageMaxKb) { [weak self]  progress in
-//            guard let self = self else { return }
-//            if generatingProgress == 0 {
-//                stateDatauPblished = (.progressString(uploadingPhoto(progress: progress)),currentActionInfoModel)
-//            }
-//        } completion: { [weak self]  data, error in
-//            guard let self = self else { return }
-//            if stopNetwork == true { return }
-//            if let error = error {
-//                generateStyleModel.upLoadImageUrl = nil
-//                self.stateDatauPblished = (ASProgressState.getFailed(error.tsDesc,error.tsCode),nil)
-//                complete(nil)
-//            }else{
-//                if let string = data as? String {
-//                    generateStyleModel.upLoadImageUrl = string
-//                    if let url = URL(string: string){//上传成功后,就将图片缓存到本地
-//                        ImageCache.default.store(upLoadImage, forKey: url.cacheKey)
-//                    }
-//                    
-//                    complete(createActionInfoModel(generateStyleModel: generateStyleModel))
-//                }else{
-//                    complete(nil)
-//                }
-//            }
-//        }
-//    }
     
     func creatImage(oldModel:ASActionInfoModel,complete:@escaping (Bool)->Void) {
         
         initializeActionInfoModel(oldModel: oldModel)
-//        if oldModel.upImageURLExpired { return  }
-
-        generatingProgress = 0
         stopNetwork = false
 
-        
-        
         currentActionInfoModel.status = "running"
         currentActionInfoModel.actionStatus = .running
         currentActionInfoModel.percent = 0
@@ -204,12 +141,11 @@ class ASGenerateTTPOperation:ASGenerateBaseOperation , @unchecked Sendable{
                 prompt = inputText
             }
         }
-        let width = 800.0
-        let height = 1440.0
+
         creatRequest = AINetworkManager.post(endpoint:.textToImage,parameters:
                                                 ["prompt":prompt,
-                                                 "width":width,
-                                                 "height":height,
+                                                 "width":800.0,
+                                                 "height":1440.0,
                                                  "device":AIGetUserInfoJsonString,
                                                 ]) { [weak self] data,error in
             guard let self = self else { return }
@@ -235,28 +171,13 @@ class ASGenerateTTPOperation:ASGenerateBaseOperation , @unchecked Sendable{
     }
     override func generating(progress: Float) -> String {
         let progress = Float(progress)*(kPercentScale) // 预留 10% 进度给图片下载
-        //Generating 0%-100%
         var progressInt = Int(progress*100)
-
-        if progressInt > 99 {
-            progressInt = 99
-        }
-        
-        generatingProgress = progressInt
         return "Generating".localized + " \(progressInt)%"
     }
 
-    var imageMaxKb:Int{
-        return 10*1024
-    }
-    
+
     func uploadingPhoto(progress:Float) -> String {
-        //Uploading Photo 0%-100%
-        var progressInt = Int(progress*100)
-        if progressInt > 99 {
-            progressInt = 99
-        }
-        return "Uploading Photo".localized + " \(progressInt)%"
+        return "Uploading Photo".localized + " \(Int(progress*100))%"
     }