perf: 优化预览消息

This commit is contained in:
kuaifan 2025-07-18 13:05:27 +08:00
parent 937e7ba154
commit 1a841c4b5d
2 changed files with 20 additions and 3 deletions

View File

@ -665,8 +665,16 @@ class WebSocketDialogMsg extends AbstractModel
if (preg_match('/:::\s*reasoning\s+/', $text)) {
return Doo::translate('思考中...');
}
$text = Base::markdown2html($text);
$text = self::previewConvertTaskList($text);
$title = '';
if (preg_match('/^#{1,2}\s+(.+)/m', $text, $matches)) {
$title = trim($matches[1]);
}
if ($title) {
$text = $title;
} else {
$text = Base::markdown2html($text);
$text = self::previewConvertTaskList($text);
}
}
$text = preg_replace("/<img\s+class=\"emoticon\"[^>]*?alt=\"(\S+)\"[^>]*?>/", "[$1]", $text);
$text = preg_replace("/<img\s+class=\"emoticon\"[^>]*?>/", "[" . Doo::translate('动画表情') . "]", $text);

View File

@ -250,7 +250,16 @@ import {convertLocalResourcePath} from "../components/Replace/utils";
if (/:::\s*reasoning\s+/.test(text)) {
return $A.L('思考中...')
}
text = MarkdownPreview(text);
let titleText = '';
const titleMatch = text.match(/^#{1,2}\s+(.+)/m);
if (titleMatch) {
titleText = titleMatch[1].trim();
}
if (titleText) {
text = titleText;
} else {
text = MarkdownPreview(text);
}
}
//
text = text.replace(/<img\s+class="emoticon"[^>]*?alt="(\S+)"[^>]*?>/g, "[$1]")