perf: 优化桌面端数据处理

This commit is contained in:
kuaifan 2024-12-17 00:07:50 +08:00
parent d8fbf36e00
commit 3aa2c604d8
3 changed files with 12 additions and 0 deletions

View File

@ -104,6 +104,7 @@ export default {
'$route': { '$route': {
handler(to) { handler(to) {
this.routePath = to.path this.routePath = to.path
this.$store.state.routeName = to.name
}, },
immediate: true, immediate: true,
}, },

View File

@ -2576,6 +2576,12 @@ export default {
return !state.dialogMsgs.find(m => m.id == id)?.read_at return !state.dialogMsgs.find(m => m.id == id)?.read_at
}) })
} }
if (data.last_at
&& original.last_at
&& $A.dayjs(data.last_at) < $A.dayjs(original.last_at)) {
delete data.last_at
delete data.last_msg
}
state.cacheDialogs.splice(index, 1, Object.assign({}, original, data)); state.cacheDialogs.splice(index, 1, Object.assign({}, original, data));
} else { } else {
state.cacheDialogs.push(data); state.cacheDialogs.push(data);
@ -3735,6 +3741,10 @@ export default {
}, 3000); }, 3000);
}; };
state.ws.onmessage = async (e) => { state.ws.onmessage = async (e) => {
if ($A.inArray(state.routeName, ['preload', '404'])) {
wgLog && console.log("[WS] Preload", e);
return;
}
wgLog && console.log("[WS] Message", e); wgLog && console.log("[WS] Message", e);
let result = $A.jsonParse(e.data); let result = $A.jsonParse(e.data);
if (result.type === "encrypt" && result.encrypted) { if (result.type === "encrypt" && result.encrypted) {

View File

@ -46,6 +46,7 @@ export default {
audioPlaying: null, audioPlaying: null,
// 路由记录 // 路由记录
routeName: null,
routeHistorys: [], routeHistorys: [],
routeHistoryLast: {}, routeHistoryLast: {},