diff --git a/src/views/AI-new/components/message.vue b/src/views/AI-new/components/message.vue index 6a5d6f3..6b9aa86 100644 --- a/src/views/AI-new/components/message.vue +++ b/src/views/AI-new/components/message.vue @@ -14,14 +14,13 @@ {{ message.text ? '思考完成' : '思考中...' }} - +

-

+

@@ -51,7 +50,7 @@ import markdownItKatex from 'markdown-it-katex' const md = new MarkdownIt({ html: true, linkify: true, - typographer: true, + typographer: true }).use(markdownItKatex) export default { @@ -60,21 +59,21 @@ export default { props: { messagesList: { type: Array, - default: () => [], + default: () => [] }, thinkOk: { type: Boolean, - default: false, + default: false }, isDeep: { type: Boolean, - default: false, - }, + default: false + } }, data() { return { md, - primaryColor: '#57a6fc', + primaryColor: '#57a6fc' } }, methods: { @@ -85,23 +84,24 @@ export default { this.$emit('setProductName', e) }, filterVisible(message) { - // 捕获 不包含 < 的后置标签 ( .*>) - let _text = message.text.replace(/(?/g, '') - // 把 未闭合的标签替换成空白 - _text = _text.replace(/<\/\w*$/g, '') - return _text if (!message.text.startsWith('<')) { - return message.text + let text = message.text + // 如果开头是中文,直接返回 + if (new RegExp('^[\u4e00-\u9fa5]+', 'g').test(text)) return text + + // 捕获 不包含 < 的后置标签 span> /span> a + text = text.replace(/^[\/]?[a-zA-z0-9]+[]+/g, '') + // 尝试匹配 标签 + text = text.replace(/^<\/\w+>/g, '') + // 尝试把 ([^<]*)(?:<\/text>)?/.exec(message.text) let text = match ? match[1] : '' - // 捕获 不包含 < 的后置标签 ( .*>) - text = text.replace(/(?/g, '') - // 把 未闭合的标签替换成空白 - text = text.replace(/<\/\w*$/g, '') - console.log(text); - return text }, showThink(message) { @@ -119,7 +119,7 @@ export default { } // 触发父组件的更新事件 this.$emit('update-message', { ...message }) - }, + } }, mounted() { window.md = md