浏览代码

后台生成过程中杀死app,再次进度app 后,向后台查询最新数据

100Years 3 周之前
父节点
当前提交
fe7ac7cbf5

+ 1 - 0
AIRingtone/AppDelegate.swift

@@ -57,6 +57,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
     func initPlatform() {
         TSColorConfigShared.naviMianTextColor = .white
         checkAppConfig()
+        kHandleTSHistory()
     }
 
 }

+ 35 - 18
AIRingtone/Business/Data/TSUserDefaultData.swift

@@ -6,7 +6,39 @@
 //
 import ObjectMapper
 
+func kHandleTSHistory(){
+    for model in TSAIRintoneHistory.listModelArray {
+        if model.modelType != .example {
+            switch model.actionStatus {
+            case .pending,.running:
+                TSGenerateRintoneOperationQueue.shared.creatOperation(uuid: model.uuid).getActionInfo(oldModel: model)
+            default:break
+            }
+        }
+    }
+    
+    for model in TSPosterHistory.listModelArray {
+        if model.modelType != .example {
+            switch model.actionStatus {
+            case .pending,.running:
+                TSGeneratePosterOperationQueue.shared.creatOperation(uuid: model.uuid).getActionInfo(oldModel: model)
+            default:break
+            }
+        }
+    }
+    
+    for model in TSPhotoHistory.listModelArray {
+        if model.modelType != .example {
+            switch model.actionStatus {
+            case .pending,.running:
+                TSGeneratePhotoOperationQueue.shared.creatOperation(uuid: model.uuid).getActionInfo(oldModel: model)
+            default:break
+            }
+        }
+    }
+    
 
+}
 //海报历史记录
 class TSPosterHistory{
     @UserDefault(key: "kPosterTextPicHistoryListString", defaultValue: "")
@@ -45,12 +77,7 @@ class TSPosterHistory{
             dePrint("TSPosterHistory.listModel ArrayModel not found")
         }
         dePrint("TSPosterHistory.listModelArray.count=\(TSAIRintoneHistory.listModelArray.count)")
-        
-        if newModel.status == "success" ||
-            newModel.status == "failed" {
-            self.saveHistoryString()
-        }
-   
+        self.saveHistoryString()
     }
     
     static func removeIndex(index:Int){
@@ -127,12 +154,7 @@ class TSPhotoHistory{
             dePrint("TSPhotoHistory.listModel ArrayModel not found")
         }
         dePrint("TSPhotoHistory.listModelArray.count=\(TSAIRintoneHistory.listModelArray.count)")
-        
-        if newModel.status == "success" ||
-            newModel.status == "failed" {
-            self.saveHistoryString()
-        }
-   
+        self.saveHistoryString()
     }
     
     static func saveHistoryString(){
@@ -206,12 +228,7 @@ class TSAIRintoneHistory{
             dePrint("TSAIRintoneHistory.listModel ArrayModel not found")
         }
         dePrint("TSAIRintoneHistory.listModelArray.count=\(TSAIRintoneHistory.listModelArray.count)")
-        
-        if newModel.status == "success" ||
-            newModel.status == "failed" {
-            self.saveHistoryString()
-        }
-   
+        self.saveHistoryString()
     }
     
     static func removeIndex(index:Int){

+ 5 - 0
AIRingtone/Common/Tool/OperationQueue/TSGenerateBaseOperation/TSGenerateBaseOperation.swift

@@ -96,6 +96,11 @@ class TSGenerateBaseOperation: TSBaseOperation , @unchecked Sendable{
         self.stateDatauPblished = (.failed(errorString ?? ""),nil)
     }
     
+    func getActionInfo(oldModel:TSActionInfoModel) {
+        currentActionInfoModel = oldModel
+        self.getActionInfo(action_id:oldModel.id)
+    }
+
     func getActionInfo(action_id:Int){
         self.action_id = action_id
         queryRequest = TSNetworkShared.get(urlType: .actionInfo,parameters: ["action_id":action_id]) { [weak self] data,error in