Commit 3a77a9ff authored by Steven杜宇's avatar Steven杜宇

// AI

parent be2b5d11
...@@ -17,6 +17,7 @@ class YHAIRequestManager: NSObject { ...@@ -17,6 +17,7 @@ class YHAIRequestManager: NSObject {
static let subrobotConversationConfigKey = "subrobot_conversation_config_key" static let subrobotConversationConfigKey = "subrobot_conversation_config_key"
var sessionId: String = "" var sessionId: String = ""
var request: DataStreamRequest?
let prefix_id = "id:" let prefix_id = "id:"
let prefix_event = "event:" let prefix_event = "event:"
...@@ -73,7 +74,7 @@ class YHAIRequestManager: NSObject { ...@@ -73,7 +74,7 @@ class YHAIRequestManager: NSObject {
let headers = self.getCommonHeaders() let headers = self.getCommonHeaders()
// 发送 POST 请求 // 发送 POST 请求
AF.streamRequest(url, request = AF.streamRequest(url,
method: .post, method: .post,
headers: headers, headers: headers,
automaticallyCancelOnStreamError: false, automaticallyCancelOnStreamError: false,
...@@ -82,6 +83,7 @@ class YHAIRequestManager: NSObject { ...@@ -82,6 +83,7 @@ class YHAIRequestManager: NSObject {
request.httpBodyStream = httpBodyStream request.httpBodyStream = httpBodyStream
} }
}).responseStreamString { }).responseStreamString {
[weak self] stream in [weak self] stream in
guard let self = self else { return } guard let self = self else { return }
......
...@@ -304,5 +304,3 @@ class YHAIImageInfo: SmartCodable { ...@@ -304,5 +304,3 @@ class YHAIImageInfo: SmartCodable {
...@@ -12,6 +12,7 @@ import SDWebImage ...@@ -12,6 +12,7 @@ import SDWebImage
class YHAICardItemView: UIView { class YHAICardItemView: UIView {
var updateBlock:(()->())? var updateBlock:(()->())?
var evaluationResultCallback: ((Dictionary<String, Any>)->())?
var cardModel = YHAIListItemModel() { var cardModel = YHAIListItemModel() {
didSet { didSet {
...@@ -132,6 +133,7 @@ class YHAICardItemView: UIView { ...@@ -132,6 +133,7 @@ class YHAICardItemView: UIView {
YHAIJumpPageTool.jumpPageWithType(mode: cardModel.redirectMode, path: cardModel.redirectPath) { YHAIJumpPageTool.jumpPageWithType(mode: cardModel.redirectMode, path: cardModel.redirectPath) {
dict in dict in
self.evaluationResultCallback?(dict)
} }
} }
} }
...@@ -37,6 +37,7 @@ class YHAIJumpPageTool { ...@@ -37,6 +37,7 @@ class YHAIJumpPageTool {
let vc = YHH5WebViewVC() let vc = YHH5WebViewVC()
vc.url = path vc.url = path
vc.evaluationResultCallback = block
UIViewController.current?.navigationController?.pushViewController(vc, animated: true) UIViewController.current?.navigationController?.pushViewController(vc, animated: true)
} }
} }
...@@ -73,7 +74,7 @@ class YHCardMessageCell: UITableViewCell { ...@@ -73,7 +74,7 @@ class YHCardMessageCell: UITableViewCell {
static let cellReuseIdentifier = "YHCardMessageCell" static let cellReuseIdentifier = "YHCardMessageCell"
var evaluationResultCallback: ((Dictionary<String, Any>)->()) = { dic in } var evaluationResultCallback: ((Dictionary<String, Any>)->())?
var cardListModel = YHAIListInfoModel() { var cardListModel = YHAIListInfoModel() {
didSet { didSet {
...@@ -91,6 +92,11 @@ class YHCardMessageCell: UITableViewCell { ...@@ -91,6 +92,11 @@ class YHCardMessageCell: UITableViewCell {
guard let self = self else { return } guard let self = self else { return }
self.updateBlock?() self.updateBlock?()
} }
productView.evaluationResultCallback = {
[weak self] dict in
guard let self = self else { return }
self.evaluationResultCallback?(dict)
}
productView.cardModel = item productView.cardModel = item
listView.addSubview(productView) listView.addSubview(productView)
productView.snp.makeConstraints { make in productView.snp.makeConstraints { make in
...@@ -172,7 +178,7 @@ class YHCardMessageCell: UITableViewCell { ...@@ -172,7 +178,7 @@ class YHCardMessageCell: UITableViewCell {
} }
YHAIJumpPageTool.jumpPageWithType(type, mode: cardListModel.redirectMode, path: cardListModel.redirectPath) { YHAIJumpPageTool.jumpPageWithType(type, mode: cardListModel.redirectMode, path: cardListModel.redirectPath) {
dict in dict in
self.evaluationResultCallback(dict) self.evaluationResultCallback?(dict)
} }
} }
......
...@@ -520,6 +520,7 @@ extension YHH5WebViewVC { ...@@ -520,6 +520,7 @@ extension YHH5WebViewVC {
printLog("\(dic)") printLog("\(dic)")
} }
self.evaluationResultCallback?(dic) self.evaluationResultCallback?(dic)
self.navigationController?.popViewController(animated: false)
} }
//22、禁用全局手势返回 //22、禁用全局手势返回
...@@ -534,8 +535,6 @@ extension YHH5WebViewVC { ...@@ -534,8 +535,6 @@ extension YHH5WebViewVC {
} }
} }
//20、导航栏上是否展示title //20、导航栏上是否展示title
func hideNavigationTitleSyn(_ tag : String) { func hideNavigationTitleSyn(_ tag : String) {
if tag.contains("0") { if tag.contains("0") {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment