Skip to content

Commit

Permalink
perf: 优化桌面端数据处理
Browse files Browse the repository at this point in the history
  • Loading branch information
kuaifan committed Dec 16, 2024
1 parent d8fbf36 commit 3aa2c60
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
1 change: 1 addition & 0 deletions resources/assets/js/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ export default {
'$route': {
handler(to) {
this.routePath = to.path
this.$store.state.routeName = to.name
},
immediate: true,
},
Expand Down
10 changes: 10 additions & 0 deletions resources/assets/js/store/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -2576,6 +2576,12 @@ export default {
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));
} else {
state.cacheDialogs.push(data);
Expand Down Expand Up @@ -3735,6 +3741,10 @@ export default {
}, 3000);
};
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);
let result = $A.jsonParse(e.data);
if (result.type === "encrypt" && result.encrypted) {
Expand Down
1 change: 1 addition & 0 deletions resources/assets/js/store/state.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ export default {
audioPlaying: null,

// 路由记录
routeName: null,
routeHistorys: [],
routeHistoryLast: {},

Expand Down

0 comments on commit 3aa2c60

Please sign in to comment.