Просмотр исходного кода

给 TSUserDefaultData 精简优化

100Years 3 недель назад
Родитель
Сommit
0328b4a5c7

+ 142 - 209
AIRingtone/Business/Data/TSUserDefaultData.swift

@@ -7,7 +7,7 @@
 import ObjectMapper
 
 func kHandleTSHistory(){
-    for model in TSAIRintoneHistory.listModelArray {
+    for model in TSAIRintoneHistory.shared.listModels {
         if model.modelType != .example {
             switch model.actionStatus {
             case .pending,.running:
@@ -17,7 +17,7 @@ func kHandleTSHistory(){
         }
     }
     
-    for model in TSPosterHistory.listModelArray {
+    for model in TSPosterHistory.shared.listModels {
         if model.modelType != .example {
             switch model.actionStatus {
             case .pending,.running:
@@ -27,7 +27,7 @@ func kHandleTSHistory(){
         }
     }
     
-    for model in TSPhotoHistory.listModelArray {
+    for model in TSPhotoHistory.shared.listModels {
         if model.modelType != .example {
             switch model.actionStatus {
             case .pending,.running:
@@ -36,73 +36,130 @@ func kHandleTSHistory(){
             }
         }
     }
-    
-
 }
-//海报历史记录
-class TSPosterHistory{
-    @UserDefault(key: "kPosterTextPicHistoryListString", defaultValue: "")
-    static private var historyString: String
-    static var listModelArray: [TSActionInfoModel] = {
+
+// MARK: - 基础历史记录类
+class TSBaseHistoryManager<ModelType: TSBaseModel> {
+    // 子类必须重写的属性
+    var historyKey: String { fatalError("必须重写 historyKey") }
+    var exampleDataKey: String { fatalError("必须重写 exampleDataKey") }
+    var exampleModels: [ModelType] { fatalError("必须重写 exampleModels") }
+
+    func findModelID(modelID: Int)->Int?{
+        fatalError("必须重写 findModelID")
+    }
+
+    func saveModelAfterProcess(){
         
-        if UserDefaults.standard.string(forKey: "insertPosterExampleData") == nil {
-            insertExampleData()
-            UserDefaults.standard.set("1", forKey: "insertPosterExampleData")
-            UserDefaults.standard.synchronize()
+    }
+    
+    // 存储属性
+    private var _historyString: String {
+        get { UserDefaults.standard.string(forKey: historyKey) ?? "" }
+        set { UserDefaults.standard.set(newValue, forKey: historyKey) }
+    }
+    
+    private var _listModels: [ModelType]?
+    var listModels: [ModelType] {
+        get {
+            if _listModels == nil { loadModels() }
+            return _listModels ?? []
         }
-        
-        if let listModelArray = Mapper<TSActionInfoModel>().mapArray(JSONString: historyString){
-            return listModelArray
+        set {
+            _listModels = newValue
         }
-        return []
-    }()
+    }
     
-    static func saveModel(model:TSActionInfoModel){
-        self.listModelArray.insert(model, at: 0)
-        self.saveHistoryString()
+    // MARK: - 公共方法
+    func saveModel(model: ModelType, at index: Int = 0) {
+        listModels.insert(model, at: index)
+        saveHistory()
+        saveModelAfterProcess()
     }
     
-    static func removeModel(model:TSActionInfoModel){
-        self.listModelArray.removeAll { $0 === model }
-        self.saveHistoryString()
+    func removeModel(model:ModelType) {
+        self.listModels.removeAll { $0 === model }
+        saveHistory()
     }
     
+    func removeModel(index: Int) {
+        guard index >= 0 && index < listModels.count else { return }
+        listModels.remove(at: index)
+        saveHistory()
+    }
+
     
-    static func replaceModel(oldID: Int, newModel: TSActionInfoModel) {
-        if let index = self.listModelArray.firstIndex(where: {$0.id == oldID}) {
-            self.listModelArray[index] = newModel
-            dePrint("TSPosterHistory.listModelArray Model replaced at index \(index)")
+    func replaceModel(oldID: Int, newModel: ModelType){
+        if let index = findModelID(modelID: oldID) {
+            listModels[index] = newModel
+            dePrint("\(Self.self).listModels Model replaced at index \(index)")
         } else {
-            self.listModelArray.insert(newModel, at: 0)
-            dePrint("TSPosterHistory.listModel ArrayModel not found")
+            listModels.insert(newModel, at: 0)
+            dePrint("\(Self.self).listModels Model not found")
         }
-        dePrint("TSPosterHistory.listModelArray.count=\(TSAIRintoneHistory.listModelArray.count)")
-        self.saveHistoryString()
+        dePrint("\(Self.self).listModels.count=\(listModels.count)")
+        saveHistory()
     }
     
-    static func removeIndex(index:Int){
-        self.listModelArray.remove(at: index)
-        self.saveHistoryString()
+    func dePrintAllModel() {
+        dePrint("=======================结果查询开始======================")
+        dePrint("\(Self.self).listModels.count=\(listModels.count)")
+        for model in listModels {
+            dePrint(model.toJSON())
+        }
+        dePrint("=======================结果查询结束======================")
     }
     
-    static func saveHistoryString(){
-        if let jsonString = listModelArray.toJSONString() {
-            historyString = jsonString
+    // MARK: - 私有方法
+    private func saveHistory() {
+        if let jsonString = listModels.toJSONString() {
+            _historyString = jsonString
         }
     }
     
-    private static func insertExampleData(){
-        let array = [
-            self.createExampleModel(imageName: "poster_example_0"),
-            self.createExampleModel(imageName: "poster_example_1"),
-            self.createExampleModel(imageName: "poster_example_2")
-        ]
-        if let jsonString = array.toJSONString() {
-            self.historyString = jsonString
+    private func loadModels() {
+        if exampleModels.count > 0 {
+            // 第一次运行时插入示例数据
+            if UserDefaults.standard.string(forKey: exampleDataKey) == nil {
+                insertExampleData()
+                UserDefaults.standard.set("1", forKey: exampleDataKey)
+            }
         }
+
+        // 从历史记录加载模型
+        if let models = Mapper<ModelType>().mapArray(JSONString: _historyString) {
+            _listModels = models
+        } else {
+            _listModels = []
+        }
+    }
+    
+    private func insertExampleData() {
+        if let jsonString = exampleModels.toJSONString() {
+            _historyString = jsonString
+        }
+    }
+}
+
+// MARK: - 海报历史记录
+final class TSPosterHistory: TSBaseHistoryManager<TSActionInfoModel> {
+    static let shared = TSPosterHistory()
+    override var historyKey: String { "kPosterTextPicHistoryListString" }
+    override var exampleDataKey: String { "insertPosterExampleData" }
+    
+    override func findModelID(modelID: Int) -> Int? {
+        return listModels.firstIndex(where: {$0.id == modelID})
+    }
+    
+    override var exampleModels: [TSActionInfoModel] {
+        [
+            createExampleModel(imageName: "poster_example_0"),
+            createExampleModel(imageName: "poster_example_1"),
+            createExampleModel(imageName: "poster_example_2")
+        ]
     }
     
-    private static func createExampleModel(imageName:String)->TSActionInfoModel{
+    private func createExampleModel(imageName: String) -> TSActionInfoModel {
         let model = TSActionInfoModel()
         model.modelType = .example
         model.request.prompt = "Example"
@@ -113,68 +170,25 @@ class TSPosterHistory{
         return model
     }
 }
-
-//头像历史记录
-class TSPhotoHistory{
-    @UserDefault(key: "kPhotoTextPicHistoryListString", defaultValue: "")
-    static private var historyString: String
-    static var listModelArray: [TSActionInfoModel] = {
-        if UserDefaults.standard.string(forKey: "insertPhotoExampleData") == nil {
-            insertExampleData()
-            UserDefaults.standard.set("1", forKey: "insertPhotoExampleData")
-            UserDefaults.standard.synchronize()
-        }
-        if let listModelArray = Mapper<TSActionInfoModel>().mapArray(JSONString: historyString){
-            return listModelArray
-        }
-        return []
-    }()
-    
-    static func saveModel(model:TSActionInfoModel){
-        self.listModelArray.insert(model, at: 0)
-        self.saveHistoryString()
-    }
+// MARK: - 头像历史记录
+final class TSPhotoHistory: TSBaseHistoryManager<TSActionInfoModel> {
+    static let shared = TSPhotoHistory()
+    override var historyKey: String { "kPhotoTextPicHistoryListString" }
+    override var exampleDataKey: String { "insertPhotoExampleData" }
     
-    static func removeModel(model:TSActionInfoModel){
-        self.listModelArray.removeAll { $0 === model }
-        self.saveHistoryString()
+    override func findModelID(modelID: Int) -> Int? {
+        return listModels.firstIndex(where: {$0.id == modelID})
     }
     
-    static func removeIndex(index:Int){
-        self.listModelArray.remove(at: index)
-        self.saveHistoryString()
-    }
-    
-    static func replaceModel(oldID: Int, newModel: TSActionInfoModel) {
-        if let index = self.listModelArray.firstIndex(where: {$0.id == oldID}) {
-            self.listModelArray[index] = newModel
-            dePrint("TSPhotoHistory.listModelArray Model replaced at index \(index)")
-        } else {
-            self.listModelArray.insert(newModel, at: 0)
-            dePrint("TSPhotoHistory.listModel ArrayModel not found")
-        }
-        dePrint("TSPhotoHistory.listModelArray.count=\(TSAIRintoneHistory.listModelArray.count)")
-        self.saveHistoryString()
-    }
-    
-    static func saveHistoryString(){
-        if let jsonString = listModelArray.toJSONString() {
-            self.historyString = jsonString
-        }
-    }
-    
-    private static func insertExampleData(){
-        let array = [
-            self.createExampleModel(imageName: "photo_example_0"),
-            self.createExampleModel(imageName: "photo_example_1"),
-            self.createExampleModel(imageName: "photo_example_2")
+    override var exampleModels: [TSActionInfoModel] {
+        [
+            createExampleModel(imageName: "photo_example_0"),
+            createExampleModel(imageName: "photo_example_1"),
+            createExampleModel(imageName: "photo_example_2")
         ]
-        if let jsonString = array.toJSONString() {
-            self.historyString = jsonString
-        }
     }
     
-    private static func createExampleModel(imageName:String)->TSActionInfoModel{
+    private func createExampleModel(imageName: String) -> TSActionInfoModel {
         let model = TSActionInfoModel()
         model.modelType = .example
         model.request.prompt = "Example"
@@ -185,83 +199,23 @@ class TSPhotoHistory{
         return model
     }
 }
-
-//AI铃声历史记录
-class TSAIRintoneHistory{
-    @UserDefault(key: "kRintoneTextMusicHistoryListString", defaultValue: "")
-    static private var historyString: String
-    static var listModelArray: [TSActionInfoModel] = {
-        
-        if UserDefaults.standard.string(forKey: "insertRintoneExampleData") == nil {
-            insertExampleData()
-            UserDefaults.standard.set("1", forKey: "insertRintoneExampleData")
-            UserDefaults.standard.synchronize()
-        }
-        
-        if let listModelArray = Mapper<TSActionInfoModel>().mapArray(JSONString: historyString){
-            return listModelArray
-        }
-        return []
-    }()
-    
-    static func saveModel(model:TSActionInfoModel){
-        //若存在,则不更新替换
-        if let index = self.listModelArray.firstIndex(where: { $0.id == model.id }) {
-            self.listModelArray[index] = model
-        }else{
-            self.listModelArray.insert(model, at: 0)
-        }
-        self.saveHistoryString()
-    }
-    
-    static func removeModel(model:TSActionInfoModel){
-        self.listModelArray.removeAll { $0.id == model.id }
-        self.saveHistoryString()
-    }
-    
-    static func replaceModel(oldID: Int, newModel: TSActionInfoModel) {
-        if let index = self.listModelArray.firstIndex(where: {$0.id == oldID}) {
-            self.listModelArray[index] = newModel
-            dePrint("TSAIRintoneHistory.listModelArray Model replaced at index \(index)")
-        } else {
-            self.listModelArray.insert(newModel, at: 0)
-            dePrint("TSAIRintoneHistory.listModel ArrayModel not found")
-        }
-        dePrint("TSAIRintoneHistory.listModelArray.count=\(TSAIRintoneHistory.listModelArray.count)")
-        self.saveHistoryString()
-    }
-    
-    static func removeIndex(index:Int){
-        self.listModelArray.remove(at: index)
-        self.saveHistoryString()
-    }
+// MARK: - AI铃声历史记录
+final class TSAIRintoneHistory: TSBaseHistoryManager<TSActionInfoModel> {
+    static let shared = TSAIRintoneHistory()
+    override var historyKey: String { "kRintoneTextMusicHistoryListString" }
+    override var exampleDataKey: String { "insertRintoneExampleData" }
     
-    static func saveHistoryString(){
-        if let jsonString = listModelArray.toJSONString() {
-            self.historyString = jsonString
-        }
+    override func findModelID(modelID: Int) -> Int? {
+        return listModels.firstIndex(where: {$0.id == modelID})
     }
     
-    
-    static func dePrintAllModel(){
-        dePrint("=======================结果查询开始======================")
-        dePrint("TSAIRintoneHistory.listModelArray.count=\(TSAIRintoneHistory.listModelArray.count)")
-        for model in TSAIRintoneHistory.listModelArray {
-            dePrint(model.toJSON())
-        }
-        dePrint("=======================结果查询结束======================")
-    }
-
-    private static func insertExampleData(){
-        let array = [
-            self.createExampleModel(),
+    override var exampleModels: [TSActionInfoModel] {
+        [
+            createExampleModel()
         ]
-        if let jsonString = array.toJSONString() {
-            historyString = jsonString
-        }
     }
     
-    private static func createExampleModel()->TSActionInfoModel{
+    private  func createExampleModel()->TSActionInfoModel{
         let model = TSActionInfoModel()
         model.modelType = .example
         model.request.duration = 30
@@ -273,45 +227,24 @@ class TSAIRintoneHistory{
         return model
     }
 }
-
-
-//我的下载铃声历史记录
-class TSMineRintoneHistory{
-    @UserDefault(key: "kMineRintoneHistoryListString", defaultValue: "")
-    static private var historyString: String
-    static var listModelArray: [TSRingModel] = {
-
-        if let listModelArray = Mapper<TSRingModel>().mapArray(JSONString: historyString){
-            return listModelArray
-        }
-        return []
-    }()
+// MARK: - 我的下载铃声历史记录
+final class TSMineRintoneHistory: TSBaseHistoryManager<TSRingModel> {
+    static let shared = TSMineRintoneHistory()
+    override var historyKey: String { "kMineRintoneHistoryListString" }
+    override var exampleDataKey: String { "insertMineRintoneExampleData" }
     
-    static func saveModel(model:TSRingModel){
-        if let _ = self.listModelArray.first(where: { $0.audioUrl == model.audioUrl }) {
-            return
-        }
-        self.listModelArray.insert(model, at: 0)
-        self.saveHistoryString()
-        isHaveNew = true
-    }
+    var isHaveNew:Bool = false
     
-    static func removeModel(model:TSRingModel){
-        listModelArray.removeAll { $0 === model }
-        self.saveHistoryString()
+    override func findModelID(modelID: Int) -> Int? {
+        return nil
     }
     
-    static func removeIndex(index:Int){
-        listModelArray.remove(at: index)
-        self.saveHistoryString()
+    override var exampleModels: [TSRingModel] {
+        []
     }
     
-    static func saveHistoryString(){
-        if let jsonString = listModelArray.toJSONString() {
-            historyString = jsonString
-        }
+    override func saveModelAfterProcess() {
+        isHaveNew = true
     }
-    
-    
-    static var isHaveNew:Bool = false
 }
+

+ 2 - 2
AIRingtone/Business/TSAIPhotoVC/TSAIPhotoChildVC/TSAIPhotoChildVM.swift

@@ -37,9 +37,9 @@ class TSAIPhotoChildVM {
     
     var dataList:[TSActionInfoModel]{
         if style == .photo {
-            return TSPhotoHistory.listModelArray
+            return TSPhotoHistory.shared.listModels
         }else{
-            return TSPosterHistory.listModelArray
+            return TSPosterHistory.shared.listModels
         }
         
     }

+ 2 - 2
AIRingtone/Business/TSAIRintoneVC/TSAIRintoneVC/TSAIRintoneVC.swift

@@ -128,7 +128,7 @@ class TSAIRintoneVC: TSBaseVC {
             }
         }
         
-        TSAIRintoneHistory.dePrintAllModel()
+        TSAIRintoneHistory.shared.dePrintAllModel()
     }
     
     func updateListView(){
@@ -190,7 +190,7 @@ extension TSAIRintoneVC: UICollectionViewDataSource ,UICollectionViewDelegate,UI
             }else if let ringModel = model as? TSRingModel {
                 _ = kPurchaseToolShared.kshareBand(needVip: ringModel.vip, vc: self, urlString: ringModel.audioUrl, fileName: ringModel.title){ success in
                     if success {
-                        TSMineRintoneHistory.saveModel(model: ringModel)
+                        TSMineRintoneHistory.shared.saveModel(model: ringModel)
                     }
                 }
             }

+ 3 - 3
AIRingtone/Business/TSAIRintoneVC/TSAIRintoneVC/ViewModel/TSAIRintoneVM.swift

@@ -44,7 +44,7 @@ class TSAIRintoneVM {
     
     //生成的历史
     lazy var aiRintoneHistoryModel: TSAIRintoneHistoryModel = {
-        let model = TSAIRintoneHistoryModel(title: "Generate History", list:Array(TSAIRintoneHistory.listModelArray.prefix(2)),type: .history)
+        let model = TSAIRintoneHistoryModel(title: "Generate History", list:Array(TSAIRintoneHistory.shared.listModels.prefix(2)),type: .history)
         return model
     }()
     
@@ -61,12 +61,12 @@ class TSAIRintoneVM {
 extension TSAIRintoneVM {
     
     func updateRecentData() {
-        aiRintoneHistoryModel.list = Array(TSAIRintoneHistory.listModelArray.prefix(2))
+        aiRintoneHistoryModel.list = Array(TSAIRintoneHistory.shared.listModels.prefix(2))
         modelList = getModelList()
     }
     
     func removeModel(model:TSActionInfoModel){
-        TSAIRintoneHistory.removeModel(model: model)
+        TSAIRintoneHistory.shared.removeModel(model: model)
         updateRecentData()
     }
     

+ 1 - 1
AIRingtone/Business/TSAIRintoneVC/TSGenerateHistoryVC/TSGenerateHistoryVC.swift

@@ -140,7 +140,7 @@ extension TSGenerateHistoryVC: UICollectionViewDataSource ,UICollectionViewDeleg
                 _ = kPurchaseToolShared.kshareBand(needVip: ringModel.vip, vc: self, urlString: ringModel.audioUrl, fileName: ringModel.title)
 //                { success in
 //                    if success {
-//                        TSMineRintoneHistory.saveModel(model: ringModel)
+//                        TSMineRintoneHistory.shared.saveModel(model: ringModel)
 //                    }
 //                }
             }

+ 3 - 3
AIRingtone/Business/TSAIRintoneVC/TSGenerateHistoryVC/TSGenerateHistoryVM.swift

@@ -24,7 +24,7 @@ class TSGenerateHistoryVM {
     
     //生成的历史
     lazy var aiRintoneHistoryModel: TSAIRintoneHistoryModel = {
-        let model = TSAIRintoneHistoryModel(title: "Generate History", list:TSAIRintoneHistory.listModelArray)
+        let model = TSAIRintoneHistoryModel(title: "Generate History", list:TSAIRintoneHistory.shared.listModels)
         return model
     }()
 
@@ -34,12 +34,12 @@ class TSGenerateHistoryVM {
 extension TSGenerateHistoryVM {
     
     func updateRecentData() {
-        aiRintoneHistoryModel.list = TSAIRintoneHistory.listModelArray
+        aiRintoneHistoryModel.list = TSAIRintoneHistory.shared.listModels
         modelList = getModelList()
     }
     
     func removeModel(model:TSActionInfoModel){
-        TSAIRintoneHistory.removeModel(model: model)
+        TSAIRintoneHistory.shared.removeModel(model: model)
         updateRecentData()
     }
     

+ 1 - 1
AIRingtone/Business/TSDiscoverVC/TSDiscoverListVC/TSDiscoverListVC.swift

@@ -158,7 +158,7 @@ extension TSDiscoverListVC: UICollectionViewDataSource ,UICollectionViewDelegate
             if let ringModel = itemModel as? TSRingModel {
                 _ = kPurchaseToolShared.kshareBand(needVip: ringModel.vip, vc: self, urlString: ringModel.audioUrl, fileName: ringModel.title){ success in
                     if success {
-                        TSMineRintoneHistory.saveModel(model: ringModel)
+                        TSMineRintoneHistory.shared.saveModel(model: ringModel)
                     }
                 }
             }

+ 1 - 1
AIRingtone/Business/TSDiscoverVC/TSDiscoverVC/TSDiscoverVC.swift

@@ -117,6 +117,6 @@ class TSDiscoverVC: TSBaseVC {
     override func viewWillAppear(_ animated: Bool) {
         super.viewWillAppear(animated)
         
-        redDot.isHidden = !TSMineRintoneHistory.isHaveNew
+        redDot.isHidden = !TSMineRintoneHistory.shared.isHaveNew
     }
 }

+ 2 - 2
AIRingtone/Business/TSDiscoverVC/TSRingDownVC/TSRingDownVC.swift

@@ -79,7 +79,7 @@ class TSRingDownVC: TSBaseVC {
     
     override func viewWillAppear(_ animated: Bool) {
         super.viewWillAppear(animated)
-        TSMineRintoneHistory.isHaveNew = false
+        TSMineRintoneHistory.shared.isHaveNew = false
     }
     
     override func viewWillDisappear(_ animated: Bool) {
@@ -149,7 +149,7 @@ extension TSRingDownVC: UICollectionViewDataSource ,UICollectionViewDelegate,UIC
                 _ = kPurchaseToolShared.kshareBand(needVip: ringModel.vip, vc: self, urlString: ringModel.audioUrl, fileName: ringModel.title)
 //                { success in
 //                    if success {
-//                        TSMineRintoneHistory.saveModel(model: ringModel)
+//                        TSMineRintoneHistory.shared.saveModel(model: ringModel)
 //                    }
 //                }
             }

+ 3 - 3
AIRingtone/Business/TSDiscoverVC/TSRingDownVC/VM/TSRingDownVM.swift

@@ -24,7 +24,7 @@ class TSRingDownVM {
     
     //保存的历史
     lazy var aiRintoneHistoryModel: TSAIRintoneHistoryModel = {
-        let model = TSAIRintoneHistoryModel(title: "Generate History", list:TSMineRintoneHistory.listModelArray)
+        let model = TSAIRintoneHistoryModel(title: "Generate History", list:TSMineRintoneHistory.shared.listModels)
         return model
     }()
     
@@ -33,12 +33,12 @@ class TSRingDownVM {
 extension TSRingDownVM {
     
     func updateRecentData() {
-        aiRintoneHistoryModel.list = TSMineRintoneHistory.listModelArray
+        aiRintoneHistoryModel.list = TSMineRintoneHistory.shared.listModels
         modelList = getModelList()
     }
     
     func removeModel(model:TSRingModel){
-        TSMineRintoneHistory.removeModel(model: model)
+        TSMineRintoneHistory.shared.removeModel(model: model)
         updateRecentData()
         
         if let pathURL = TSCommonTool.getCachedURLString(from: model.audioUrl) {

+ 3 - 3
AIRingtone/Common/Tool/OperationQueue/TSGenerateBaseOperation/TSGeneratePhotoOperation.swift

@@ -44,9 +44,9 @@ class TSGeneratePhotoOperation: TSGenerateBaseOperation , @unchecked Sendable{
 
     override func replaceSaveInfoModel(model:TSActionInfoModel){
         model.uuid = uuid
-        TSPhotoHistory.replaceModel(oldID: currentActionInfoModel.id, newModel: model)
+        TSPhotoHistory.shared.replaceModel(oldID: currentActionInfoModel.id, newModel: model)
         currentActionInfoModel = model
-        dePrint("TSPhotoHistory.listModelArray.count=\(TSPhotoHistory.listModelArray.count)")
+        dePrint("TSPhotoHistory.shared.listModels.count=\(TSPhotoHistory.shared.listModels.count)")
         dePrint("model actionStatus 发出=\(model.actionStatus)")
         currentActionInfoModelChanged?(currentActionInfoModel)
     }
@@ -93,7 +93,7 @@ class TSGeneratePhotoOperation: TSGenerateBaseOperation , @unchecked Sendable{
 //                self.replaceSaveInfoModel(model: self.currentActionInfoModel)
 //                self.stateDatauPblished = (.failed("error?.localizedDescription"),nil)
 //            }
-////            TSPhotoHistory.dePrintAllModel()
+////            TSPhotoHistory.shared.dePrintAllModel()
 //        }
 //    }
     

+ 3 - 3
AIRingtone/Common/Tool/OperationQueue/TSGenerateBaseOperation/TSGeneratePosterOperation.swift

@@ -45,9 +45,9 @@ class TSGeneratePosterOperation: TSGenerateBaseOperation , @unchecked Sendable{
 
     override func replaceSaveInfoModel(model:TSActionInfoModel){
         model.uuid = uuid
-        TSPosterHistory.replaceModel(oldID: currentActionInfoModel.id, newModel: model)
+        TSPosterHistory.shared.replaceModel(oldID: currentActionInfoModel.id, newModel: model)
         currentActionInfoModel = model
-        dePrint("TSPosterHistory.listModelArray.count=\(TSPosterHistory.listModelArray.count)")
+        dePrint("TSPosterHistory.shared.listModels.count=\(TSPosterHistory.shared.listModels.count)")
         dePrint("model actionStatus 发出=\(model.actionStatus)")
         currentActionInfoModelChanged?(currentActionInfoModel)
     }
@@ -94,7 +94,7 @@ class TSGeneratePosterOperation: TSGenerateBaseOperation , @unchecked Sendable{
 //                self.replaceSaveInfoModel(model: self.currentActionInfoModel)
 //                self.stateDatauPblished = (.failed("error?.localizedDescription"),nil)
 //            }
-////            TSPosterHistory.dePrintAllModel()
+////            TSPosterHistory.shared.dePrintAllModel()
 //        }
 //    }
     

+ 3 - 3
AIRingtone/Common/Tool/OperationQueue/TSGenerateBaseOperation/TSGenerateRintoneOperation.swift

@@ -46,9 +46,9 @@ class TSGenerateRintoneOperation: TSGenerateBaseOperation , @unchecked Sendable{
     
     override func replaceSaveInfoModel(model:TSActionInfoModel){
         model.uuid = uuid
-        TSAIRintoneHistory.replaceModel(oldID: currentActionInfoModel.id, newModel: model)
+        TSAIRintoneHistory.shared.replaceModel(oldID: currentActionInfoModel.id, newModel: model)
         currentActionInfoModel = model
-        dePrint("TSAIRintoneHistory.listModelArray.count=\(TSAIRintoneHistory.listModelArray.count)")
+        dePrint("TSAIRintoneHistory.shared.listModels.count=\(TSAIRintoneHistory.shared.listModels.count)")
         dePrint("model actionStatus 发出=\(model.actionStatus)")
         currentActionInfoModelChanged?(currentActionInfoModel)
     }
@@ -86,7 +86,7 @@ class TSGenerateRintoneOperation: TSGenerateBaseOperation , @unchecked Sendable{
 //                self.replaceSaveInfoModel(model: self.currentActionInfoModel)
 //                self.stateDatauPblished = (.failed("error?.localizedDescription"),nil)
 //            }
-//            TSAIRintoneHistory.dePrintAllModel()
+//            TSAIRintoneHistory.shared.dePrintAllModel()
 //        }
 //    }