|
@@ -48,50 +48,50 @@ class TSGenneralPicVM {
|
|
|
var gennerateType:TSGennerateType = .poster
|
|
|
var generatingProgress = 0
|
|
|
|
|
|
- //模拟数据
|
|
|
- func creatImageEmoji(text:String) {
|
|
|
- stateDatauPblished = (.start,nil)
|
|
|
- stateDatauPblished = (.progressString(generating(progress: 0.0)),nil)
|
|
|
-
|
|
|
- kDelayOnMainThread(0.2) {
|
|
|
- self.stateDatauPblished = (.progressString(self.generating(progress: 0.5)),nil)
|
|
|
- }
|
|
|
-
|
|
|
- kDelayOnMainThread(1.0) {
|
|
|
- if Bool.random() {
|
|
|
- let infoModel = TSActionInfoModel(JSON: self.gennerateType == .poster ? actionInfoDictPoster : actionInfoDictPhoto)
|
|
|
- self.stateDatauPblished = (.success(nil),infoModel)
|
|
|
- }else{
|
|
|
- self.stateDatauPblished = (.failed("error?.localizedDescription"),nil)
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
-// //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)
|
|
|
-// }
|
|
|
+//
|
|
|
+// kDelayOnMainThread(0.2) {
|
|
|
+// self.stateDatauPblished = (.progressString(self.generating(progress: 0.5)),nil)
|
|
|
+// }
|
|
|
+//
|
|
|
+// kDelayOnMainThread(1.0) {
|
|
|
+// if Bool.random() {
|
|
|
+// let infoModel = TSActionInfoModel(JSON: self.gennerateType == .poster ? actionInfoDictPoster : actionInfoDictPhoto)
|
|
|
+// self.stateDatauPblished = (.success(nil),infoModel)
|
|
|
// }else{
|
|
|
-// self.stateDatauPblished = (.failed(error?.localizedDescription ?? ""),nil)
|
|
|
+// self.stateDatauPblished = (.failed("error?.localizedDescription"),nil)
|
|
|
// }
|
|
|
// }
|
|
|
// }
|
|
|
|
|
|
+ //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)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
func getActionInfo(action_id:Int){
|
|
|
queryRequest = TSNetworkShared.get(urlType: .actionInfo,parameters: ["action_id":action_id]) { [weak self] data,error in
|
|
|
guard let self = self else { return }
|