diff --git a/changelog.md b/changelog.md
index 1fec892d8071876bc91494650631bcd626ee32cd..1a5ee0a67ae794bdbc69e077703de56070a667db 100644
--- a/changelog.md
+++ b/changelog.md
@@ -1,3 +1,7 @@
+## 1.0.23(2023-06-08)
+- 新增 支持单独删除某一次对话(注意:一次对话包含提问和回答2条消息)
+- 更新 客户端网络请求超时时间(`manifest.json`->`networkTimeout`->`request`)设置为`600000`毫秒 [详情参考](https://uniapp.dcloud.net.cn/collocation/manifest.html#networktimeout)
+- 修复 部分情况,消息发送失败 仍然会显示“ai正在思考中”的问题
## 1.0.22(2023-06-07)
- 修复 解决Vue3版本的微信小程序端 textarea的blur事件,会触发“清空会话”事件的问题
## 1.0.21(2023-06-06)
diff --git a/components/llm-config/llm-config.vue b/components/llm-config/llm-config.vue
index 3ab4d879c3a09b403b2565e36b77663c0f37d63b..c880148d7c1c4b652fb44ced2b4e6d94aa85a2a4 100644
--- a/components/llm-config/llm-config.vue
+++ b/components/llm-config/llm-config.vue
@@ -1,11 +1,11 @@
-
+
请选择llm的model
-
@@ -13,34 +13,56 @@
确认
-
-
-
+
+
+
-
+ },
+ }
+ }
+
+
\ No newline at end of file
diff --git a/components/uni-ai-msg/uni-ai-msg.vue b/components/uni-ai-msg/uni-ai-msg.vue
index d5c43df0a1735aec09894f538cf63d6f40e854a1..051164f3b21ac55c0ccecfe5b056d17a55ae6d98 100644
--- a/components/uni-ai-msg/uni-ai-msg.vue
+++ b/components/uni-ai-msg/uni-ai-msg.vue
@@ -1,5 +1,5 @@
-
+
@@ -22,12 +22,21 @@
-
- ⟳
-
-
-
+
|');
+ htmlString = markdownIt.render(this.msgContent)+ '|';
} else {
htmlString = markdownIt.render(this.msgContent) + ' \n |';
}
@@ -211,7 +222,7 @@
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,
@@ -241,7 +252,13 @@
icon: 'none'
});
}
- })
+ })
+ this.showMoreMenu = false
+ },
+ // 删除消息
+ removeMsg(){
+ this.$emit('removeMsg',this.msgIndex)
+ this.showMoreMenu = false
}
}
}
@@ -273,8 +290,8 @@
.msgStateIcon {
position: relative;
- top: 5px;
- right: 5px;
+ top: -5px;
+ right: 1px;
align-self: center;
}
@@ -300,7 +317,7 @@
.content {
position: relative;
/* #ifndef APP-NVUE */
- max-width: calc(85% - 15px);
+ max-width: calc(85% - 45px);
/* #endif */
background-color: #FFF;
border-radius: 5px;
@@ -313,9 +330,9 @@
/* #endif */
}
- .controller {
+ .menu-box {
position: absolute;
- right: -25px;
+ left: -18px;
bottom: 0;
width: 20px;
flex-direction: column;
@@ -323,26 +340,81 @@
justify-content: flex-end;
}
- .retry-icon {
+ .menu-box-ai {
+ left: auto;
+ right: -20px;
+ }
+
+ .change-answer {
font-size: 26px;
color: #d4d4d4;
height: 25px;
line-height: 15px;
margin-bottom: 5px;
+ position: relative;
+ left: 2px;
}
- .retry-icon:hover {
+
+ .pointer {
+ cursor: pointer;
+ }
+
+ .pointer:hover {
color: #BBB;
}
- .retry-icon,.copy-icon {
- cursor: pointer;
+ .more-icon-box {
+ justify-content: center;
+ overflow: hidden;
}
- .copy-icon {
+ .more-icon {
+ color: #d4d4d4;
+ transform: rotate(90deg);
position: relative;
- height: 25px;
+ left: 4px;
+ font-size: 16px;
+ z-index: 999;
+ }
+
+ .more-menu {
+ position: absolute;
+ bottom:-10px;
+ left:-30px;
+ flex-direction: column;
+ justify-content: space-around;
+ width: 30px;
+ padding: 2px 5px;
+ height: 60px;
+ z-index: 999;
+ background-color: #FFF;
+ box-shadow: 0 0 20px #eee;
+ border-radius: 3px;
}
+ .more-menu-mask {
+ position: fixed;
+ width: 100vw;
+ height: 100vh;
+ top: 0;
+ left: 0;
+ z-index: 998;
+ }
+
+ .menu-box-ai .more-menu {
+ left:auto;
+ right: -32px;
+ }
+
+ .more-menu .pointer{
+ width: 20px;
+ }
+
+ .copy-icon{
+ position: relative;
+ height: 25px;
+ width: 20px;
+ }
.copy-icon-a,
.copy-icon-b {
position: absolute;
@@ -350,18 +422,29 @@
width: 10px;
height: 12px;
background-color: #FFF;
- left: 2px;
- top: 2px;
+ left: 3px;
+ top: 4px;
border-radius: 3px;
}
+ .copy-icon-b {
+ top: 8px;
+ left: 6px;
+ }
.copy-icon:hover .copy-icon-a,
.copy-icon:hover .copy-icon-b,{
border-color:#bbb;
}
- .copy-icon-b {
- top: 5px;
- left: 5px;
- }
+
+
+ .remove-msg {
+ position: relative;
+ opacity: 0.7;
+ }
+
+ .remove-msg:hover{
+ opacity: 1;
+ }
+
/* #ifndef APP-NVUE */
.content ::v-deep rich-text {
diff --git a/manifest.json b/manifest.json
index b963b9533f8b3687ea40d6ba1ea2164e1f9b8bc3..3c1335c98e70083aa7358dc2f1cc34af83f2f88a 100644
--- a/manifest.json
+++ b/manifest.json
@@ -5,6 +5,9 @@
"versionName" : "1.0.0",
"versionCode" : "100",
"transformPx" : false,
+ "networkTimeout" : {
+ "request" : 600000
+ },
"app-plus" : {
"usingComponents" : true,
"nvueStyleCompiler" : "uni-app",
diff --git a/package.json b/package.json
index 3e0d5a53886cba4df83f2fb80e0bada5ead938e7..016980a267bd9c53d0d88fa007fa4c2fff08a3d4 100644
--- a/package.json
+++ b/package.json
@@ -1,7 +1,7 @@
{
"id": "uni-ai-chat",
"name": "uni-ai-chat",
- "version": "1.0.22",
+ "version": "1.0.23",
"description": "基于uni-ai的聊天示例项目,支持流式、支持前文总结,云端一体",
"main": "main.js",
"scripts": {
diff --git a/pages/chat/chat.vue b/pages/chat/chat.vue
index 61c4ffbdcc38d4e1cf55e487be1100c59536c4b0..7cffddb3893d7020b962ab17bda33fd142670599 100644
--- a/pages/chat/chat.vue
+++ b/pages/chat/chat.vue
@@ -7,8 +7,8 @@
没有对话记录
-
+ :show-cursor="index == msgLength - 1 && msgLength%2 === 0 && sseIndex" :isLastMsg="index == msgLength - 1" @removeMsg="removeMsg">
+
uni-ai正在思考中...
如需提速,请开通
-
+
@@ -68,8 +68,10 @@
let uniCoTaskList = []
// 定义终止并清空 云对象的任务列表中所有 任务的方法
uniCoTaskList.clear = function(){
+ // 执行数组内的所有任务
uniCoTaskList.forEach(task=>task.abort())
- uniCoTaskList.slice(0,0)
+ // 清空数组
+ uniCoTaskList.slice(0,uniCoTaskList.length)
}
// 获取广告id
@@ -99,8 +101,7 @@
// 当前屏幕是否为宽屏
isWidescreen: false,
// 广告位id
- adpid,
- focus: false,
+ adpid,
llmModel:false
}
},
@@ -125,6 +126,15 @@
// 获取当前环境
NODE_ENV() {
return process.env.NODE_ENV
+ },
+ //最后一条消息的状态
+ lastMsgState(){
+ let mLength = this.msgList.length
+ if(mLength){
+ return this.msgList[mLength - 1].state
+ }else{
+ return false
+ }
}
},
// 监听msgList变化,将其存储到本地缓存中
@@ -137,7 +147,8 @@
this.$nextTick(() => {
this.updateLastMsg(msgList[msgLength - 1])
})
- }
+ }
+ msgList = msgList.filter(i=>i.isDelete !== true)
// 将msgList存储到本地缓存中
uni.setStorage({
"key": "uni-ai-msg",
@@ -373,6 +384,26 @@
illegal:false
})
this.send()
+ },
+ removeMsg(index){
+ // #ifdef VUE3
+ this.msgList[index].isDelete = true
+ if(this.msgList[index].isAi && this.msgList[index - 1]){
+ this.msgList[index - 1].isDelete = true
+ }else if(this.msgList[index + 1]){
+ this.msgList[index + 1].isDelete = true
+ }
+ // #endif
+
+ // #ifdef VUE2
+ this.$set(msgList[index],"isDelete",true)
+ msgList.slice(index,1,msgList[index])
+ if(msgList[index].isAi && msgList[index - 1]){
+ this.$set(msgList[index - 1],"isDelete",true)
+ }else if(msgList[index + 1]){
+ this.$set(msgList[index + 1],"isDelete",true)
+ }
+ // #endif
},
async beforeSendMsg() {
if(this.inputBoxDisabled){
@@ -465,7 +496,7 @@
let messages = []
// 复制一份,消息列表数据
- let msgs = JSON.parse(JSON.stringify(this.msgList))
+ let msgs = msgList.filter(i=>i.isDelete !== true)
// 带总结的消息 index
let findIndex = [...msgs].reverse().findIndex(item => item.summarize)
// console.log('findIndex', findIndex)
@@ -681,14 +712,6 @@
},
// 清空消息列表
clearAllMsg(e) {
- // #ifdef MP-WEIXIN && VUE3
- console.log('clearAllMsg',e);
- if(e && e.type == "blur"){
- console.log('补丁:解决Vue3版本的微信小程序端 textarea的blur事件,会触发“清空会话”事件的问题');
- return false
- }
- // #endif
-
// 弹出确认清空聊天记录的提示框
uni.showModal({
title: "确认要清空聊天记录?",
@@ -795,13 +818,13 @@
}
.textarea-box .textarea {
- max-height: 100px;
+ max-height: 120px;
font-size: 14px;
/* #ifndef APP-NVUE */
overflow: auto;
/* #endif */
width: 450rpx;
- font-size: 14px;
+ font-size: 14px;
}
/* #ifdef H5 */