Przeglądaj źródła

修改 15(2)bug

100Years 3 tygodni temu
rodzic
commit
dec44f48ea

+ 2 - 2
AIRingtone.xcodeproj/project.pbxproj

@@ -1325,7 +1325,7 @@
 				ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
 				CLANG_ENABLE_MODULES = YES;
 				CODE_SIGN_STYLE = Automatic;
-				CURRENT_PROJECT_VERSION = 2;
+				CURRENT_PROJECT_VERSION = 3;
 				DEVELOPMENT_TEAM = 65UD255J84;
 				GENERATE_INFOPLIST_FILE = YES;
 				INFOPLIST_FILE = AIRingtone/Info.plist;
@@ -1367,7 +1367,7 @@
 				ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
 				CLANG_ENABLE_MODULES = YES;
 				CODE_SIGN_STYLE = Automatic;
-				CURRENT_PROJECT_VERSION = 2;
+				CURRENT_PROJECT_VERSION = 3;
 				DEVELOPMENT_TEAM = 65UD255J84;
 				GENERATE_INFOPLIST_FILE = YES;
 				INFOPLIST_FILE = AIRingtone/Info.plist;

+ 5 - 1
AIRingtone/Business/TSAIPhotoVC/TSGeneralPicVC/TSGeneralPicVC+Event.swift

@@ -63,6 +63,10 @@ extension TSGeneralPicVC {
         }
         return .posetr
     }
+    
+    var gennerateDefaultString:String {
+        return gennerateType == .poster ? "Working on your contact poster...".localized : "Working on your contact photo...".localized
+    }
 }
 extension TSGeneralPicVC {
     
@@ -104,7 +108,7 @@ extension TSGeneralPicVC {
     
     func showLoading(){
         generateInView.isHidden = false
-        generateInView.showLoading(text: "Generating...".localized)
+        generateInView.showLoading(text: gennerateDefaultString)
         generateInView.isRotating = true
         
         bottomView.isHidden = true

+ 2 - 5
AIRingtone/Business/TSAIPhotoVC/TSGeneralPicVC/TSGeneralPicVC.swift

@@ -46,6 +46,8 @@ class TSGeneralPicVC: TSBottomAlertVC {
     //############################## 生成动画 ##############################
     lazy var generateInView : TSCommonloadingView = {
         let generateInView = TSCommonloadingView()
+        generateInView.textLabel.text = gennerateDefaultString
+        
 //        generateInView.timeLabel.text = "~ 1min"
         //generateInView.cancelBtn.addTarget(self, action: #selector(closePage), for: .touchUpInside)
         generateInView.backstageBtn.addTarget(self, action: #selector(clickBackstageBtn), for: .touchUpInside)
@@ -122,11 +124,6 @@ class TSGeneralPicVC: TSBottomAlertVC {
     override func dealThings() {
         //判断 vip
         if kPurchaseToolShared.kJudgeVipFreeType(vipFreeNumType: vipFreeNumType, vc: self){ return }
-//        viewModel.creatImageEmoji(text: self.aiText)
-//        viewModel.$stateDatauPblished.receive(on: DispatchQueue.main).sink {[weak self]  (state,model) in
-//            guard let self = self else { return }
-//            self.upDateView(state: state, model: model)
-//        }.store(in: &cancellable)
         creatImage()
     }
     

+ 1 - 1
AIRingtone/Business/TSAIPhotoVC/TSTextGeneralPicVC/TSTextGeneralPicVC.swift

@@ -51,7 +51,7 @@ class TSTextGeneralPicVC: TSBaseVC {
         let photoStyleView = TSTGPPhotoStyleView()
         photoStyleView.selectedValueBlock = { [weak self] index in
             guard let self = self else { return }
-            creatBtnView.vipFreeNumType = vipFreeNumType
+            creatBtnView.vipFreeNumType =  index == 0 ? .posetr : .photo
             selectedIndex?(index)
             viewModel.gennerateType = TSGennerateType(rawValue: index) ?? .poster
         }

+ 0 - 3
AIRingtone/Business/TSAIRintoneVC/TSAIRintoneVC/TSAIRintoneVC.swift

@@ -123,9 +123,6 @@ class TSAIRintoneVC: TSBaseVC {
                 case .start, .success(_),.failed(_),.none:
                     self.viewModel.updateRecentData()
                     self.updateGeneratedHistory()
-//                case .start, .success(_),.failed(_):
-//                    self.viewModel.updateRecentData()
-//                    self.updateGeneratedHistory()
                 default:break
                 }
             }

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

@@ -51,7 +51,7 @@ class TSAIRintoneVM {
 
     //每日推荐的歌曲
     lazy var recommendRingtonesModel: TSAIRintoneHistoryModel = {
-        let model = TSAIRintoneHistoryModel(title: "🔥 Recommend Ringtones", list:[],type: .recommend)
+        let model = TSAIRintoneHistoryModel(title: "🔥 Hot Ringtones", list:[],type: .recommend)
         return model
     }()
 

+ 1 - 1
AIRingtone/Business/TSAIRintoneVC/TSGeneralRintoneVC/TSGeneralRintoneVC+Event.swift

@@ -51,7 +51,7 @@ extension TSGeneralRintoneVC {
     
     func showLoading(){
         generateInView.isHidden = false
-        generateInView.showLoading(text: "Generating...".localized)
+        generateInView.showLoading(text: "Working on your ringtone...".localized)
         generateInView.isRotating = true
         
         bottomView.isHidden = true

+ 1 - 0
AIRingtone/Business/TSAIRintoneVC/TSGeneralRintoneVC/TSGeneralRintoneVC.swift

@@ -44,6 +44,7 @@ class TSGeneralRintoneVC: TSBottomAlertVC {
     //############################## 生成动画 ##############################
     lazy var generateInView : TSCommonloadingView = {
         let generateInView = TSCommonloadingView()
+        generateInView.textLabel.text = "Working on your ringtone...".localized
 //        generateInView.timeLabel.text = "~ 4min"
 //        generateInView.cancelBtn.addTarget(self, action: #selector(closePage), for: .touchUpInside)
         generateInView.backstageBtn.addTarget(self, action: #selector(clickBackstageBtn), for: .touchUpInside)

+ 0 - 1
AIRingtone/Business/TSAIRintoneVC/TSTextGeneralRintoneVC/TSTextGeneralRintoneVC.swift

@@ -101,7 +101,6 @@ class TSTextGeneralRintoneVC: TSBaseVC {
     }
 
     override func dealThings() {
-        let maxCount = TSGenerateRintoneOperationQueue.shared.queue.maxConcurrentOperationCount
         NotificationCenter.default.addObserver(forName: .kBaseOperationQueueCountChanged, object: nil, queue: nil) { [weak self] notification in
             guard let self = self else { return }
             setCreatBtnEnabled()

+ 1 - 1
AIRingtone/Business/VIewTool/TSCommonloadingView.swift

@@ -77,7 +77,7 @@ class TSCommonloadingView: TSBaseView {
         contentView.addSubview(timeLabel)
         timeLabel.snp.makeConstraints { make in
             make.height.equalTo(18.0)
-            make.top.equalTo(imageView.snp.bottom).offset(-8)
+            make.top.equalTo(imageView.snp.bottom).offset(-12)
             make.leading.trailing.equalToSuperview()
         }
         

+ 31 - 2
AIRingtone/Common/Tool/OperationQueue/TSGenerateBaseOperation/TSGenerateBaseOperation.swift

@@ -71,12 +71,38 @@ class TSGenerateBaseOperation: TSBaseOperation , @unchecked Sendable{
     var currentActionInfoModelChanged:((TSActionInfoModel)->Void)?
     @Published var currentActionInfoModel: TSActionInfoModel = TSActionInfoModel()
     
+
+    func initializeFirstCurrentActionInfoModel(oldModel:TSActionInfoModel? = nil,prompt:String,promptSort:String) {
+        if let model = oldModel {
+            currentActionInfoModel = model
+        }else {
+            currentActionInfoModel.id = Int.timestampInt()
+            currentActionInfoModel.request.prompt = prompt
+            currentActionInfoModel.request.promptSort = promptSort
+            currentActionInfoModel.actionStatus = .pending
+            currentActionInfoModel.status = "pending"
+        }
+        replaceSaveInfoModel(model: currentActionInfoModel)
+        stateDatauPblished = (.start,currentActionInfoModel)
+//        stateDatauPblished = (.progressString(generating(progress: 0.0)),nil)
+    }
+    
+    func replaceSaveInfoModel(model:TSActionInfoModel){ }
+
+    func handleFailInfoModel(errorString:String?){
+        self.currentActionInfoModel.actionStatus = .failed
+        self.currentActionInfoModel.status = "failed"
+        self.replaceSaveInfoModel(model: self.currentActionInfoModel)
+        self.stateDatauPblished = (.failed(errorString ?? ""),nil)
+    }
+    
     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
             guard let self = self else { return }
             if let result = kNetWorkResultSuccess(data: data) {
                 if let genmojiModel = TSActionInfoModel(JSON: result) {
+                    self.replaceSaveInfoModel(model: genmojiModel)
                     switch genmojiModel.actionStatus {
                     case .success:
                         TSToastShared.hideLoading()
@@ -93,10 +119,13 @@ class TSGenerateBaseOperation: TSBaseOperation , @unchecked Sendable{
                             }
                         }
                     }
+                    
+                    return
                 }
-            }else{
-                self.stateDatauPblished = (.failed(error?.localizedDescription ?? ""),nil)
             }
+ 
+            handleFailInfoModel(errorString: error?.localizedDescription)
+            
         }
     }
      func generating(progress:Float) -> String {

+ 64 - 63
AIRingtone/Common/Tool/OperationQueue/TSGenerateBaseOperation/TSGeneratePhotoOperation.swift

@@ -42,7 +42,7 @@ class TSGeneratePhotoOperation: TSGenerateBaseOperation , @unchecked Sendable{
 
     var gennerateType:TSGennerateType = .photo
 
-    func replaceSaveInfoModel(model:TSActionInfoModel){
+    override func replaceSaveInfoModel(model:TSActionInfoModel){
         model.uuid = uuid
         TSPhotoHistory.replaceModel(oldID: currentActionInfoModel.id, newModel: model)
         currentActionInfoModel = model
@@ -51,75 +51,76 @@ class TSGeneratePhotoOperation: TSGenerateBaseOperation , @unchecked Sendable{
         currentActionInfoModelChanged?(currentActionInfoModel)
     }
     
-    //模拟数据
+//    //模拟数据
+//    func creatPhoto(oldModel:TSActionInfoModel? = nil,prompt:String,promptSort:String) {
+//        if let model = oldModel {
+//            currentActionInfoModel = model
+//        }else {
+//            currentActionInfoModel.id = Int.timestampInt()
+//            currentActionInfoModel.request.prompt = prompt
+//            currentActionInfoModel.request.promptSort = promptSort
+//            currentActionInfoModel.actionStatus = .pending
+//            currentActionInfoModel.status = "pending"
+//        }
+//        
+//        replaceSaveInfoModel(model: currentActionInfoModel)
+//        stateDatauPblished = (.start,currentActionInfoModel)
+//        let time = 5.0
+//        
+//        for i in 0..<Int(time){
+//            kDelayOnMainThread(Double(i)) {
+//                let progress = Float(i)*10/100.0
+//                self.currentActionInfoModel.percent = progress
+//                self.currentActionInfoModel.actionStatus = .running
+//                self.currentActionInfoModel.status = "running"
+//                self.replaceSaveInfoModel(model: self.currentActionInfoModel)
+//                self.stateDatauPblished = (.progressString(self.generating(progress: progress)),nil)
+//            }
+//        }
+//
+//        kDelayOnMainThread(time+1.0) {
+//            if kRandomBool(), let infoModel = TSActionInfoModel(JSON: self.actionInfoDict){
+//                infoModel.id = Int.uuid
+//                self.replaceSaveInfoModel(model: infoModel)
+//                self.stateDatauPblished = (.success(nil),self.currentActionInfoModel)
+//            }else{
+//                self.currentActionInfoModel.actionStatus = .failed
+//                self.currentActionInfoModel.status = "failed"
+//                self.replaceSaveInfoModel(model: self.currentActionInfoModel)
+//                self.stateDatauPblished = (.failed("error?.localizedDescription"),nil)
+//            }
+////            TSPhotoHistory.dePrintAllModel()
+//        }
+//    }
+    
+
+    
+    //width 和 height 必须是 32 的倍数
     func creatPhoto(oldModel:TSActionInfoModel? = nil,prompt:String,promptSort:String) {
-        if let model = oldModel {
-            currentActionInfoModel = model
-        }else {
-            currentActionInfoModel.id = Int.timestampInt()
-            currentActionInfoModel.request.prompt = prompt
-            currentActionInfoModel.request.promptSort = promptSort
-            currentActionInfoModel.actionStatus = .pending
-            currentActionInfoModel.status = "pending"
-        }
+        initializeFirstCurrentActionInfoModel(oldModel: oldModel, prompt: prompt, promptSort: promptSort)
         
-        replaceSaveInfoModel(model: currentActionInfoModel)
-        stateDatauPblished = (.start,currentActionInfoModel)
-        let time = 5.0
-        
-        for i in 0..<Int(time){
-            kDelayOnMainThread(Double(i)) {
-                let progress = Float(i)*10/100.0
-                self.currentActionInfoModel.percent = progress
-                self.currentActionInfoModel.actionStatus = .running
-                self.currentActionInfoModel.status = "running"
-                self.replaceSaveInfoModel(model: self.currentActionInfoModel)
-                self.stateDatauPblished = (.progressString(self.generating(progress: progress)),nil)
-            }
-        }
+        generatingProgress = 0
 
-        kDelayOnMainThread(time+1.0) {
-            if kRandomBool(), let infoModel = TSActionInfoModel(JSON: self.actionInfoDict){
-                infoModel.id = Int.uuid
-                self.replaceSaveInfoModel(model: infoModel)
-                self.stateDatauPblished = (.success(nil),self.currentActionInfoModel)
-            }else{
-                self.currentActionInfoModel.actionStatus = .failed
-                self.currentActionInfoModel.status = "failed"
-                self.replaceSaveInfoModel(model: self.currentActionInfoModel)
-                self.stateDatauPblished = (.failed("error?.localizedDescription"),nil)
+        let postDict:[String : Any] = [
+            "prompt":prompt,
+            "width":textPicW,
+            "height":textPicH
+        ]
+        creatRequest = TSNetworkShared.post(urlType: .textPicCreate,parameters: postDict) { [weak self] data,error in
+            guard let self = self else { return }
+            if let dataDict = data as? [String:Any] ,
+               dataDict.safeInt(forKey: "code") == 200,
+               let actionId = dataDict["actionId"] as? Int{
+                if stopNetwork == false {
+                    self.getActionInfo(action_id:actionId)
+                    return
+                }
             }
-//            TSPhotoHistory.dePrintAllModel()
+            
+            handleFailInfoModel(errorString: error?.localizedDescription)
         }
     }
     
-
-    
-//    //width 和 height 必须是 32 的倍数
-//    func creatImageEmoji(text:String) {
-//        generatingProgress = 0
-//        aiText = text
-//        let postDict:[String : Any] = [
-//            "prompt":text,
-//            "width":textPicW,
-//            "height":textPicH
-//        ]
-//        stateDatauPblished = (.start,nil)
-//        stateDatauPblished = (.progressString(generating(progress: 0.0)),nil)
-//        creatRequest = TSNetworkShared.post(urlType: .textPicCreate,parameters: postDict) { [weak self] data,error in
-//            guard let self = self else { return }
-//            if let dataDict = data as? [String:Any] ,
-//               dataDict.safeInt(forKey: "code") == 200,
-//               let actionId = dataDict["actionId"] as? Int{
-//                if stopNetwork == false {
-//                    self.getActionInfo(action_id:actionId)
-//                }
-//            }else{
-//                self.stateDatauPblished = (.failed(error?.localizedDescription ?? ""),nil)
-//            }
-//        }
-//    }
-    
     override func getGeneratingProgressText()->String{
         return "Working on your contact Photo \(generatingProgress)% ..."
     }

+ 48 - 47
AIRingtone/Common/Tool/OperationQueue/TSGenerateBaseOperation/TSGeneratePosterOperation.swift

@@ -43,7 +43,7 @@ class TSGeneratePosterOperation: TSGenerateBaseOperation , @unchecked Sendable{
     var gennerateType:TSGennerateType = .poster
 
 
-    func replaceSaveInfoModel(model:TSActionInfoModel){
+    override func replaceSaveInfoModel(model:TSActionInfoModel){
         model.uuid = uuid
         TSPosterHistory.replaceModel(oldID: currentActionInfoModel.id, newModel: model)
         currentActionInfoModel = model
@@ -53,59 +53,59 @@ class TSGeneratePosterOperation: TSGenerateBaseOperation , @unchecked Sendable{
     }
 
     //模拟数据
-    func creatPoster(oldModel:TSActionInfoModel? = nil,prompt:String,promptSort:String) {
-        if let model = oldModel {
-            currentActionInfoModel = model
-        }else {
-            currentActionInfoModel.id = Int.timestampInt()
-            currentActionInfoModel.request.prompt = prompt
-            currentActionInfoModel.request.promptSort = promptSort
-            currentActionInfoModel.actionStatus = .pending
-            currentActionInfoModel.status = "pending"
-        }
-        
-        replaceSaveInfoModel(model: currentActionInfoModel)
-        stateDatauPblished = (.start,currentActionInfoModel)
-        let time = 5.0
-        
-        for i in 0..<Int(time){
-            kDelayOnMainThread(Double(i)) {
-                let progress = Float(i)*10/100.0
-                self.currentActionInfoModel.percent = progress
-                self.currentActionInfoModel.actionStatus = .running
-                self.currentActionInfoModel.status = "running"
-                self.replaceSaveInfoModel(model: self.currentActionInfoModel)
-                self.stateDatauPblished = (.progressString(self.generating(progress: progress)),nil)
-            }
-        }
-
-        kDelayOnMainThread(time+1.0) {
-            if kRandomBool(), let infoModel = TSActionInfoModel(JSON: self.actionInfoDict){
-                infoModel.id = Int.uuid
-                self.replaceSaveInfoModel(model: infoModel)
-                self.stateDatauPblished = (.success(nil),self.currentActionInfoModel)
-            }else{
-                self.currentActionInfoModel.actionStatus = .failed
-                self.currentActionInfoModel.status = "failed"
-                self.replaceSaveInfoModel(model: self.currentActionInfoModel)
-                self.stateDatauPblished = (.failed("error?.localizedDescription"),nil)
-            }
-//            TSPosterHistory.dePrintAllModel()
-        }
-    }
+//    func creatPoster(oldModel:TSActionInfoModel? = nil,prompt:String,promptSort:String) {
+//        if let model = oldModel {
+//            currentActionInfoModel = model
+//        }else {
+//            currentActionInfoModel.id = Int.timestampInt()
+//            currentActionInfoModel.request.prompt = prompt
+//            currentActionInfoModel.request.promptSort = promptSort
+//            currentActionInfoModel.actionStatus = .pending
+//            currentActionInfoModel.status = "pending"
+//        }
+//        replaceSaveInfoModel(model: currentActionInfoModel)
+//        
+//        stateDatauPblished = (.start,currentActionInfoModel)
+//        let time = 5.0
+//        
+//        for i in 0..<Int(time){
+//            kDelayOnMainThread(Double(i)) {
+//                let progress = Float(i)*10/100.0
+//                self.currentActionInfoModel.percent = progress
+//                self.currentActionInfoModel.actionStatus = .running
+//                self.currentActionInfoModel.status = "running"
+//                self.replaceSaveInfoModel(model: self.currentActionInfoModel)
+//                self.stateDatauPblished = (.progressString(self.generating(progress: progress)),nil)
+//            }
+//        }
+//
+//        kDelayOnMainThread(time+1.0) {
+//            if kRandomBool(), let infoModel = TSActionInfoModel(JSON: self.actionInfoDict){
+//                infoModel.id = Int.uuid
+//                self.replaceSaveInfoModel(model: infoModel)
+//                self.stateDatauPblished = (.success(nil),self.currentActionInfoModel)
+//            }else{
+//                self.currentActionInfoModel.actionStatus = .failed
+//                self.currentActionInfoModel.status = "failed"
+//                self.replaceSaveInfoModel(model: self.currentActionInfoModel)
+//                self.stateDatauPblished = (.failed("error?.localizedDescription"),nil)
+//            }
+////            TSPosterHistory.dePrintAllModel()
+//        }
+//    }
     
 
     
     //width 和 height 必须是 32 的倍数
-    func creatImageEmoji(text:String) {
+    func creatPoster(oldModel:TSActionInfoModel? = nil,prompt:String,promptSort:String) {
+        initializeFirstCurrentActionInfoModel(oldModel: oldModel, prompt: prompt, promptSort: promptSort)
+        
         generatingProgress = 0
         let postDict:[String : Any] = [
-            "prompt":text,
+            "prompt":prompt,
             "width":textPicW,
             "height":textPicH
         ]
-        stateDatauPblished = (.start,nil)
-        stateDatauPblished = (.progressString(generating(progress: 0.0)),nil)
         creatRequest = TSNetworkShared.post(urlType: .textPicCreate,parameters: postDict) { [weak self] data,error in
             guard let self = self else { return }
             if let dataDict = data as? [String:Any] ,
@@ -113,10 +113,11 @@ class TSGeneratePosterOperation: TSGenerateBaseOperation , @unchecked Sendable{
                let actionId = dataDict["actionId"] as? Int{
                 if stopNetwork == false {
                     self.getActionInfo(action_id:actionId)
+                    return
                 }
-            }else{
-                self.stateDatauPblished = (.failed(error?.localizedDescription ?? ""),nil)
             }
+            
+            handleFailInfoModel(errorString: error?.localizedDescription)
         }
     }
     

+ 54 - 63
AIRingtone/Common/Tool/OperationQueue/TSGenerateBaseOperation/TSGenerateRintoneOperation.swift

@@ -44,7 +44,7 @@ class TSGenerateRintoneOperation: TSGenerateBaseOperation , @unchecked Sendable{
         ]
     }
     
-    func replaceSaveInfoModel(model:TSActionInfoModel){
+    override func replaceSaveInfoModel(model:TSActionInfoModel){
         model.uuid = uuid
         TSAIRintoneHistory.replaceModel(oldID: currentActionInfoModel.id, newModel: model)
         currentActionInfoModel = model
@@ -53,70 +53,61 @@ class TSGenerateRintoneOperation: TSGenerateBaseOperation , @unchecked Sendable{
         currentActionInfoModelChanged?(currentActionInfoModel)
     }
 
-    //模拟数据
+//    //模拟数据
+//    func creatRintone(oldModel:TSActionInfoModel? = nil,prompt:String,promptSort:String) {
+//        
+//    initializeFirstCurrentActionInfoModel(oldModel: oldModel, prompt: prompt, promptSort: promptSort)
+//        let time = 8.0
+//        
+//        for i in 0..<Int(time){
+//            kDelayOnMainThread(Double(i)) {
+//                let progress = Float(i)*10.0/100.0
+//                self.currentActionInfoModel.percent = progress
+//                self.currentActionInfoModel.actionStatus = .running
+//                self.currentActionInfoModel.status = "running"
+//                self.replaceSaveInfoModel(model: self.currentActionInfoModel)
+//                self.stateDatauPblished = (.progressString(self.generating(progress: progress)),nil)
+//            }
+//        }
+//
+//        kDelayOnMainThread(time+1.0) {
+//            if kRandomBool(), let infoModel = TSActionInfoModel(JSON: self.actionInfoDict){
+//                infoModel.id = Int.uuid
+//                self.replaceSaveInfoModel(model: infoModel)
+//                self.stateDatauPblished = (.success(nil),self.currentActionInfoModel)
+//            }else{
+//                self.currentActionInfoModel.actionStatus = .failed
+//                self.currentActionInfoModel.status = "failed"
+//                self.replaceSaveInfoModel(model: self.currentActionInfoModel)
+//                self.stateDatauPblished = (.failed("error?.localizedDescription"),nil)
+//            }
+//            TSAIRintoneHistory.dePrintAllModel()
+//        }
+//    }
+    
     func creatRintone(oldModel:TSActionInfoModel? = nil,prompt:String,promptSort:String) {
-//        stateDatauPblished = (.start,nil)
-        if let model = oldModel {
-            currentActionInfoModel = model
-        }else {
-            currentActionInfoModel.id = Int.timestampInt()
-            currentActionInfoModel.request.prompt = prompt
-            currentActionInfoModel.request.promptSort = promptSort
-            currentActionInfoModel.actionStatus = .pending
-            currentActionInfoModel.status = "pending"
-        }
-        
-        replaceSaveInfoModel(model: currentActionInfoModel)
-        stateDatauPblished = (.start,currentActionInfoModel)
-        let time = 8.0
-        
-        for i in 0..<Int(time){
-            kDelayOnMainThread(Double(i)) {
-                let progress = Float(i)*10.0/100.0
-                self.currentActionInfoModel.percent = progress
-                self.currentActionInfoModel.actionStatus = .running
-                self.currentActionInfoModel.status = "running"
-                self.replaceSaveInfoModel(model: self.currentActionInfoModel)
-                self.stateDatauPblished = (.progressString(self.generating(progress: progress)),nil)
-            }
-        }
+        initializeFirstCurrentActionInfoModel(oldModel: oldModel, prompt: prompt, promptSort: promptSort)
+       
+       generatingProgress = 0
+       let postDict:[String : Any] = [
+           "prompt":prompt,
+           "duration":20
+       ]
 
-        kDelayOnMainThread(time+1.0) {
-            if kRandomBool(), let infoModel = TSActionInfoModel(JSON: self.actionInfoDict){
-                infoModel.id = Int.uuid
-                self.replaceSaveInfoModel(model: infoModel)
-                self.stateDatauPblished = (.success(nil),self.currentActionInfoModel)
-            }else{
-                self.currentActionInfoModel.actionStatus = .failed
-                self.currentActionInfoModel.status = "failed"
-                self.replaceSaveInfoModel(model: self.currentActionInfoModel)
-                self.stateDatauPblished = (.failed("error?.localizedDescription"),nil)
-            }
-            TSAIRintoneHistory.dePrintAllModel()
-        }
-    }
-    
-//   func creatRintone(text:String) {
-//       generatingProgress = 0
-//       aiText = text
-//       let postDict:[String : Any] = [
-//           "prompt":text,
-//           "duration":20
-//       ]
-//       stateDatauPblished = (.start,nil)
-//       creatRequest = TSNetworkShared.post(urlType: .musicCreate,parameters: postDict) { [weak self] data,error in
-//           guard let self = self else { return }
-//           if let dataDict = data as? [String:Any] ,
-//              dataDict.safeInt(forKey: "code") == 200,
-//              let actionId = dataDict["actionId"] as? Int{
-//               if stopNetwork == false {
-//                   self.getActionInfo(action_id:actionId)
-//               }
-//           }else{
-//               self.stateDatauPblished = (.failed(error?.localizedDescription ?? ""),nil)
-//           }
-//       }
-//   }
+       creatRequest = TSNetworkShared.post(urlType: .musicCreate,parameters: postDict) { [weak self] data,error in
+           guard let self = self else { return }
+           if let dataDict = data as? [String:Any] ,
+              dataDict.safeInt(forKey: "code") == 200,
+              let actionId = dataDict["actionId"] as? Int{
+               if stopNetwork == false {
+                   self.getActionInfo(action_id:actionId)
+                   return
+               }
+           }
+           
+           handleFailInfoModel(errorString: error?.localizedDescription)
+       }
+   }
 
     
 }