fix: 补 .gitattributes(CRLF for .bat) + README 端口 19540 + 提交 console 锁文件

This commit is contained in:
AskaEth committed 2026-09-09 20:57:58 +08:00
1 parent c121111f51
commit b80c64a115
39 files changed
+4217 -345

No files matched your search

+26 -9
View File
@@ -6,7 +6,6 @@ import type {
DisplayCommand,
Event,
EventResultGroup,
EventSettings,
RealtimeStatus,
RecordEntry,
SnapshotMessage,
@@ -21,11 +20,13 @@ import {
parseEvent,
parseEventResultGroups,
parseSettings,
parseSnapshot,
parseStandingRow,
parseStandingRows,
parseTeam,
parseTeamBreakdown,
} from './guards'
import type { DisplaySettings } from './guards'
import { createMockAthletes, createMockSnapshot } from './mock'
import { readCachedSnapshot, writeCachedSnapshot } from './storage'
import { DISPLAY_PAGES, normalizePage } from './types'
@@ -49,7 +50,7 @@ const reducedMotion = prefersReducedMotion()
const source = ref<DisplaySource>('live')
const status = ref<RealtimeStatus>('idle')
const version = ref<number | null>(null)
const settings = ref<EventSettings | null>(null)
const settings = ref<DisplaySettings | null>(null)
const teams = ref<Team[]>([])
const events = ref<Event[]>([])
const standings = ref<StandingRow[]>([])
@@ -169,8 +170,17 @@ function applyChanges(changes: Change[]): void {
for (const change of changes) {
switch (change.entity) {
case 'standings':
if (change.action === 'replace') applyStandings(parseStandingRows(change.data))
else if (change.action === 'upsert') mergeStanding(parseStandingRow(change.data))
if (change.action === 'replace') {
// 服务端当前下发的是 {eventId:N} 这类定位信息而不是榜单数组;
// 直接当空数组用会把大屏清空,所以忽略并拉全量。
if (!Array.isArray(change.data)) {
resyncNeeded = true
break
}
applyStandings(parseStandingRows(change.data))
} else if (change.action === 'upsert') {
mergeStanding(parseStandingRow(change.data))
}
break
case 'athleteStandings':
case 'athlete_standings':
@@ -178,7 +188,9 @@ function applyChanges(changes: Change[]): void {
break
case 'latestResults':
case 'eventResults':
if (change.action === 'replace') latestResults.value = parseEventResultGroups(change.data)
if (change.action === 'replace') {
latestResults.value = parseEventResultGroups(change.data, teams.value)
}
break
case 'settings':
if (change.action !== 'void') settings.value = parseSettings(change.data)
@@ -221,7 +233,8 @@ async function loadRest(): Promise<boolean> {
let ok = false
if (settingsResult.status === 'fulfilled' && !hasSnapshot) {
settings.value = settingsResult.value
// REST 载荷同样过解析层,保证嵌套结构与默认值和大屏其余入口一致。
settings.value = parseSettings(settingsResult.value)
ok = true
}
if (standingsResult.status === 'fulfilled' && !hasSnapshot) {
@@ -237,7 +250,7 @@ async function loadRest(): Promise<boolean> {
function activateMock(): void {
const snapshot = createMockSnapshot()
settings.value = snapshot.settings
settings.value = parseSettings(snapshot.settings)
teams.value = snapshot.teams
events.value = snapshot.events
latestResults.value = snapshot.latestResults
@@ -419,8 +432,12 @@ function connect(): void {
displayKey: options.value.instance ?? options.value.screen ?? undefined,
initialVersion: version.value,
onSnapshot: (message) => {
applySnapshot(message, 'live')
writeCachedSnapshot(message)
// 服务端快照的 settings 是点号扁平 map,原始载荷直写 ref 会让 display 变 undefined;
// 必须过解析层归一,解析失败则整包丢弃(心跳/重连会再给一次)。
const snapshot = parseSnapshot(message)
if (snapshot === null) return
applySnapshot(snapshot, 'live')
writeCachedSnapshot(snapshot)
},
onCatchup: (message) => {
applyChanges(message.changes)