fix: String() conversion for block.blockContent, avoid ES2019 methods
blockContent from QVariant needs explicit String() conversion. Use charAt/indexOf instead of startsWith (ES6 compat).
This commit is contained in:
parent
38df1a8e32
commit
c2ff88e8e6
|
|
@ -622,7 +622,7 @@ ApplicationWindow {
|
|||
Text {
|
||||
id: callText
|
||||
Layout.fillWidth: true
|
||||
text: visible ? chatModel.prettyJson(block.blockContent || "") : ""
|
||||
text: visible ? chatModel.prettyJson(String(block.blockContent || "")) : ""
|
||||
textFormat: Text.RichText
|
||||
wrapMode: Text.Wrap
|
||||
font.family: "monospace"
|
||||
|
|
@ -653,12 +653,12 @@ ApplicationWindow {
|
|||
Layout.fillWidth: true
|
||||
text: {
|
||||
if (!visible) return ""
|
||||
let content = block.blockContent || ""
|
||||
let content = String(block.blockContent || "")
|
||||
if (!content) return ""
|
||||
let trimmed = content.trim()
|
||||
if (trimmed.startsWith("{") || trimmed.startsWith("["))
|
||||
if (trimmed.charAt(0) === '{' || trimmed.charAt(0) === '[')
|
||||
return chatModel.prettyJson(content)
|
||||
if (trimmed.startsWith("---") || trimmed.startsWith("diff "))
|
||||
if (trimmed.indexOf("---") === 0 || trimmed.indexOf("diff ") === 0)
|
||||
return chatModel.highlightedHtml(content, "diff")
|
||||
return content.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/\n/g, '<br>')
|
||||
}
|
||||
|
|
|
|||
Reference in New Issue