fix: AI客服回复内容格式化(换行+加粗+列表)

This commit is contained in:
2026-10-12 17:12:16 +08:00
parent 6a3e44b247
commit f3a1b01a10
8 changed files with 6528 additions and 222 deletions
+6151
View File
File diff suppressed because it is too large Load Diff
+2 -1
View File
@@ -31,7 +31,8 @@
"js-md5": "^0.8.3", "js-md5": "^0.8.3",
"mp-html": "^2.5.1", "mp-html": "^2.5.1",
"normalize-wheel": "^1.0.1", "normalize-wheel": "^1.0.1",
"pdfjs-dist": "2.5.207", "pdfh5": "^2.0.6",
"pdfjs-dist": "^2.5.207",
"request": "^2.88.2", "request": "^2.88.2",
"resize-observer-polyfill": "^1.5.1", "resize-observer-polyfill": "^1.5.1",
"sortablejs": "^1.15.6", "sortablejs": "^1.15.6",
+14 -5
View File
@@ -25,7 +25,7 @@
<view v-for="(msg, i) in messages" :key="i" :id="'msg' + i" <view v-for="(msg, i) in messages" :key="i" :id="'msg' + i"
:class="['msg-item', msg.role === 'user' ? 'right' : 'left']"> :class="['msg-item', msg.role === 'user' ? 'right' : 'left']">
<view v-if="msg.role !== 'user'" class="avatar">🤖</view> <view v-if="msg.role !== 'user'" class="avatar">🤖</view>
<view class="bubble" v-html="msg.content"></view> <view class="bubble" v-html="formatContent(msg.content)"></view>
</view> </view>
<!-- 加载中 --> <!-- 加载中 -->
@@ -61,6 +61,14 @@ export default {
this.msgListHeight = sys.windowHeight - 88 - 56; this.msgListHeight = sys.windowHeight - 88 - 56;
}, },
methods: { methods: {
formatContent(text) {
if (!text) return '';
let html = text.replace(/\*\*(.*?)\*\*/g, '<strong>$1</strong>');
html = html.replace(/^[\-\•]\s+(.+)$/gm, '<div style="padding-left:12px;">• $1</div>');
html = html.replace(/^(\d+)\.\s+(.+)$/gm, '<div style="padding-left:12px;">$1. $2</div>');
html = html.replace(/\n/g, '<br>');
return html;
},
quickSend(text) { quickSend(text) {
this.inputText = text; this.inputText = text;
this.send(); this.send();
@@ -74,10 +82,11 @@ export default {
this.scrollToBottom(); this.scrollToBottom();
try { try {
const res = await this.vk.callFunction({ const res = await this.vk.callFunction({
url: 'client/ai/pub/chat', url: 'client/ai/pub/chat',
data: { message: msg, conversation_id: this.conversationId } data: { message: msg, bot_id: '7680345813062680618' }
}); });
if (res.data.conversation_id) this.conversationId = res.data.conversation_id; if (res.data.conversation_id) this.conversationId = res.data.conversation_id;
this.messages.push({ role: 'assistant', content: res.data.answer }); this.messages.push({ role: 'assistant', content: res.data.answer });
} catch (e) { } catch (e) {
+80 -12
View File
@@ -1,15 +1,83 @@
{ {
"id": "piaoyi-editor", "id": "piaoyi-editor",
"name": "多功能富文本编辑器", "name": "多功能富文本编辑器",
"displayName": "多功能富文本编辑器", "displayName": "多功能富文本编辑器",
"version": "1.1.0", "version": "1.1.0",
"description": "富文本编辑器,内置上传图片以及更改颜色, 多样化等功能", "description": "富文本编辑器,内置上传图片以及更改颜色, 多样化等功能",
"keywords": [ "keywords": [
"富文本编辑器", "富文本编辑器",
"上传图片", "上传图片",
"字体颜色" "字体颜色"
], ],
"dcloudext": { "dcloudext": {
"type": "component-vue" "type": "component-vue",
"darkmode": "-",
"i18n": "-",
"widescreen": "-"
},
"engines": {
"HBuilderX": "^3.1.0",
"uni-app": "^3.1.0",
"uni-app-x": "^3.1.0"
},
"uni_modules": {
"dependencies": [],
"encrypt": [],
"platforms": {
"cloud": {
"tcb": "-",
"aliyun": "-",
"alipay": "-"
},
"client": {
"uni-app": {
"vue": {
"vue2": "-",
"vue3": "-"
},
"web": {
"safari": "-",
"chrome": "-"
},
"app": {
"vue": "-",
"nvue": "-",
"android": "-",
"ios": "-",
"harmony": "-"
},
"mp": {
"weixin": "-",
"alipay": "-",
"toutiao": "-",
"baidu": "-",
"kuaishou": "-",
"jd": "-",
"harmony": "-",
"qq": "-",
"lark": "-",
"xhs": "-"
},
"quickapp": {
"huawei": "-",
"union": "-"
}
},
"uni-app-x": {
"web": {
"safari": "-",
"chrome": "-"
},
"app": {
"android": "-",
"ios": "-",
"harmony": "-"
},
"mp": {
"weixin": "-"
}
}
}
} }
}
} }
+57 -37
View File
@@ -6,12 +6,14 @@
"keywords": [ "keywords": [
"配置", "配置",
"配置中心" "配置中心"
], ],
"repository": "", "repository": "",
"engines": { "engines": {
"HBuilderX": "^3.1.0" "HBuilderX": "^3.1.0",
"uni-app": "^3.1.0",
"uni-app-x": "^3.1.0"
}, },
"dcloudext": { "dcloudext": {
"sale": { "sale": {
"regular": { "regular": {
"price": "0.00" "price": "0.00"
@@ -29,7 +31,10 @@
"permissions": "无" "permissions": "无"
}, },
"npmurl": "", "npmurl": "",
"type": "unicloud-template-function" "type": "unicloud-template-function",
"darkmode": "-",
"i18n": "-",
"widescreen": "-"
}, },
"directories": { "directories": {
"example": "../../../scripts/dist" "example": "../../../scripts/dist"
@@ -39,43 +44,58 @@
"encrypt": [], "encrypt": [],
"platforms": { "platforms": {
"cloud": { "cloud": {
"tcb": "y", "tcb": "√",
"aliyun": "y" "aliyun": "√"
}, },
"client": { "client": {
"App": { "uni-app": {
"app-vue": "u", "vue": {
"app-nvue": "u" "vue2": "-",
"vue3": "-"
},
"web": {
"safari": "-",
"chrome": "-"
},
"app": {
"vue": "-",
"nvue": "-",
"android": "-",
"ios": "-",
"harmony": "-"
},
"mp": {
"weixin": "-",
"alipay": "-",
"toutiao": "-",
"baidu": "-",
"kuaishou": "-",
"jd": "-",
"harmony": "-",
"qq": "-",
"lark": "-",
"xhs": "-"
},
"quickapp": {
"huawei": "-",
"union": "-"
}
}, },
"H5-mobile": { "uni-app-x": {
"Safari": "u", "web": {
"Android Browser": "u", "safari": "-",
"微信浏览器(Android)": "u", "chrome": "-"
"QQ浏览器(Android)": "u" },
}, "app": {
"H5-pc": { "android": "-",
"Chrome": "u", "ios": "-",
"IE": "u", "harmony": "-"
"Edge": "u", },
"Firefox": "u", "mp": {
"Safari": "u" "weixin": "-"
}, }
"小程序": {
"微信": "u",
"阿里": "u",
"百度": "u",
"字节跳动": "u",
"QQ": "u"
},
"快应用": {
"华为": "u",
"联盟": "u"
},
"Vue": {
"vue2": "y",
"vue3": "u"
} }
} }
} }
} }
} }
+59 -41
View File
@@ -9,12 +9,14 @@
"用户管理", "用户管理",
"用户中心", "用户中心",
"短信验证码" "短信验证码"
], ],
"repository": "https://gitee.com/dcloud/uni-id.git", "repository": "https://gitee.com/dcloud/uni-id.git",
"engines": { "engines": {
"HBuilderX": "^3.1.0" "HBuilderX": "^3.1.0",
"uni-app": "^3.1.0",
"uni-app-x": "^3.1.0"
}, },
"dcloudext": { "dcloudext": {
"sale": { "sale": {
"regular": { "regular": {
"price": "0.00" "price": "0.00"
@@ -32,52 +34,68 @@
"permissions": "无" "permissions": "无"
}, },
"npmurl": "", "npmurl": "",
"type": "unicloud-template-function" "type": "unicloud-template-function",
"darkmode": "-",
"i18n": "-",
"widescreen": "-"
}, },
"uni_modules": { "uni_modules": {
"dependencies": ["uni-config-center"], "dependencies": [
"uni-config-center"
],
"encrypt": [], "encrypt": [],
"platforms": { "platforms": {
"cloud": { "cloud": {
"tcb": "y", "tcb": "√",
"aliyun": "y" "aliyun": "√"
}, },
"client": { "client": {
"App": { "uni-app": {
"app-vue": "u", "vue": {
"app-nvue": "u" "vue2": "-",
"vue3": "-"
},
"web": {
"safari": "-",
"chrome": "-"
},
"app": {
"vue": "-",
"nvue": "-",
"android": "-",
"ios": "-",
"harmony": "-"
},
"mp": {
"weixin": "-",
"alipay": "-",
"toutiao": "-",
"baidu": "-",
"kuaishou": "-",
"jd": "-",
"harmony": "-",
"qq": "-",
"lark": "-",
"xhs": "-"
},
"quickapp": {
"huawei": "-",
"union": "-"
}
}, },
"H5-mobile": { "uni-app-x": {
"Safari": "u", "web": {
"Android Browser": "u", "safari": "-",
"微信浏览器(Android)": "u", "chrome": "-"
"QQ浏览器(Android)": "u" },
}, "app": {
"H5-pc": { "android": "-",
"Chrome": "u", "ios": "-",
"IE": "u", "harmony": "-"
"Edge": "u", },
"Firefox": "u", "mp": {
"Safari": "u" "weixin": "-"
}, }
"小程序": {
"微信": "u",
"阿里": "u",
"百度": "u",
"字节跳动": "u",
"QQ": "u",
"钉钉": "u",
"快手": "u",
"飞书": "u",
"京东": "u"
},
"快应用": {
"华为": "u",
"联盟": "u"
},
"Vue": {
"vue2": "y",
"vue3": "u"
} }
} }
} }
+103 -83
View File
@@ -1,84 +1,104 @@
{ {
"id": "uview-ui", "id": "uview-ui",
"name": "uview-ui", "name": "uview-ui",
"displayName": "uView2.0重磅发布,利剑出鞘,一统江湖", "displayName": "uView2.0重磅发布,利剑出鞘,一统江湖",
"version": "2.0.36", "version": "2.0.36",
"description": "uView UI已完美兼容nvue,全面的组件和便捷的工具会让您信手拈来,如鱼得水", "description": "uView UI已完美兼容nvue,全面的组件和便捷的工具会让您信手拈来,如鱼得水",
"keywords": [ "keywords": [
"uview", "uview",
"uview", "uview",
"ui", "ui",
"ui", "ui",
"uni-app", "uni-app",
"uni-app", "uni-app",
"ui" "ui"
], ],
"repository": "https://github.com/umicro/uView2.0", "repository": "https://github.com/umicro/uView2.0",
"engines": { "engines": {
"HBuilderX": "^3.1.0" "HBuilderX": "^3.1.0",
}, "uni-app": "^3.1.0",
"dcloudext": { "uni-app-x": "^3.1.0"
"sale": { },
"regular": { "dcloudext": {
"price": "0.00" "sale": {
}, "regular": {
"sourcecode": { "price": "0.00"
"price": "0.00" },
} "sourcecode": {
}, "price": "0.00"
"contact": { }
"qq": "1416956117" },
}, "contact": {
"declaration": { "qq": "1416956117"
"ads": "无", },
"data": "无", "declaration": {
"permissions": "无" "ads": "无",
}, "data": "无",
"npmurl": "https://www.npmjs.com/package/uview-ui", "permissions": "无"
"type": "component-vue" },
}, "npmurl": "https://www.npmjs.com/package/uview-ui",
"uni_modules": { "type": "component-vue",
"dependencies": [], "darkmode": "-",
"encrypt": [], "i18n": "-",
"platforms": { "widescreen": "-"
"cloud": { },
"tcb": "y", "uni_modules": {
"aliyun": "y" "dependencies": [],
}, "encrypt": [],
"client": { "platforms": {
"Vue": { "cloud": {
"vue2": "y", "tcb": "√",
"vue3": "n" "aliyun": "√"
}, },
"App": { "client": {
"app-vue": "y", "uni-app": {
"app-nvue": "y" "vue": {
}, "vue2": "-",
"H5-mobile": { "vue3": "-"
"Safari": "y", },
"Android Browser": "y", "web": {
"微信浏览器(Android)": "y", "safari": "-",
"QQ浏览器(Android)": "y" "chrome": "-"
}, },
"H5-pc": { "app": {
"Chrome": "y", "vue": "-",
"IE": "y", "nvue": "-",
"Edge": "y", "android": "-",
"Firefox": "y", "ios": "-",
"Safari": "y" "harmony": "-"
}, },
"小程序": { "mp": {
"微信": "y", "weixin": "-",
"阿里": "y", "alipay": "-",
"百度": "y", "toutiao": "-",
"字节跳动": "y", "baidu": "-",
"QQ": "y" "kuaishou": "-",
}, "jd": "-",
"快应用": { "harmony": "-",
"华为": "y", "qq": "-",
"联盟": "y" "lark": "-",
} "xhs": "-"
} },
} "quickapp": {
} "huawei": "-",
} "union": "-"
}
},
"uni-app-x": {
"web": {
"safari": "-",
"chrome": "-"
},
"app": {
"android": "-",
"ios": "-",
"harmony": "-"
},
"mp": {
"weixin": "-"
}
}
}
}
}
}
+62 -43
View File
@@ -9,13 +9,15 @@
"vk云开发", "vk云开发",
"内置uni-id、uview、数据库baseDao", "内置uni-id、uview、数据库baseDao",
"内置众多API、工具包" "内置众多API、工具包"
], ],
"author": "VK", "author": "VK",
"repository": "https://gitee.com/vk-uni/vk-uni-cloud-router", "repository": "https://gitee.com/vk-uni/vk-uni-cloud-router",
"engines": { "engines": {
"HBuilderX": "^3.1.0" "HBuilderX": "^3.1.0",
"uni-app": "^3.1.0",
"uni-app-x": "^3.1.0"
}, },
"dcloudext": { "dcloudext": {
"sale": { "sale": {
"regular": { "regular": {
"price": "0.00" "price": "0.00"
@@ -33,54 +35,71 @@
"permissions": "无" "permissions": "无"
}, },
"npmurl": "https://vkdoc.fsq.pub/", "npmurl": "https://vkdoc.fsq.pub/",
"type": "unicloud-template-function" "type": "unicloud-template-function",
"darkmode": "-",
"i18n": "-",
"widescreen": "-"
}, },
"uni_modules": { "uni_modules": {
"dependencies": ["uni-config-center","uni-id"], "dependencies": [
"uni-config-center",
"uni-id"
],
"encrypt": [], "encrypt": [],
"platforms": { "platforms": {
"cloud": { "cloud": {
"tcb": "y", "tcb": "√",
"aliyun": "y" "aliyun": "√"
}, },
"client": { "client": {
"App": { "uni-app": {
"app-vue": "y", "vue": {
"app-nvue": "y" "vue2": "-",
"vue3": "-"
},
"web": {
"safari": "-",
"chrome": "-"
},
"app": {
"vue": "-",
"nvue": "-",
"android": "-",
"ios": "-",
"harmony": "-"
},
"mp": {
"weixin": "-",
"alipay": "-",
"toutiao": "-",
"baidu": "-",
"kuaishou": "-",
"jd": "-",
"harmony": "-",
"qq": "-",
"lark": "-",
"xhs": "-"
},
"quickapp": {
"huawei": "-",
"union": "-"
}
}, },
"H5-mobile": { "uni-app-x": {
"Safari": "y", "web": {
"Android Browser": "y", "safari": "-",
"微信浏览器(Android)": "y", "chrome": "-"
"QQ浏览器(Android)": "y" },
}, "app": {
"H5-pc": { "android": "-",
"Chrome": "y", "ios": "-",
"IE": "y", "harmony": "-"
"Edge": "y", },
"Firefox": "y", "mp": {
"Safari": "y" "weixin": "-"
}, }
"小程序": {
"微信": "y",
"阿里": "y",
"百度": "y",
"字节跳动": "y",
"QQ": "y",
"钉钉": "u",
"快手": "u",
"飞书": "u",
"京东": "u"
},
"快应用": {
"华为": "u",
"联盟": "u"
},
"Vue": {
"vue2": "y",
"vue3": "u"
} }
} }
} }
} }
} }