From a4c13480bab80d7089e46c4b17d7cf48d7e2a6ca Mon Sep 17 00:00:00 2001 From: DCloud__JSON Date: Mon, 5 Jun 2023 21:11:40 +0800 Subject: [PATCH] 1.0.20 --- changelog.md | 3 +++ components/uni-ai-msg/uni-ai-msg.vue | 32 ++++++++++++++++++---------- package.json | 2 +- 3 files changed, 25 insertions(+), 12 deletions(-) diff --git a/changelog.md b/changelog.md index 9021420..9f02742 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 8862f0c..70c5674 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 d81e92f..cd81199 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": { -- GitLab