100Years 2 сар өмнө
parent
commit
58c2b2e1af

+ 4 - 0
TSLiveWallpaper.xcodeproj/project.pbxproj

@@ -152,6 +152,7 @@
 		A8F8BCE62E04F62400EF4AA6 /* TSAIListPhotoGeneratorModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = A8F8BCE52E04F62200EF4AA6 /* TSAIListPhotoGeneratorModel.swift */; };
 		A8F8BCEB2E0501DC00EF4AA6 /* TSAppUpdateAlertVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = A8F8BCEA2E0501DB00EF4AA6 /* TSAppUpdateAlertVC.swift */; };
 		A8F8BCED2E0513D000EF4AA6 /* animated_photos.webp in Resources */ = {isa = PBXBuildFile; fileRef = A8F8BCEC2E0513D000EF4AA6 /* animated_photos.webp */; };
+		A8F8BCF92E054A1A00EF4AA6 /* animated_example.gif in Resources */ = {isa = PBXBuildFile; fileRef = A8F8BCF82E054A1A00EF4AA6 /* animated_example.gif */; };
 		A8FD8F332DFBCB85008CAACF /* ZillaSlab-Regular.ttf in Resources */ = {isa = PBXBuildFile; fileRef = A8FD8F322DFBCB85008CAACF /* ZillaSlab-Regular.ttf */; };
 		A8FD8F342DFBCB85008CAACF /* ZillaSlab-Medium.ttf in Resources */ = {isa = PBXBuildFile; fileRef = A8FD8F312DFBCB85008CAACF /* ZillaSlab-Medium.ttf */; };
 		A8FD8F352DFBCB85008CAACF /* ZillaSlab-BoldItalic.ttf in Resources */ = {isa = PBXBuildFile; fileRef = A8FD8F302DFBCB85008CAACF /* ZillaSlab-BoldItalic.ttf */; };
@@ -331,6 +332,7 @@
 		A8F8BCF52E0535E200EF4AA6 /* zh-Hant */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "zh-Hant"; path = "zh-Hant.lproj/LaunchScreen.strings"; sourceTree = "<group>"; };
 		A8F8BCF62E0535E200EF4AA6 /* zh-Hant */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "zh-Hant"; path = "zh-Hant.lproj/InfoPlist.strings"; sourceTree = "<group>"; };
 		A8F8BCF72E0535E200EF4AA6 /* zh-Hant */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "zh-Hant"; path = "zh-Hant.lproj/Localizable.strings"; sourceTree = "<group>"; };
+		A8F8BCF82E054A1A00EF4AA6 /* animated_example.gif */ = {isa = PBXFileReference; lastKnownFileType = image.gif; path = animated_example.gif; sourceTree = "<group>"; };
 		A8FD8F302DFBCB85008CAACF /* ZillaSlab-BoldItalic.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; path = "ZillaSlab-BoldItalic.ttf"; sourceTree = "<group>"; };
 		A8FD8F312DFBCB85008CAACF /* ZillaSlab-Medium.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; path = "ZillaSlab-Medium.ttf"; sourceTree = "<group>"; };
 		A8FD8F322DFBCB85008CAACF /* ZillaSlab-Regular.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; path = "ZillaSlab-Regular.ttf"; sourceTree = "<group>"; };
@@ -568,6 +570,7 @@
 			isa = PBXGroup;
 			children = (
 				A8F8BCEC2E0513D000EF4AA6 /* animated_photos.webp */,
+				A8F8BCF82E054A1A00EF4AA6 /* animated_example.gif */,
 				A86857D62DF983620089D222 /* generat_loading.gif */,
 				606372D62D545E55005C82CF /* Example */,
 				A81F5B502D19684D00740085 /* Json */,
@@ -1176,6 +1179,7 @@
 				A8C4C0A42D24218A003C46FC /* metadata.mov in Resources */,
 				A86857D72DF983620089D222 /* generat_loading.gif in Resources */,
 				A86857C62DF92BE70089D222 /* ZillaSlab-Bold.ttf in Resources */,
+				A8F8BCF92E054A1A00EF4AA6 /* animated_example.gif in Resources */,
 				A8FD8F472DFC3092008CAACF /* launch2.png in Resources */,
 				609B6EA52D6F1221007942D4 /* Localizable.strings in Resources */,
 				A8FD8F332DFBCB85008CAACF /* ZillaSlab-Regular.ttf in Resources */,

+ 4 - 4
TSLiveWallpaper/AppDelegate.swift

@@ -88,10 +88,10 @@ extension AppDelegate {
         KingfisherManager.shared.cache = cache
         
         
-        KingfisherManager.shared.defaultOptions += [
-            .processor(WebPProcessor.default),
-            .cacheSerializer(WebPSerializer.default),
-        ]
+//        KingfisherManager.shared.defaultOptions += [
+//            .processor(WebPProcessor.default),
+//            .cacheSerializer(WebPSerializer.default),
+//        ]
         checkAppConfig()
     }
     

+ 1 - 1
TSLiveWallpaper/Business/TSAIListVC/TSAIList+Enmu.swift

@@ -75,7 +75,7 @@ enum TSGeneratorImageStyle:String {
         case .recreate:
             return "Recreate Photo".localized
         case .creatVideo:
-            return "Animate Photo".localized
+            return "Animated Photo".localized
         }
     }
 }

+ 4 - 2
TSLiveWallpaper/Business/TSAIListVC/TSAIListVC/TSAIListVM.swift

@@ -58,7 +58,7 @@ class TSAIListVM {
         //视频照片
         let animatedItemModel = createItemModel(
             leftImageName:"aiList_Animated",
-            leftTitle: "Animated Photos".localized,
+            leftTitle: "Animated Photo".localized,
             leftSubTitle: "Turn photos into live moments".localized,
             rightViewStyle: 0,
             tapBlock: { [weak self] model, _, _ in
@@ -68,7 +68,9 @@ class TSAIListVM {
                     kPushVC(target: self.target, modelVC: baseVc)
                 }
             })
-        animatedItemModel.leftImagePath = "animated_photos.webp"
+        
+        animatedItemModel.leftImagePath = "animated_example.gif"
+//        animatedItemModel.leftImagePath = "animated_photos.webp"
         sectionModel.addSubItemModel(animatedItemModel)
 
         

+ 3 - 3
TSLiveWallpaper/Common/Purchase/TSPurchaseManager.swift

@@ -75,9 +75,9 @@ public class PurchaseManager: NSObject {
     }
 
     @objc public var isVip: Bool {
-//        #if DEBUG
-//        return true
-//        #endif
+        #if DEBUG
+        return true
+        #endif
         guard let expiresDate = expiredDate else {
             return false
         }

+ 26 - 8
TSLiveWallpaper/Data/OperationQueue/TSGenerateBaseOperation/TSGenerateBaseOperation.swift

@@ -82,7 +82,7 @@ class TSGenerateBaseOperation: TSBaseOperation , @unchecked Sendable{
     var stopNetwork = false
     var generatingProgress = 0
     var action_id:Int = 0
-    
+    var retryDownloadCount = 0
     public var isShowSuccessView:Bool = false //是否展示成功后的 View 提醒
     var isSaveProcessToDB:Bool = false //是否保存过程到数据库
     {
@@ -184,7 +184,13 @@ class TSGenerateBaseOperation: TSBaseOperation , @unchecked Sendable{
     }
     
     func downResultUrl(infoModel:TSActionInfoModel){
-
+        
+        if retryDownloadCount > 3 {
+            debugPrint("生成后下载视频失败,重新尝试超过 3 次,直接失败")
+            handleFailInfoModel(errorString: nil)
+            return
+        }
+   
         if generateStyleModel?.generatorStyle == .creatVideo {
             let group = DispatchGroup()
             //下载视频源
@@ -203,16 +209,28 @@ class TSGenerateBaseOperation: TSBaseOperation , @unchecked Sendable{
 
             group.notify(queue: .main){[weak self]  in
                 guard let self = self else { return }
-                handleSuccess(infoModel: infoModel)
+                if infoModel.response.videoDocument.isEmpty {
+                    debugPrint("生成后下载视频失败,重新尝试retryDownloadCount=\(retryDownloadCount)")
+                    downResultUrl(infoModel: infoModel)
+                }else{
+                    handleSuccess(infoModel: infoModel)
+                }
             }
 
         }else{
-            downloadImage(urlString: infoModel.response.resultUrl) { [weak self]  in
+            downloadImage(urlString: infoModel.response.resultUrl) { [weak self] image in
                 guard let self = self else { return }
-                handleSuccess(infoModel: infoModel)
+                if image == nil {
+                    debugPrint("生成后下载视频失败,重新尝试retryDownloadCount=\(retryDownloadCount)")
+                    downResultUrl(infoModel: infoModel)
+                }else{
+                    handleSuccess(infoModel: infoModel)
+                }
+                
             }
         }
-
+        
+        retryDownloadCount += 1
     }
     
     let generatingText:String = "Processing".localized
@@ -227,7 +245,7 @@ class TSGenerateBaseOperation: TSBaseOperation , @unchecked Sendable{
         }
     }
     
-    func downloadImage(urlString:String,completion:@escaping ()->Void){
+    func downloadImage(urlString:String,completion:@escaping (UIImage?)->Void){
         TSImageStoreTool.downloadImageWithProgress(urlString: urlString) { [weak self]  progress in
             guard let self = self else { return }
     
@@ -236,7 +254,7 @@ class TSGenerateBaseOperation: TSBaseOperation , @unchecked Sendable{
             stateDatauPblished = (.progressString(progressString),currentActionInfoModel)
             dePrint("生成后图片下载进度: \(progress)")
         } completion: { image in
-            completion()
+            completion(image)
         }
     }
     

BIN
TSLiveWallpaper/Resource/animated_example.gif