diff --git a/changelog.md b/changelog.md index 9021420e6559039bd8427e7338813d869c222241..9f02742df1105c41fe8acdfc1d4a04403893ad4a 100644 --- a/changelog.md +++ b/changelog.md @@ -1,3 +1,6 @@ +## 1.0.20(2023-06-05) +- 修复 移动端 部分情况下 代码块的复制按钮,挡住内容的问题 +- 修复 微信小程序端 点击“复制按钮”无效的问题 ## 1.0.19(2023-06-05) - 新增 支持停止响应(终止接收ai返回的答案) - 新增 支持一键换答案(让ai重新回答一遍,得到新的答案) diff --git a/components/uni-ai-msg/uni-ai-msg.vue b/components/uni-ai-msg/uni-ai-msg.vue index 8862f0c116a9198d7da77c984f2e1c994ac2cfe7..70c5674f2735311d161429af0e8b310d8d5f783f 100644 --- a/components/uni-ai-msg/uni-ai-msg.vue +++ b/components/uni-ai-msg/uni-ai-msg.vue @@ -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 '
  • ' + item +'
  • ' }).join('') - html = '
      ' + html + '
    ' + html = '
      ' + html + '
    ' // 代码复制功能 codeDataList.push(str) - html = `复制` + html - return `
    ${html}
    `; + let htmlCode = `
    ` + // #ifndef MP-WEIXIN + htmlCode += `
    ` + htmlCode += `${lang} 复制代码 ` + htmlCode += `
    ` + // #endif + htmlCode += `
    ${html}
    `; + htmlCode += '
    ' + 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 } } @@ -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 */ diff --git a/package.json b/package.json index d81e92faea2544d52de0f88e8f981e17f2abc961..cd811997934e8e5bb016993b5caa56fb8c5da586 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "id": "uni-ai-chat", "name": "uni-ai-chat", - "version": "1.0.19", + "version": "1.0.20", "description": "基于uni-ai的聊天示例项目,支持流式、支持前文总结,云端一体", "main": "main.js", "scripts": {