From 1a841c4b5dc53bb3b9f6aabb26c2712ecc4f9964 Mon Sep 17 00:00:00 2001 From: kuaifan Date: Fri, 18 Jul 2025 13:05:27 +0800 Subject: [PATCH] =?UTF-8?q?perf:=20=E4=BC=98=E5=8C=96=E9=A2=84=E8=A7=88?= =?UTF-8?q?=E6=B6=88=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Models/WebSocketDialogMsg.php | 12 ++++++++++-- resources/assets/js/functions/web.js | 11 ++++++++++- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/app/Models/WebSocketDialogMsg.php b/app/Models/WebSocketDialogMsg.php index 15b3041d3..c50b44fd6 100644 --- a/app/Models/WebSocketDialogMsg.php +++ b/app/Models/WebSocketDialogMsg.php @@ -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("/]*?alt=\"(\S+)\"[^>]*?>/", "[$1]", $text); $text = preg_replace("/]*?>/", "[" . Doo::translate('动画表情') . "]", $text); diff --git a/resources/assets/js/functions/web.js b/resources/assets/js/functions/web.js index 27b8193fc..7b2e995f3 100755 --- a/resources/assets/js/functions/web.js +++ b/resources/assets/js/functions/web.js @@ -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(/]*?alt="(\S+)"[^>]*?>/g, "[$1]")