更新优化,修复bug

This commit is contained in:
weipengfei 2023-09-22 09:54:05 +08:00
parent fbdb8fe8c6
commit 9b8aa5389a
1 changed files with 7 additions and 5 deletions

View File

@ -60,6 +60,7 @@
content: '', content: '',
c_content: '', c_content: '',
n_content: '', n_content: '',
params: [], //
timer: '', timer: '',
socketTask: {}, socketTask: {},
TEXT: '', TEXT: '',
@ -350,11 +351,12 @@
// } // }
// } // }
// }; // };
if (this.historyTextList.length > 8) this.historyTextList = this.historyTextList.splice(-8); if (this.historyTextList.length > 8) this.params = JSON.parse(JSON.stringify(this.historyTextList.splice(-8)));
else this.params = JSON.parse(JSON.stringify(this.historyTextList));
console.log(this.params);
this.isSurpass(); this.isSurpass();
let params = this.historyTextList;
realThis.socketTask.send({ // uni realThis.socketTask.send({ // uni
data: JSON.stringify(params), data: JSON.stringify(this.params),
success() { success() {
console.log('第一帧发送成功') console.log('第一帧发送成功')
} }
@ -408,11 +410,11 @@
}, },
// //
isSurpass(){ isSurpass(){
let sum = this.historyTextList.reduce((accumulator, currentValue) => { let sum = this.params.reduce((accumulator, currentValue) => {
return accumulator + currentValue.content; return accumulator + currentValue.content;
}, ''); }, '');
if(sum.length>5000){ if(sum.length>5000){
this.historyTextList.shift(); this.params.shift();
return this.isSurpass(); return this.isSurpass();
}else { }else {
console.log(`本次发送${sum.length}`); console.log(`本次发送${sum.length}`);