|
@@ -23,6 +23,25 @@ class TSTextMessageContentCell: TSMessageContentCell {
|
|
|
return activityIndicator
|
|
|
}()
|
|
|
|
|
|
+
|
|
|
+
|
|
|
+ lazy var refreshBtn: UIButton = {
|
|
|
+ let refresh = UIButton.createButton(image: UIImage(named: "aichat_refresh")) { [weak self] in
|
|
|
+ guard let self = self else { return }
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+ return refresh
|
|
|
+ }()
|
|
|
+
|
|
|
+ lazy var bottomToolView: UIView = {
|
|
|
+ bottomToolView = UIView()
|
|
|
+ bottomToolView.isHidden = true
|
|
|
+ return bottomToolView
|
|
|
+ }()
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
override func prepareForReuse() {
|
|
|
super.prepareForReuse()
|
|
|
}
|
|
@@ -44,6 +63,16 @@ class TSTextMessageContentCell: TSMessageContentCell {
|
|
|
make.width.height.equalTo(24.0)
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ bottomToolView.addSubview(refreshBtn)
|
|
|
+ refreshBtn.snp.makeConstraints { make in
|
|
|
+ make.left.equalTo(12)
|
|
|
+ make.bottom.equalTo(-9)
|
|
|
+ make.width.height.equalTo(20)
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
|
|
|
override func configure(
|
|
@@ -92,34 +121,39 @@ class TSTextMessageContentCell: TSMessageContentCell {
|
|
|
messageLabel.text = text
|
|
|
// debugPrint("text赋值")
|
|
|
case .attributedText(let text):
|
|
|
+ messageLabel.text = text.string
|
|
|
messageLabel.attributedText = text
|
|
|
// debugPrint("attributedText赋值")
|
|
|
+
|
|
|
+// extractAndPrintSubstring(from: messageLabel.text ?? "", to: text.string)
|
|
|
default:
|
|
|
break
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
-// func extractAndPrintSubstring(from sourceString: String, to targetString: String) {
|
|
|
-// // 查找 sourceString 在 targetString 中的结束位置
|
|
|
-// if let range = targetString.range(of: sourceString) {
|
|
|
-// // 获取 sourceString 在 targetString 中的结束位置
|
|
|
-// let startIdx = range.upperBound
|
|
|
-// // 提取从该位置到 targetString 结束的子字符串
|
|
|
-// let extractedSubstring = targetString[startIdx...]
|
|
|
-//
|
|
|
-// // 将提取的子字符串逐个字符输出
|
|
|
-// for character in extractedSubstring {
|
|
|
+ func extractAndPrintSubstring(from sourceString: String, to targetString: String) {
|
|
|
+ // 查找 sourceString 在 targetString 中的结束位置
|
|
|
+ if let range = targetString.range(of: sourceString) {
|
|
|
+ // 获取 sourceString 在 targetString 中的结束位置
|
|
|
+ let startIdx = range.upperBound
|
|
|
+ // 提取从该位置到 targetString 结束的子字符串
|
|
|
+ let extractedSubstring = targetString[startIdx...]
|
|
|
+
|
|
|
+ // 将提取的子字符串逐个字符输出
|
|
|
+ var string = sourceString
|
|
|
+ for character in extractedSubstring {
|
|
|
// print(character)
|
|
|
-// messageLabel.text = (messageLabel.text ?? "") + String(character)
|
|
|
-// messageLabel.attributedText = SwiftyMarkdown(string: messageLabel.text ?? "").attributedString()
|
|
|
-// }
|
|
|
-// } else {
|
|
|
-// print("未找到 sourceString")
|
|
|
-// messageLabel.text = targetString
|
|
|
-// messageLabel.attributedText = SwiftyMarkdown(string: targetString).attributedString()
|
|
|
-// }
|
|
|
-// }
|
|
|
+ string = string + String(character)
|
|
|
+ messageLabel.text = string
|
|
|
+ messageLabel.attributedText = kMDAttributedString(text: string)
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ print("未找到 sourceString")
|
|
|
+ messageLabel.text = targetString
|
|
|
+ messageLabel.attributedText = kMDAttributedString(text: targetString)
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
func startAnimating() {
|
|
|
activityIndicator.isHidden = false
|