提交 e683dc17 编写于 作者: DCloud_JSON's avatar DCloud_JSON

1.0.20

上级 26aa2ef8
## 1.0.20(2023-06-05)
- 修复 移动端 部分情况下 代码块的复制按钮,挡住内容的问题
- 修复 微信小程序端 点击“复制按钮”无效的问题
## 1.0.19(2023-06-05)
- 新增 支持停止响应(终止接收ai返回的答案)
- 新增 支持一键换答案(让ai重新回答一遍,得到新的答案)
......
......@@ -84,6 +84,7 @@
// console.log('err',err);
preCode = markdownIt.utils.escapeHtml(str);
}
// 以换行进行分割
const lines = preCode.split(/\n/).slice(0, -1)
......@@ -95,12 +96,19 @@
}
return '<li><span class="line-num" data-line="' + (index + 1) + '"></span>' + item +'</li>'
}).join('')
html = '<ol>' + html + '</ol>'
html = '<ol style="padding: 0px 30px;">' + html + '</ol>'
// 代码复制功能
codeDataList.push(str)
html = `<a class="copy-btn" code-data-index="${codeDataList.length - 1}" style="float:right;cursor: pointer;">复制</a>` + html
return `<pre class="hljs" style="padding: 5px 8px;margin: 5px 0;overflow: auto;display: block;"><code>${html}</code></pre>`;
let htmlCode = `<div style="background:#0d1117;margin-top: 5px;color: #888;padding:5px 0;border-radius: 5px;">`
// #ifndef MP-WEIXIN
htmlCode += `<div style="text-align: end;font-size: 12px;">`
htmlCode += `${lang}<a class="copy-btn" code-data-index="${codeDataList.length - 1}" style="cursor: pointer;"> 复制代码 </a>`
htmlCode += `</div>`
// #endif
htmlCode += `<pre class="hljs" style="padding:0 8px;margin-bottom:5px;overflow: auto;display: block;border-radius: 5px;"><code>${html}</code></pre>`;
htmlCode += '</div>'
return htmlCode
}
})
......@@ -194,12 +202,12 @@
}
},
trOnclick(e){
// console.log(e);
console.log(e);
let {attrs} = e.detail.node
// console.log({attrs});
console.log({attrs});
let {"code-data-index":codeDataIndex,"class":className} = attrs
if(className == 'copy-btn'){
// console.log('codeDataList[codeDataIndex]',codeDataList[codeDataIndex]);
console.log('codeDataList[codeDataIndex]',codeDataList[codeDataIndex]);
uni.setClipboardData({
data:codeDataList[codeDataIndex],
showToast:false,
......@@ -218,7 +226,6 @@
retriesSendMsg(){
this.$emit('retriesSendMsg')
},
// #ifdef H5
// 复制文本内容到系统剪切板
copy() {
uni.setClipboardData({
......@@ -231,10 +238,7 @@
});
}
})
// 设置悬浮的复制按钮的坐标值,使其隐藏
this.left = "-100px"
}
// #endif
}
}
</script>
......@@ -386,7 +390,13 @@
.create_time-box {
margin-top: 15px;
justify-content: center;
}
}
/* #ifdef H5 */
a.copy-btn:hover {
color: #259939;
}
/* #endif */
/* #ifndef VUE3 && APP-PLUS */
......
{
"id": "uni-ai-chat",
"name": "uni-ai-chat",
"version": "1.0.19",
"version": "1.0.20",
"description": "基于uni-ai的聊天示例项目,支持流式、支持前文总结,云端一体",
"main": "main.js",
"scripts": {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册