update:优化个人训练图片

This commit is contained in:
2026-07-23 11:01:55 +08:00
parent 3c5754b3fd
commit dff210462f
61 changed files with 678 additions and 110 deletions
+18 -16
View File
@@ -5,6 +5,11 @@ const { Reader, Writer } = protobuf;
// 比赛服 protobuf 协议适配层:
// 小程序环境不支持 protobufjs 反射模式里的动态 Function codegen
// 所以这里使用 minimal Reader/Writer 做静态字段解码和客户端消息编码。
// <match-schema-generated>
// 此区块由 scripts/generate-match-schema.mjs 自动生成,请勿手动修改。
// 来源:src/utils/match.min.jssha256: b4f272aad40fb951
// 协议命名空间:rpc;消息数:12;字段数:137
export const ServerMessageType = {
SERVER_MSG_UNKNOWN: 0,
SERVER_MSG_MATCH_READY: 1,
@@ -21,6 +26,7 @@ export const ServerMessageType = {
SERVER_MSG_HEARTBEAT: 12,
SERVER_MSG_PRACTICE_END: 13,
SERVER_MSG_SYNC_PRACTICE_INFO: 14,
SERVER_MSG_SYNC_MATCH_INFO: 15,
};
export const ClientMessageType = {
@@ -30,18 +36,9 @@ export const ClientMessageType = {
CLIENT_MSG_ACK: 3,
CLIENT_MSG_LEAVE: 4,
CLIENT_MSG_SYNC_PRACTICE_INFO: 5,
CLIENT_MSG_SYNC_MATCH_INFO: 6,
};
// protobufjs 的 enum 默认是 name -> value,这里反转成 value -> name 用于日志打印。
const ServerMessageTypeNameByValue = Object.keys(ServerMessageType).reduce(
(result, name) => {
result[ServerMessageType[name]] = name;
return result;
},
{}
);
// 当前只需要解码比赛服下发的字段并打印,字段表按后端 proto 定义维护。
const SCHEMAS = {
MatchShoot: {
1: { name: "player_id", kind: "int64" },
@@ -210,12 +207,7 @@ const SCHEMAS = {
17: { name: "win_team", kind: "int32" },
18: { name: "mvp", kind: "message", type: "PlayerFull" },
19: { name: "room_id", kind: "string" },
20: {
name: "result_list",
kind: "message",
type: "PlayerMatchResult",
repeated: true,
},
20: { name: "result_list", kind: "message", type: "PlayerMatchResult", repeated: true },
21: { name: "timeout_time", kind: "int64" },
22: { name: "target_type", kind: "int32" },
23: { name: "event_type", kind: "int32" },
@@ -233,6 +225,16 @@ const SCHEMAS = {
7: { name: "sequence", kind: "int64" },
},
};
// </match-schema-generated>
// protobufjs 的 enum 默认是 name -> value,这里反转成 value -> name 用于日志打印。
const ServerMessageTypeNameByValue = Object.keys(ServerMessageType).reduce(
(result, name) => {
result[ServerMessageType[name]] = name;
return result;
},
{}
);
// 小程序 websocket 收到的 data 可能是 ArrayBuffer、TypedArray 或字符串,这里统一成 Uint8Array。
function toUint8Array(data) {