feat: departure广播新增下一站播报 + 客户端预解析station code

This commit is contained in:
2026-08-16 13:01:32 +08:00
parent 17b03ce0f7
commit ae96c86288
2 changed files with 41 additions and 7 deletions
+24 -6
View File
@@ -2213,14 +2213,24 @@ function handleTrainDeparture(ws, data) {
const trainId = data.trainId;
const stationName = getCorrectStationName(data.stationName);
const stationCode = data.stationCode;
const platform = data.stationPlatform || data.platform || '1';
const cleanPlatform = String(platform).replace(/\D/g, '');
const finalPlatform = cleanPlatform || '1';
const beep = data.departureBeep || data.beep || 'fc1';
const lineCode = data.lineCode || (stationCode ? stationCode.split('-')[0] : 'UNK');
const destCode = data.destCode || getStationCodeFromName(data.destination) || 'UNK';
const nextStationRaw = data.nextStation ? String(data.nextStation).trim() : '';
const nextCodeRaw = data.nextCode ? String(data.nextCode).trim() : (nextStationRaw ? getStationCodeFromName(nextStationRaw) : '');
const hasNextStation = nextStationRaw && nextStationRaw !== '' && nextCodeRaw && nextCodeRaw !== 'UNK' && nextCodeRaw !== '';
const finalNextCode = hasNextStation ? nextCodeRaw : null;
const existingIndex = activeTrains.findIndex(t => t.trainId === trainId);
if (existingIndex >= 0) {
activeTrains.splice(existingIndex, 1);
}
log('INFO', `Train ${trainId} departing from ${stationName}. Broadcasting departure...`);
log('INFO', `Train ${trainId} departing from ${stationName}. Broadcasting departure... nextStation=${nextStationRaw || '(none/terminal)'} nextCode=${finalNextCode || '(none)'}`);
saveData();
broadcastUpdate();
@@ -2232,11 +2242,19 @@ function handleTrainDeparture(ws, data) {
}));
// Departure Audio Logic
const seq = [
beep,
'ja-doorwarn',
'ch-doorwarn'
];
const seq = [beep, 'ja-doorwarn', 'ch-doorwarn'];
if (finalNextCode) {
seq.push(
'ja-fc1', `ja-${finalPlatform}`, 'ja-fc2', `ja-${destCode}`, 'ja-fc3', 'ja-nextsta', `ja-${finalNextCode}`,
'ch-fc1', `ch-${finalPlatform}`, 'ch-fc2', 'ch-fc3', `ch-${destCode}`, 'ch-nextsta', `ch-${finalNextCode}`
);
} else {
seq.push(
'ja-fc1', `ja-${finalPlatform}`, 'ja-fc2', `ja-${destCode}`, 'ja-fc3',
'ch-fc1', `ch-${finalPlatform}`, 'ch-fc2', 'ch-fc3', `ch-${destCode}`
);
}
enqueueHlsPush(stationName, seq);