优化消息处理,只显示最近100条

Former-commit-id: 2ca8596cd78220579c91978dd3a71d8b7d38e8de
TangShanKaiPing
zhengpengju 5 years ago
parent 4342bb8f23
commit f108686555

@ -0,0 +1 @@
<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1590654813817" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="2781" xmlns:xlink="http://www.w3.org/1999/xlink" width="1024" height="1024"><defs><style type="text/css"></style></defs><path d="M803.406102 829.44c0 14.578983-21.000678 26.554576-46.861017 26.554576H267.454915c-25.860339 0-46.861017-11.975593-46.861017-26.554576s21.000678-26.728136 46.861017-26.728136h489.09017c25.860339 0 46.861017 11.975593 46.861017 26.728136zM512 308.588475a23.08339 23.08339 0 0 1-23.777627-22.562712V190.915254a23.777627 23.777627 0 0 1 47.555254 0v95.631187a23.08339 23.08339 0 0 1-23.777627 22.562712zM333.928136 369.681356a24.471864 24.471864 0 0 1-17.355933-8.157288l-65.084745-73.068475a21.521356 21.521356 0 0 1 2.950508-31.587796 24.471864 24.471864 0 0 1 33.32339 2.776949l65.258305 73.068474a21.521356 21.521356 0 0 1-3.818305 31.761356 24.124746 24.124746 0 0 1-15.27322 5.380339zM239.338305 524.496271h-4.165424l-99.79661-17.355932a22.562712 22.562712 0 0 1-19.265085-25.860339 23.604068 23.604068 0 0 1 27.422373-17.87661l99.97017 17.355932a22.215593 22.215593 0 0 1 19.091525 25.860339 23.256949 23.256949 0 0 1-23.256949 18.570847zM690.071864 369.681356a24.992542 24.992542 0 0 1-15.27322-5.20678 21.521356 21.521356 0 0 1-2.950508-31.587796L737.106441 260.338983a24.818983 24.818983 0 0 1 33.32339-2.776949 21.521356 21.521356 0 0 1 2.950508 31.587797l-65.084746 73.242033a24.471864 24.471864 0 0 1-18.223729 8.157289zM784.661695 524.496271a23.430508 23.430508 0 0 1-23.256949-18.570847A22.215593 22.215593 0 0 1 781.016949 480.065085l99.97017-17.355932a23.604068 23.604068 0 0 1 27.422373 18.223728 22.562712 22.562712 0 0 1-19.265085 25.860339l-99.79661 17.355933h-4.165424z" fill="#d81e06" p-id="2782"></path><path d="M697.187797 577.431864c0-109.863051-82.961356-198.725424-185.187797-198.725423s-185.187797 88.862373-185.187797 198.725423v225.627119h370.375594z" fill="#d81e06" p-id="2783"></path><path d="M526.058305 576.216949h60.225085l-143.707119 172.517966 47.902373-121.491525h-53.456271l53.456271-143.36h104.135593z" fill="#d81e06" p-id="2784"></path></svg>

After

Width:  |  Height:  |  Size: 2.2 KiB

@ -231,7 +231,7 @@ function saveMessage(msg){
}
}
function loadMessage(callback, limit = 10){
function loadMessage(callback, limit = 99){
if(db){
console.log("数据库打开");
console.log(db);

@ -148,16 +148,28 @@ const store = new Vuex.Store({
* 设置消息数据
* @param {*} state 原有状态
* @param {*} messages 新的消息数组
* @param {*} limit 默认条数限制
*/
setMessages(state, messages){
setMessages(state, messages, limit = 99){
console.log('<<>>');
console.log(state.messages);
console.log(messages);
console.log('====================================');
console.log('=================state.messages===================');
//state.messages = messages;
//state.messages.push(messages);
// 便利消息列表追加
console.log('state.messages::s:', state.messages);
// 推出超出条数FIFO
state.messages.forEach(function(value,i){
if(i >= limit){
state.messages.shift()
}
})
console.log('state.messages::e:', state.messages);
// 消息列表追加
messages.forEach(function(value,i){
if(state.messages >= limit){
state.messages.shift()
}
state.messages.push(value);
})
console.log(state.messages);

Loading…
Cancel
Save