100Years 1 mese fa
parent
commit
6e163f959f
27 ha cambiato i file con 427 aggiunte e 76 eliminazioni
  1. 12 0
      AIEmoji.xcodeproj/project.pbxproj
  2. 22 0
      AIEmoji/Assets.xcassets/Common/gray_right_arrow.imageset/Contents.json
  3. BIN
      AIEmoji/Assets.xcassets/Common/gray_right_arrow.imageset/gary_right_arrow@2x.png
  4. BIN
      AIEmoji/Assets.xcassets/Common/gray_right_arrow.imageset/gary_right_arrow@3x.png
  5. 15 3
      AIEmoji/Business/Data/TSDBHistoryManager.swift
  6. 2 0
      AIEmoji/Business/General/Ex/Notification+Ex.swift
  7. 3 3
      AIEmoji/Business/TSAILIstVC/TSAIListHistoryBaseVC/TSAIListHistoryBaseCell.swift
  8. 39 32
      AIEmoji/Business/TSAILIstVC/TSAIListHistoryBaseVC/TSAIListHistoryBaseVC.swift
  9. 15 9
      AIEmoji/Business/TSGenmojiVC/TSGenmojiVC/TSGenmojiVC.swift
  10. 40 3
      AIEmoji/Business/TSGenmojiVC/TSGenmojiVC/View/TSGenmojiColSectionView.swift
  11. 20 2
      AIEmoji/Business/TSGenmojiVC/TSGenmojiVC/View/TSGenmojiItemCell.swift
  12. 25 4
      AIEmoji/Business/TSGenmojiVC/TSGenmojiVC/ViewModel/TSGenmojiViewModel.swift
  13. 126 0
      AIEmoji/Business/TSPTPGeneratorVC/TSPTPHistoryVC/TSPTPHistoryVC.swift
  14. 18 7
      AIEmoji/Business/TSPTPGeneratorVC/TSPTPInputVC/TSPTPInputVC.swift
  15. 1 2
      AIEmoji/Business/TSPTPGeneratorVC/TSPTPInputVC/VM/TSPTPInputVM.swift
  16. 9 5
      AIEmoji/Business/TSTextGeneralPictureVC/TSTextGeneralPictureVC/TSTextGeneralPictureVC.swift
  17. 29 5
      AIEmoji/Business/TSTextGeneralPictureVC/TSTextGeneralPictureVC/ViewModel/TSTextGeneralPictureVM.swift
  18. 1 1
      AIEmoji/Common/Tool/OperationQueue/TSGenerateBaseOperation/TSGeneratePosterOperation.swift
  19. 5 0
      AIEmoji/de.lproj/Localizable.strings
  20. 5 0
      AIEmoji/en.lproj/Localizable.strings
  21. 5 0
      AIEmoji/es.lproj/Localizable.strings
  22. 5 0
      AIEmoji/ja.lproj/Localizable.strings
  23. 10 0
      AIEmoji/ko.lproj/Localizable.strings
  24. 5 0
      AIEmoji/pt-BR.lproj/Localizable.strings
  25. 5 0
      AIEmoji/pt-PT.lproj/Localizable.strings
  26. 5 0
      AIEmoji/zh-Hans.lproj/Localizable.strings
  27. 5 0
      AIEmoji/zh-Hant.lproj/Localizable.strings

+ 12 - 0
AIEmoji.xcodeproj/project.pbxproj

@@ -133,6 +133,7 @@
 		A87587162D81734300286A66 /* text_to_photo_style.json in Resources */ = {isa = PBXBuildFile; fileRef = A87587152D81733C00286A66 /* text_to_photo_style.json */; };
 		A87587182D81814500286A66 /* TSAIThinkingView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A87587172D81812C00286A66 /* TSAIThinkingView.swift */; };
 		A88508882DBCD944000FBCEC /* MemoryLeakChecker.swift in Sources */ = {isa = PBXBuildFile; fileRef = A88508872DBCD940000FBCEC /* MemoryLeakChecker.swift */; };
+		A885088D2DBCE7BE000FBCEC /* TSPTPHistoryVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = A885088C2DBCE7BC000FBCEC /* TSPTPHistoryVC.swift */; };
 		A899D34A2D827A0E00AB9C1C /* TSChatThinkingModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = A899D3492D8279FB00AB9C1C /* TSChatThinkingModel.swift */; };
 		A89EA64B2D59A588000EB181 /* MessageKit in Frameworks */ = {isa = PBXBuildFile; productRef = A89EA64A2D59A588000EB181 /* MessageKit */; };
 		A89EA6542D59A9F4000EB181 /* TSTextLayoutSizeCalculator.swift in Sources */ = {isa = PBXBuildFile; fileRef = A89EA64F2D59A9F4000EB181 /* TSTextLayoutSizeCalculator.swift */; };
@@ -403,6 +404,7 @@
 		A87587152D81733C00286A66 /* text_to_photo_style.json */ = {isa = PBXFileReference; lastKnownFileType = text.json; path = text_to_photo_style.json; sourceTree = "<group>"; };
 		A87587172D81812C00286A66 /* TSAIThinkingView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TSAIThinkingView.swift; sourceTree = "<group>"; };
 		A88508872DBCD940000FBCEC /* MemoryLeakChecker.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MemoryLeakChecker.swift; sourceTree = "<group>"; };
+		A885088C2DBCE7BC000FBCEC /* TSPTPHistoryVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TSPTPHistoryVC.swift; sourceTree = "<group>"; };
 		A899D3492D8279FB00AB9C1C /* TSChatThinkingModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TSChatThinkingModel.swift; sourceTree = "<group>"; };
 		A89EA64C2D59A9F4000EB181 /* CustomMessageFlowLayout.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CustomMessageFlowLayout.swift; sourceTree = "<group>"; };
 		A89EA64E2D59A9F4000EB181 /* TSLayoutSizeCalculator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TSLayoutSizeCalculator.swift; sourceTree = "<group>"; };
@@ -1024,6 +1026,7 @@
 		A80EDDDC2D6EB17D003CD332 /* TSPTPGeneratorVC */ = {
 			isa = PBXGroup;
 			children = (
+				A885088B2DBCE7B8000FBCEC /* TSPTPHistoryVC */,
 				A8F413492DA75863001E715A /* TSUploadPhotoPrivacyAlertVC */,
 				A8BA76502DA515F9000B6707 /* TSPTPImageHintVC */,
 				A8BA763D2DA4C8F9000B6707 /* TSPTPInputVC */,
@@ -1259,6 +1262,14 @@
 			path = TSChatMessageUIModel;
 			sourceTree = "<group>";
 		};
+		A885088B2DBCE7B8000FBCEC /* TSPTPHistoryVC */ = {
+			isa = PBXGroup;
+			children = (
+				A885088C2DBCE7BC000FBCEC /* TSPTPHistoryVC.swift */,
+			);
+			path = TSPTPHistoryVC;
+			sourceTree = "<group>";
+		};
 		A899D3482D8279E500AB9C1C /* CHatMessageModel */ = {
 			isa = PBXGroup;
 			children = (
@@ -2247,6 +2258,7 @@
 				A8F775452D39347100AA6E93 /* TSSetingViewModel.swift in Sources */,
 				A80E72202D3F3A8600C64288 /* DiyElementBaseView.swift in Sources */,
 				A8F776212D3A3F0200AA6E93 /* TSEmojisChildVC.swift in Sources */,
+				A885088D2DBCE7BE000FBCEC /* TSPTPHistoryVC.swift in Sources */,
 				A8F413512DA7B722001E715A /* TSPurchaseManager+DataReport.swift in Sources */,
 				A80E72222D3F3A9200C64288 /* DiyStickerElement.swift in Sources */,
 				A85E47C32D6964A50018D62D /* TSMSGAIDefaultHeaderView.swift in Sources */,

+ 22 - 0
AIEmoji/Assets.xcassets/Common/gray_right_arrow.imageset/Contents.json

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

BIN
AIEmoji/Assets.xcassets/Common/gray_right_arrow.imageset/gary_right_arrow@2x.png


BIN
AIEmoji/Assets.xcassets/Common/gray_right_arrow.imageset/gary_right_arrow@3x.png


+ 15 - 3
AIEmoji/Business/Data/TSDBHistoryManager.swift

@@ -41,8 +41,7 @@ class TSDBHistory: Object {
         self.primaryKey = type.rawValue
     }
     
-    
-    //获取 App 层的 TSChatMessage 数组
+
     func getModelList() -> [TSActionInfoModel] {
         var msgModel:[TSActionInfoModel] = []
         for msgDBModel in listModels {
@@ -51,7 +50,20 @@ class TSDBHistory: Object {
         return msgModel
     }
     
-    //获取 App 层的 TSChatMessage 数组
+    
+    func getModelList(completion:@escaping ([TSActionInfoModel])->Void){
+        let frozenList = self.listModels.freeze()
+        DispatchQueue.global(qos: .userInitiated).async {
+            var msgModel:[TSActionInfoModel] = []
+            for msgDBModel in frozenList {
+                msgModel.append(msgDBModel.getModel())
+            }
+            DispatchQueue.main.async {
+                completion(msgModel)
+            }
+        }
+    }
+    
     func getModelList(count:Int) -> [TSActionInfoModel] {
         let listModels = Array(listModels.prefix(count))
         var msgModel:[TSActionInfoModel] = []

+ 2 - 0
AIEmoji/Business/General/Ex/Notification+Ex.swift

@@ -15,4 +15,6 @@ extension Notification.Name {
     
     static let kBaseOperationQueueCountChanged = Notification.Name("kBaseOperationQueueCountChanged") //任务数量放生变化
     static let kGeneratePTPOperationChanged = Notification.Name("kGeneratePTPOperationChanged") //生成图生图任务发生变化
+    
+    static let kPTPDataChanged = Notification.Name("kPTPDataChanged") //图生图数据放生改变
 }

+ 3 - 3
AIEmoji/Business/TSAILIstVC/TSAIListHistoryBaseVC/TSAIListHistoryBaseCell.swift

@@ -7,11 +7,11 @@
 
 class TSAIListHistoryBaseCell: TSBaseCollectionCell,TSSimpleConfigurableView {
     
-    var delegate: (any TSSmalCoacopods.TSSimpleCollectionViewDelegate)?
+    weak var delegate: (any TSSmalCoacopods.TSSimpleCollectionViewDelegate)?
     var indexPath: IndexPath?
     var data: Any? {
         didSet {
-            debugPrint("TSAIListHistoryBaseCell data didSet")
+//            debugPrint("TSAIListHistoryBaseCell data didSet")
             if let dataModel = data as? TSActionInfoModel{
                 videoIconImageView.isHidden = true
                 exampleView.isHidden = true
@@ -68,7 +68,7 @@ class TSAIListHistoryBaseCell: TSBaseCollectionCell,TSSimpleConfigurableView {
     
     
     override func creatUI() {
-        debugPrint("TSAIListHistoryBaseCell creatUI")
+//        debugPrint("TSAIListHistoryBaseCell creatUI")
         contentView.addSubview(showImageView)
         showImageView.snp.makeConstraints { make in
             make.top.equalTo(0)

+ 39 - 32
AIEmoji/Business/TSAILIstVC/TSAIListHistoryBaseVC/TSAIListHistoryBaseVC.swift

@@ -17,9 +17,7 @@ class TSAIListHistoryBaseVC: TSBaseVC {
         fatalError("init(coder:) has not been implemented")
     }
     
-    lazy var listModelArray: [TSActionInfoModel] = {
-        return getlistModelArray
-    }()
+    var listModelArray: [TSActionInfoModel] = []
     //###################################### 集合视图 ######################################
     let collectionViewBtootm:CGFloat = 80
     lazy var collectionView: TSSimpleCollectionView = {
@@ -73,11 +71,14 @@ class TSAIListHistoryBaseVC: TSBaseVC {
     }
     
     override func dealThings() {
-        DispatchQueue.global(qos: .userInitiated).async {
-            _ = self.listModelArray
-            DispatchQueue.main.async {
-                self.updateView()
-            }
+        updateDataView()
+    }
+    
+    func updateDataView(){
+        dbHistory.getModelList { [weak self] array in
+            guard let self = self else { return }
+            listModelArray = array
+            updateView()
         }
     }
     
@@ -115,40 +116,46 @@ extension TSAIListHistoryBaseVC: TSSimpleCollectionViewDelegate {
 
 extension TSAIListHistoryBaseVC{
     func removeAllHistoryList(){
-        switch generatorStyle {
-        case .ageOld:
-            TSRMShared.oldAgeDBHistory.delete()
-        case .ageChild:
-            TSRMShared.babyAgeDBHistory.delete()
-        case .oldPhoto:
-            TSRMShared.oldPhotoDBHistory.delete()
-        case .eyeOpen:
-            TSRMShared.openEyesDBHistory.delete()
-        case .pretty:
-            TSRMShared.prettyDBHistory.delete()
-        case .photoLive:
-            TSRMShared.photoLiveDBHistory.delete()
-        case .photoExpand:
-            TSRMShared.photoExpandDBHistory.delete()
-        }
+        dbHistory.delete()
+        updateView()
     }
     
-    var getlistModelArray:[TSActionInfoModel]{
+//    var getlistModelArray:[TSActionInfoModel]{
+//        switch generatorStyle {
+//        case .ageOld:
+//            TSRMShared.oldAgeDBHistory.getModelList()
+//        case .ageChild:
+//            TSRMShared.babyAgeDBHistory.getModelList()
+//        case .oldPhoto:
+//            TSRMShared.oldPhotoDBHistory.getModelList()
+//        case .eyeOpen:
+//            TSRMShared.openEyesDBHistory.getModelList()
+//        case .pretty:
+//            TSRMShared.prettyDBHistory.getModelList()
+//        case .photoLive:
+//            TSRMShared.photoLiveDBHistory.getModelList()
+//        case .photoExpand:
+//            TSRMShared.photoExpandDBHistory.getModelList()
+//        }
+//    }
+    
+    var dbHistory:TSDBHistory{
         switch generatorStyle {
         case .ageOld:
-            TSRMShared.oldAgeDBHistory.getModelList()
+            TSRMShared.oldAgeDBHistory
         case .ageChild:
-            TSRMShared.babyAgeDBHistory.getModelList()
+            TSRMShared.babyAgeDBHistory
         case .oldPhoto:
-            TSRMShared.oldPhotoDBHistory.getModelList()
+            TSRMShared.oldPhotoDBHistory
         case .eyeOpen:
-            TSRMShared.openEyesDBHistory.getModelList()
+            TSRMShared.openEyesDBHistory
         case .pretty:
-            TSRMShared.prettyDBHistory.getModelList()
+            TSRMShared.prettyDBHistory
         case .photoLive:
-            TSRMShared.photoLiveDBHistory.getModelList()
+            TSRMShared.photoLiveDBHistory
         case .photoExpand:
-            TSRMShared.photoExpandDBHistory.getModelList()
+            TSRMShared.photoExpandDBHistory
         }
     }
+    
 }

+ 15 - 9
AIEmoji/Business/TSGenmojiVC/TSGenmojiVC/TSGenmojiVC.swift

@@ -12,9 +12,7 @@ class TSGenmojiVC: TSBaseVC {
     lazy var vipBtn: UIButton = {
         let vipBtn = UIButton.createButton(image: UIImage(named: "nav_vip")) { [weak self]  in
             guard let self = self else { return }
-            TSPurchaseVC.show(target: self) {
-      
-            }
+            TSPurchaseVC.show(target: self) {}
         }
         return vipBtn
     }()
@@ -35,8 +33,7 @@ class TSGenmojiVC: TSBaseVC {
             if let cmd = cellCp as? String, cmd == "delete"  {
                 showCustomAlert(message: "Are you sure to delete".localized, deleteHandler:  {
                     self.viewModel.removeAllHistoryList()
-                    self.collectionComponent.clear()
-                    self.collectionComponent.reloadView(with: self.viewModel.colDataArray)
+                    self.updateListDataView()
                 })
             }
         }
@@ -79,8 +76,7 @@ class TSGenmojiVC: TSBaseVC {
         let tapGesture = UITapGestureRecognizer(target: self, action: #selector(clickCollectionView))
         tapGesture.cancelsTouchesInView = false // 确保不影响其他点击事件
         collectionComponent.collectionView.addGestureRecognizer(tapGesture)
-        collectionComponent.clear()
-        collectionComponent.reloadView(with:viewModel.colDataArray)
+        updateListDataView()
     }
     
     override func dealThings() {
@@ -112,8 +108,7 @@ extension TSGenmojiVC {
         let gennerateVC = TSGenmojiGennerateVC(aiText: text) {[weak self] model in
             guard let self = self else { return }
             if viewModel.saveModel(model:model) {
-                collectionComponent.clear()
-                collectionComponent.reloadView(with:viewModel.colDataArray)
+                updateListDataView()
             }else{
                 collectionComponent.reloadData()
             }
@@ -121,4 +116,15 @@ extension TSGenmojiVC {
         
         kPresentModalVC(target: self, modelVC: gennerateVC,transitionStyle: .crossDissolve)
     }
+    
+    func updateListDataView(){
+        viewModel.updateRecentData {[weak self]  in
+            guard let self = self else { return }
+            updateListView()
+        }
+    }
+    func updateListView(){
+        self.collectionComponent.clear()
+        self.collectionComponent.reloadView(with: self.viewModel.colDataArray)
+    }
 }

+ 40 - 3
AIEmoji/Business/TSGenmojiVC/TSGenmojiVC/View/TSGenmojiColSectionView.swift

@@ -25,6 +25,29 @@ class TSGenmojiColSectionView: TSBaseCollectionnReusableView {
         return delBtn
     }()
     
+    
+    
+    lazy var moreView: UIView = {
+        let moreView = UIView()
+        moreView.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(clickMoreView)))
+        
+        let label = UILabel.createLabel(text: "More".localized,font: .font(size: 12),textColor: .white.withAlphaComponent(0.4))
+        moreView.addSubview(label)
+        label.snp.makeConstraints { make in
+            make.leading.top.bottom.equalTo(0)
+        }
+        
+        let imageView = UIImageView.createImageView(imageName: "gray_right_arrow")
+        
+        moreView.addSubview(imageView)
+        imageView.snp.makeConstraints { make in
+            make.trailing.top.bottom.equalTo(0)
+            make.leading.equalTo(label.snp.trailing)
+        }
+        
+        return moreView
+    }()
+    
     override func creatUI() {
         
         bgContentView.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(dismissKeyboard)))
@@ -47,6 +70,12 @@ class TSGenmojiColSectionView: TSBaseCollectionnReusableView {
             make.width.height.equalTo(40)
             make.centerY.equalToSuperview().offset(kSectionTitleViewCenterYOffset)
         }
+        
+        bgContentView.addSubview(moreView)
+        moreView.snp.makeConstraints { make in
+            make.trailing.equalTo(-6)
+            make.centerY.equalToSuperview().offset(kSectionTitleViewCenterYOffset)
+        }
     }
     
     override func renderView(with object: Any?, component: TSCollectionViewComponent, attributes: [String : Any]?) {
@@ -55,13 +84,16 @@ class TSGenmojiColSectionView: TSBaseCollectionnReusableView {
             leftLab.text = componentReuseViewModel.sectionModel.name
             leftSubLab.text = componentReuseViewModel.sectionModel.subText
             switch componentReuseViewModel.sectionModel.style {
-            case .history,.textPicHistory,.ptpPicHistory:
+            case .ptpPicHistory:
+                moreView.isHidden = false
+                delBtn.isHidden = true
+            case .history,.textPicHistory:
                 delBtn.isHidden = false
+                moreView.isHidden = true
             default:
                 delBtn.isHidden = true
+                moreView.isHidden = true
             }
-            
-        
         }
     }
     
@@ -70,6 +102,11 @@ class TSGenmojiColSectionView: TSBaseCollectionnReusableView {
             topVC.view.endEditing(true) // 收起键盘
         }
     }
+    
+    @objc private func clickMoreView() {
+        actionHandler(any: "more")
+    }
+    
 
 }
 

+ 20 - 2
AIEmoji/Business/TSGenmojiVC/TSGenmojiVC/View/TSGenmojiItemCell.swift

@@ -8,11 +8,10 @@
 
 class TSGenmojiItemCell: TSBaseCollectionCell ,TSSimpleConfigurableView {
     
-    var delegate: (any TSSmalCoacopods.TSSimpleCollectionViewDelegate)?
+    weak var delegate: (any TSSmalCoacopods.TSSimpleCollectionViewDelegate)?
     var indexPath: IndexPath?
     var data: Any? {
         didSet {
-            debugPrint("TSGenmojiItemCell renderView")
             if let dataModel = data as? TSActionInfoModel{
                 self.dataModel = dataModel
                 self.updataActionInfoModelView(model: dataModel)
@@ -98,6 +97,25 @@ class TSGenmojiItemCell: TSBaseCollectionCell ,TSSimpleConfigurableView {
         }
     }
     
+    override func renderView(with object: Any?, component: TSCollectionViewComponent, attributes: [String : Any]?) {
+        super.renderView(with: object, component: component, attributes: attributes)
+        if let itemModel = object as? TSGenmojiCoLItemModel{
+            self.dataModel = itemModel.dataModel
+            self.updataActionInfoModelView(model: itemModel.dataModel)
+            if let operation = TSGeneratePTPOperationQueue.shared.findOperation(uuid: itemModel.dataModel.uuid) as? TSGeneratePTPOperation {
+                DispatchQueue.main.async {
+                    operation.currentActionInfoModelChanged = { [weak self] actionInfoModel in
+                        guard let self = self else { return }
+                        DispatchQueue.main.async {
+                            self.updataActionInfoModelView(model: actionInfoModel)
+                        }
+                    }
+                }
+            }
+        }
+    }
+    
+    
     func updataActionInfoModelView(model:TSActionInfoModel){
         
         if model.modelType == .example {

+ 25 - 4
AIEmoji/Business/TSGenmojiVC/TSGenmojiVC/ViewModel/TSGenmojiViewModel.swift

@@ -33,9 +33,9 @@ class TSGenmojiViewModel {
     
     
 
-    init() {
-        combinedData()
-    }
+//    init() {
+//        combinedData()
+//    }
     
     func combinedData(){
         colDataArray.removeAll()
@@ -45,6 +45,28 @@ class TSGenmojiViewModel {
         }
     }
     
+    
+    func updateRecentData(completion:@escaping ()->Void) {
+        TSRMShared.ttEnmojiDBHistory.getModelList {[weak self] array in
+            guard let self = self else { return }
+            setRecentData(listModelArray: array)
+            completion()
+        }
+    }
+    
+    func setRecentData(listModelArray:[TSActionInfoModel]) {
+        var array = [TSGenmojiCoLItemModel]()
+        if listModelArray.count > 0 {
+            listModelArray.forEach { model in
+                let itemModel = TSGenmojiCoLItemModel()
+                itemModel.style = .history
+                itemModel.dataModel = model
+                array.append(itemModel)
+            }
+        }
+        enmojiHistorySeciton.items = array
+        combinedData()
+    }
 }
  
 extension TSGenmojiViewModel {
@@ -66,7 +88,6 @@ extension TSGenmojiViewModel {
     
     func removeAllHistoryList(){
         TSRMShared.ttEnmojiDBHistory.delete()
-        
         enmojiHistorySeciton.items.removeAll()
         colDataArray.removeLast()
     }

+ 126 - 0
AIEmoji/Business/TSPTPGeneratorVC/TSPTPHistoryVC/TSPTPHistoryVC.swift

@@ -0,0 +1,126 @@
+//
+//  TSPTPHistoryVC.swift
+//  AIEmoji
+//
+//  Created by 100Years on 2025/4/26.
+//
+
+
+
+import UIKit
+
+class TSPTPHistoryVC: TSBaseVC {
+    var listModelArray: [TSActionInfoModel] = []
+    var dataChangedBlock:(()->Void)?
+    //###################################### 集合视图 ######################################
+    let collectionViewBtootm:CGFloat = 80
+    lazy var collectionView: TSSimpleCollectionView = {
+        let identifier = "TSGenmojiItemCell"
+        
+        let itemW = (k_ScreenWidth-32.0-12.0-2.0)/2.0
+        let itemH = kGetScaleHeight(originalSize: CGSize(width: 165.0, height: 220.0), width: itemW)
+        
+//        let itemW = kPTPHistoryW
+//        let itemH = kPTPHistoryH
+        
+        let layout = UICollectionViewFlowLayout()
+        let cp = TSSimpleCollectionView()
+        cp.delegate = self
+        cp.layout.itemSize = CGSize(width: itemW, height: itemH)
+        cp.layout.minimumLineSpacing = 12
+        cp.layout.minimumInteritemSpacing = 12
+        cp.collectionView.contentInset = UIEdgeInsets(top: 16, left: 16, bottom: collectionViewBtootm, right: 16)
+        cp.registerCell(TSGenmojiItemCell.self,identifier:identifier)
+        cp.cellIdentifierForItem = { data in
+            return identifier
+        }
+
+        return cp
+    }()
+    
+    lazy var pageNullView: TSPageNullView = {
+        let pageNullView = TSPageNullView()
+        pageNullView.isHidden = true
+        return pageNullView
+    }()
+    
+    override func createData() {
+        
+    }
+    
+    var navRightBtn = UIButton()
+    override func createView() {
+        
+        addNormalNavBarView()
+        setPageTitle("History".localized)
+        navRightBtn = setNavigationItem("", imageName: "delete", direction: .right, action: #selector(clickNavRight))
+        
+        contentView.addSubview(pageNullView)
+        contentView.addSubview(collectionView)
+        collectionView.snp.makeConstraints { make in
+            make.edges.equalToSuperview()
+        }
+    }
+    
+    override func dealThings() {
+        updateDataView()
+        NotificationCenter.default.addObserver(forName: .kGeneratePTPOperationChanged, object: nil, queue: nil) { [weak self] notification in
+            guard let self = self else { return }
+            if let userInfo = notification.userInfo as? [String: Any],let state = userInfo["state"] as? TSProgressState {
+                dePrint("TSBaseOperation stateDatauPblished 收到 = \(state)")
+                if state.reloadNewData {
+                    updateDataView()
+                }
+               
+            }
+        }
+    }
+    
+    func updateDataView(){
+        TSRMShared.ptpDBHistory.getModelList { [weak self] array in
+            guard let self = self else { return }
+            listModelArray = array
+            updateView()
+        }
+    }
+    
+    func updateView() {
+        collectionView.reload(with:[TSSimpleSectionData(items: listModelArray)])
+        
+        navRightBtn.isHidden = listModelArray.count <= 0
+        pageNullView.isHidden = listModelArray.count > 0
+    }
+    
+    @objc func clickNavRight() {
+        showCustomAlert(message: "Are you sure to delete".localized, deleteHandler:  {
+            self.removeAllHistoryList()
+            self.updateDataView()
+        })
+    }
+
+    deinit {
+        NotificationCenter.default.post(name: .kPTPDataChanged, object: nil)
+    }
+}
+
+extension TSPTPHistoryVC: TSSimpleCollectionViewDelegate {
+    
+    func collectionView(didTrigger event: TSSmalCoacopods.TSSimpleCellEvent) {
+        switch event.action {
+        case .tap:
+            let browseVC = TSAIPhotoBrowseVC()
+            browseVC.dataModelArray = listModelArray.filter{$0.status == "success"}
+            browseVC.currentIndex = event.indexPath.item
+            kPresentModalVC(target: self, modelVC: browseVC,transitionStyle: .crossDissolve)
+        default:
+            break
+        }
+    }
+    
+}
+
+extension TSPTPHistoryVC{
+    func removeAllHistoryList(){
+        TSRMShared.ptpDBHistory.delete()
+    }
+}

+ 18 - 7
AIEmoji/Business/TSPTPGeneratorVC/TSPTPInputVC/TSPTPInputVC.swift

@@ -194,12 +194,17 @@ class TSPTPInputVC: TSBaseVC {
 
         cp.sectionActionHandler = { [weak self] cellCp, indexPath in
             guard let self = self else { return }
-            if let cmd = cellCp as? String, cmd == "delete"  {
-                showCustomAlert(message: "Are you sure to delete".localized, deleteHandler:  {
-                    self.viewModel.removeAllHistoryList()
-                    self.collectionComponent.clear()
-                    self.collectionComponent.reloadView(with: self.viewModel.colDataArray)
-                })
+            if let cmd = cellCp as? String {
+                if cmd == "delete" {
+                    showCustomAlert(message: "Are you sure to delete".localized, deleteHandler:  {
+                        self.viewModel.removeAllHistoryList()
+                        self.collectionComponent.clear()
+                        self.collectionComponent.reloadView(with: self.viewModel.colDataArray)
+                    })
+                }else if cmd == "more" {
+                    let historyVC = TSPTPHistoryVC()
+                    kPushVC(target: self, modelVC: historyVC)
+                }
             }
         }
         
@@ -357,9 +362,15 @@ class TSPTPInputVC: TSBaseVC {
                     collectionComponent.clear()
                     collectionComponent.reloadView(with:viewModel.colDataArray)
                 }
-               
             }
         }
+        
+        NotificationCenter.default.addObserver(forName: .kPTPDataChanged, object: nil, queue: nil) { [weak self] notification in
+            guard let self = self else { return }
+            self.viewModel.updateRecentData()
+            collectionComponent.clear()
+            collectionComponent.reloadView(with:viewModel.colDataArray)
+        }
     }
 }
 

+ 1 - 2
AIEmoji/Business/TSPTPGeneratorVC/TSPTPInputVC/VM/TSPTPInputVM.swift

@@ -42,10 +42,9 @@ class TSPTPInputVM {
     
     var listModels:[TSActionInfoModel]{
         debugPrint("listModels.count = 前")
-        let array = TSRMShared.ptpDBHistory.getModelList()
+        let array = TSRMShared.ptpDBHistory.getModelList(count: 50)
         debugPrint("listModels.count = \(array.count)")
         return array
-//        return TSRMShared.ptpDBHistory.getModelList(count: 50)
     }
     
     lazy var historySeciton: TSGenmojiCoLSectionModel = {

+ 9 - 5
AIEmoji/Business/TSTextGeneralPictureVC/TSTextGeneralPictureVC/TSTextGeneralPictureVC.swift

@@ -19,7 +19,7 @@ class TSTextGeneralPictureVC: TSBaseVC {
             if let cmd = cellCp as? String, cmd == "delete"  {
                 showCustomAlert(message: "Are you sure to delete".localized, deleteHandler:  {
                     self.viewModel.removeAllHistoryList()
-                    self.updateListView()
+                    self.updateListDataView()
                 })
             }
         }
@@ -48,8 +48,7 @@ class TSTextGeneralPictureVC: TSBaseVC {
         let generalRintoneVC = TSTTPInputVC()
         generalRintoneVC.reloadUIBlock = { [weak self]  in
             guard let self = self else { return }
-            viewModel.updateRecentData()
-            updateListView()
+            updateListDataView()
         }
         return generalRintoneVC
     }()
@@ -68,8 +67,7 @@ class TSTextGeneralPictureVC: TSBaseVC {
         tapGesture.cancelsTouchesInView = false // 确保不影响其他点击事件
         collectionComponent.collectionView.addGestureRecognizer(tapGesture)
 
-        collectionComponent.clear()
-        collectionComponent.reloadView(with:viewModel.colDataArray)
+        updateListDataView()
         
         self.collectionComponent.collectionView.addSubview(self.generalRintoneVC.view)
         setUpGeneralRintoneView()
@@ -103,6 +101,12 @@ class TSTextGeneralPictureVC: TSBaseVC {
         view.endEditing(true)
     }
     
+    func updateListDataView(){
+        viewModel.updateRecentData {[weak self]  in
+            guard let self = self else { return }
+            updateListView()
+        }
+    }
     func updateListView(){
         self.collectionComponent.clear()
         self.collectionComponent.reloadView(with: self.viewModel.colDataArray)

+ 29 - 5
AIEmoji/Business/TSTextGeneralPictureVC/TSTextGeneralPictureVC/ViewModel/TSTextGeneralPictureVM.swift

@@ -31,13 +31,37 @@ class TSTextGeneralPictureVM {
         return sectionModel
     }()
     
-    init() {
-        updateRecentData()
-    }
+//    init() {
+//        updateRecentData()
+//    }
+
+//    func updateRecentData() {
+//        let listModelArray = TSRMShared.ttpDBHistory.getModelList()
+//        if listModelArray.count == 0 {
+//            colDataArray = []
+//        }else{
+//            var array = [TSGenmojiCoLItemModel]()
+//            listModelArray.forEach { model in
+//                let itemModel = TSGenmojiCoLItemModel()
+//                itemModel.dataModel = model
+//                itemModel.style = .textPicHistory
+//                array.append(itemModel)
+//            }
+//            enmojiHistorySeciton.items = array
+//            
+//            colDataArray = [enmojiHistorySeciton]
+//        }
+//    }
     
+    func updateRecentData(completion:@escaping ()->Void) {
+        TSRMShared.ttpDBHistory.getModelList {[weak self] array in
+            guard let self = self else { return }
+            setRecentData(listModelArray: array)
+            completion()
+        }
+    }
     
-    func updateRecentData() {
-        let listModelArray = TSRMShared.ttpDBHistory.getModelList()
+    func setRecentData(listModelArray:[TSActionInfoModel]) {
         if listModelArray.count == 0 {
             colDataArray = []
         }else{

+ 1 - 1
AIEmoji/Common/Tool/OperationQueue/TSGenerateBaseOperation/TSGeneratePosterOperation.swift

@@ -57,7 +57,7 @@ class TSGeneratePTPOperation: TSGenerateBaseOperation , @unchecked Sendable{
         
         let copyModel = self.currentActionInfoModel.copy()
         if let rootVC = WindowHelper.getCurrentViewController() ,let cyModel = copyModel as? TSActionInfoModel {
-            kSaveSuccesswShared.show(atView: rootVC.view,text: "Successfully generated".localized,deadline: 30.0) {
+            kSaveSuccesswShared.show(atView: rootVC.view,text: "Successfully generated".localized,deadline: 5.0) {
                 let gennerateVC = TSPTPGeneratorVC(generateStyleModel: TSGenerateStyleModel(),infoModel: cyModel) { model in }
                 gennerateVC.modalPresentationStyle = .overFullScreen
                 gennerateVC.modalTransitionStyle = .crossDissolve

+ 5 - 0
AIEmoji/de.lproj/Localizable.strings

@@ -243,3 +243,8 @@
 "Anime Lite" = "Anime Lite";
 "Anime Pro" = "Anime-Profi";
 "AI Expand Photo" = "AI-Expand-Foto";
+
+"More" = "Mehr";
+"Generation Failed" = "Build fehlgeschlagen";
+"This task has expired" = "Diese Aufgabe ist abgelaufen";
+"Generate in the background" = "Hintergrundgenerierung";

+ 5 - 0
AIEmoji/en.lproj/Localizable.strings

@@ -240,3 +240,8 @@
 "Anime Lite" = "Anime Lite";
 "Anime Pro" = "Anime Pro";
 "AI Expand Photo" = "AI Expand Photo";
+
+"More" = "More";
+"Generation Failed" = "Generation Failed";
+"This task has expired" = "This task has expired";
+"Generate in the background" = "Generate in the background";

+ 5 - 0
AIEmoji/es.lproj/Localizable.strings

@@ -239,3 +239,8 @@
 "Anime Lite" = "Anime ligero";
 "Anime Pro" = "Anime Pro";
 "AI Expand Photo" = "IA Ampliar foto";
+
+"More" = "Más";
+"Generation Failed" = "Generación fallida";
+"This task has expired" = "Esta tarea ha caducado";
+"Generate in the background" = "Generación de fondo";

+ 5 - 0
AIEmoji/ja.lproj/Localizable.strings

@@ -239,3 +239,8 @@
 "Anime Lite" = "アニメライト";
 "Anime Pro" = "アニメプロ";
 "AI Expand Photo" = "AI拡張写真";
+
+"More" = "もっと";
+"Generation Failed" = "世代が失敗";
+"This task has expired" = "このタスクは終了しました";
+"Generate in the background" = "バックグラウンド生成";

+ 10 - 0
AIEmoji/ko.lproj/Localizable.strings

@@ -239,3 +239,13 @@
 "Anime Lite" = "애니메 라이트";
 "Anime Pro" = "애니메이션 프로";
 "AI Expand Photo" = "AI 확장 사진";
+
+"More" = "더";
+"Generation Failed" = "빌드 실패";
+"This task has expired" = "이 작업이 만료되었습니다";
+"Generate in the background" = "배경 생성";
+
+"More" = "더";
+"Generation Failed" = "빌드 실패";
+"This task has expired" = "이 작업이 만료되었습니다";
+"Generate in the background" = "배경 생성";

+ 5 - 0
AIEmoji/pt-BR.lproj/Localizable.strings

@@ -239,3 +239,8 @@
 "Anime Lite" = "Anime Lite";
 "Anime Pro" = "Anime Pro";
 "AI Expand Photo" = "Foto de expansão de IA";
+
+"More" = "Mais";
+"Generation Failed" = "Falha na geração";
+"This task has expired" = "Esta tarefa expirou";
+"Generate in the background" = "Geração de plano de fundo";

+ 5 - 0
AIEmoji/pt-PT.lproj/Localizable.strings

@@ -239,3 +239,8 @@
 "Anime Lite" = "Anime Lite";
 "Anime Pro" = "Anime Pro";
 "AI Expand Photo" = "Foto de expansão de IA";
+
+"More" = "Mais";
+"Generation Failed" = "Falha na geração";
+"This task has expired" = "Esta tarefa expirou";
+"Generate in the background" = "Geração de plano de fundo";

+ 5 - 0
AIEmoji/zh-Hans.lproj/Localizable.strings

@@ -239,3 +239,8 @@
 "Anime Lite" = "动漫精简版";
 "Anime Pro" = "动漫增强版";
 "AI Expand Photo" = "AI 扩图";
+
+"More" = "更多";
+"Generation Failed" = "生成失败";
+"This task has expired" = "此任务已过期";
+"Generate in the background" = "后台生成";

+ 5 - 0
AIEmoji/zh-Hant.lproj/Localizable.strings

@@ -231,3 +231,8 @@
 "Anime Lite" = "動漫精簡版";
 "Anime Pro" = "動漫增強版";
 "AI Expand Photo" = "AI 擴圖";
+
+"More" = "更多";
+"Generation Failed" = "生成失敗";
+"This task has expired" = "此任務已過期";
+"Generate in the background" = "後台生成";