update:优化性能问题
This commit is contained in:
+28
-1
@@ -41,6 +41,27 @@ const LIVENESS_TIMEOUT_MS = 30000;
|
||||
const RECONNECT_DELAYS_MS = [1000, 2000, 4000, 8000, 15000];
|
||||
const ROUND_AUDIO_NAMES = ["一", "二", "三", "四", "五"];
|
||||
const MATCH_STATUS_HALF_REST = 3;
|
||||
const ENABLE_REALTIME_MESSAGE_LOG = (() => {
|
||||
try {
|
||||
return uni.getAccountInfoSync().miniProgram.envVersion !== "release";
|
||||
} catch (_) {
|
||||
return false;
|
||||
}
|
||||
})();
|
||||
|
||||
function getServerMessageLogSummary(message = {}) {
|
||||
const practiceInfo = message.practice_info || message.practiceInfo || {};
|
||||
const matchInfo = message.match_info || message.matchInfo || {};
|
||||
return {
|
||||
type: message.type,
|
||||
matchId: normalizeId(pickField(message, "matchId", "match_id")),
|
||||
sequence: message.sequence,
|
||||
practiceDetailCount: Array.isArray(practiceInfo.details)
|
||||
? practiceInfo.details.length
|
||||
: 0,
|
||||
roundCount: Array.isArray(matchInfo.rounds) ? matchInfo.rounds.length : 0,
|
||||
};
|
||||
}
|
||||
|
||||
// 比赛服消息类型先映射成项目里已有的 V2 业务消息,页面仍然复用原来的 socket-inbox 流程。
|
||||
const BUSINESS_TYPE_BY_SERVER_TYPE = {
|
||||
@@ -785,7 +806,13 @@ function handleMessage(data) {
|
||||
}
|
||||
|
||||
const typeName = getServerMessageTypeName(message.type);
|
||||
console.log("收到比赛服 WebSocket 消息", typeName, message);
|
||||
if (ENABLE_REALTIME_MESSAGE_LOG) {
|
||||
console.log(
|
||||
"收到比赛服 WebSocket 消息",
|
||||
typeName,
|
||||
getServerMessageLogSummary(message)
|
||||
);
|
||||
}
|
||||
|
||||
const decodedMatchId = normalizeId(pickField(message, "matchId", "match_id"));
|
||||
if (message.type === ServerMessageType.SERVER_MSG_SYNC_PRACTICE_INFO) {
|
||||
|
||||
Reference in New Issue
Block a user