新增对话上下文,限制上下文最多5000字
This commit is contained in:
parent
f14b0b11be
commit
fbdb8fe8c6
|
@ -49,7 +49,7 @@
|
|||
return {
|
||||
talkList: [],
|
||||
ajax: {
|
||||
rows: 100, //每页数量
|
||||
rows: 15, //每页数量
|
||||
page: 1, //页码
|
||||
flag: false, // 请求开关
|
||||
loading: false, // 加载中
|
||||
|
@ -350,7 +350,9 @@
|
|||
// }
|
||||
// }
|
||||
// };
|
||||
let params = this.TEXT
|
||||
if (this.historyTextList.length > 8) this.historyTextList = this.historyTextList.splice(-8);
|
||||
this.isSurpass();
|
||||
let params = this.historyTextList;
|
||||
realThis.socketTask.send({ // 发送消息,,都用uni的官方版本
|
||||
data: JSON.stringify(params),
|
||||
success() {
|
||||
|
@ -404,6 +406,19 @@
|
|||
}
|
||||
})
|
||||
},
|
||||
// 判断文字是否超过五千字
|
||||
isSurpass(){
|
||||
let sum = this.historyTextList.reduce((accumulator, currentValue) => {
|
||||
return accumulator + currentValue.content;
|
||||
}, '');
|
||||
if(sum.length>5000){
|
||||
this.historyTextList.shift();
|
||||
return this.isSurpass();
|
||||
}else {
|
||||
console.log(`本次发送${sum.length}字`);
|
||||
return sum;
|
||||
}
|
||||
},
|
||||
// 鉴权
|
||||
getWebSocketUrl() {
|
||||
return new Promise((resolve, reject) => {
|
||||
|
@ -455,9 +470,17 @@
|
|||
}
|
||||
|
||||
@keyframes blink {
|
||||
0% { opacity: 1; }
|
||||
50% { opacity: 0; }
|
||||
100% { opacity: 1; }
|
||||
0% {
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
50% {
|
||||
opacity: 0;
|
||||
}
|
||||
|
||||
100% {
|
||||
opacity: 1;
|
||||
}
|
||||
}
|
||||
|
||||
.blinking-box {
|
||||
|
@ -521,8 +544,10 @@
|
|||
border-top: #e5e5e5 solid 1px;
|
||||
box-sizing: content-box;
|
||||
background-color: #f5f5f5;
|
||||
transform: translateY(0); /* 初始化 transform 属性 */
|
||||
transition: transform 0.3s ease; /* 添加过渡效果 */
|
||||
transform: translateY(0);
|
||||
/* 初始化 transform 属性 */
|
||||
transition: transform 0.3s ease;
|
||||
/* 添加过渡效果 */
|
||||
|
||||
/* 兼容iPhoneX */
|
||||
padding-bottom: 0;
|
||||
|
@ -640,6 +665,7 @@
|
|||
margin: 0 !important;
|
||||
padding: 0 !important;
|
||||
}
|
||||
|
||||
.placeholder {
|
||||
width: 100vw;
|
||||
background-color: #1573fb;
|
||||
|
|
Loading…
Reference in New Issue