需求:
1. 客户端与网页端所有展示到屏幕上的内容,去掉 ???、Unknown、未知版本、未选择、未合成、暂无在线 等占位问号/疑问式字符;
2. 网页端所有页面统一 cablemanager.html 那套风格(色板、硬边边框、圆角 6/8、顶栏渐变字/下边框分隔、shadow、body 径向渐变);
3. 补齐 <select>/option 下拉样式(appearance none、内联 SVG 箭头、padding-right 留位、ring focus、option 背景与主色一致),不再沿用系统默认。
改动:
1. station_broadcast.lua:
- 新增 Utils.sanitizeDisplay:统一把任意显示字符串内的 ? 全部剥离并 trim 空白,空串返回 '-'
- Display.render 里 truncL / truncR 从直接 tostring 改为走 sanitizeDisplay,保证所有监视器内容 0 问号
- Display.render 底部 3 条日志(drawLeft)和 Display.renderTerminal 顶部日志全部走 sanitizeDisplay
2. CloudServer/public/:
- index.html:
* :root 色板对齐 cablemanager(--bg-panel #121214、--text-primary #f4f4f5、--text-muted #a1a1aa、加 --bg-input/--ring-color、radius 8px)
* body 改 radial-gradient 背景
* .btn / .btn-primary / .btn-danger 统一成 cablemanager 同款尺寸(10x14、radius 6、font-weight 500/600)
* 新增 input[type=text|number|password] + textarea + select + option 完整样式组(cablemanager 同款)
* 清理 display 层的 Unknown/未知/未发布:
- stationVersion || '未知版本' 改为 || ''(空版本号直接省略,不写未知)
- seqHtml fallback 从 'Unknown sequence' 改为 ''
- localVersion 从 '未知' 改为 '-',targetVersion/publishedAt 从 '未发布' 改为 ''(空即省略)
- infoboard.html:
* :root 对齐 cablemanager,加 --bg-input、--ring-color、加 body radial-gradient
* 车次目的地 fallback 从 '未知终点' 改为 ''(没终点就空白)
- music.html:
* :root / body / layout-wrapper / topbar / title / btn / panel / card-title / badge / input+select+textarea 全对齐 cablemanager
* track_badge 默认占位从 '未选择' 改空(badge:empty 直接不显示)
* 空站台列表占位从 '暂无在线/已注册站台' 改为 '-'
* 补了完整 scrollbar 样式
* 最外层 body 内加 .layout-wrapper(对齐 cablemanager max-width 1280 + 居中)
- tempbroadcast.html:
* 所有风格同步 music.html(与 cablemanager 一致)
* build_badge 默认 '未合成' 改为空,失败分支也清空(只在合成成功/合成中写入),同时 .badge:empty {display:none}
* 空站台列表占位 '-'
* 补 select 下拉外观样式
客户端 bump v1.0.105 -> v1.0.106。
server.js node -c 通过;所有修改 HTML 仅改 style 段与少量占位文本,不影响 API 契约。
555 lines
20 KiB
HTML
555 lines
20 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="zh-CN">
|
|
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>车站广播系统 - 实时信息板</title>
|
|
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&family=JetBrains+Mono:wght@400;500&display=swap"
|
|
rel="stylesheet">
|
|
<style>
|
|
:root {
|
|
--bg-body: #09090b;
|
|
--bg-panel: #121214;
|
|
--bg-input: #09090b;
|
|
--bg-hover: #27272a;
|
|
--bg-border: #27272a;
|
|
--text-primary: #f4f4f5;
|
|
--text-muted: #a1a1aa;
|
|
--accent: #fafafa;
|
|
--danger: #ef4444;
|
|
--success: #10b981;
|
|
--warning: #f59e0b;
|
|
--radius: 8px;
|
|
--font-ui: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
|
|
--font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
|
|
--ring-color: rgba(255, 255, 255, 0.2);
|
|
}
|
|
|
|
* {
|
|
box-sizing: border-box;
|
|
}
|
|
|
|
body {
|
|
font-family: var(--font-ui);
|
|
background: radial-gradient(circle at 50% 0%, #18181b 0%, var(--bg-body) 100%);
|
|
color: var(--text-primary);
|
|
margin: 0;
|
|
padding: 24px;
|
|
height: 100vh;
|
|
display: flex;
|
|
flex-direction: column;
|
|
overflow: hidden;
|
|
}
|
|
|
|
header {
|
|
display: flex;
|
|
justify-content: space-between;
|
|
align-items: center;
|
|
margin-bottom: 24px;
|
|
padding-bottom: 16px;
|
|
border-bottom: 1px solid var(--bg-border);
|
|
}
|
|
|
|
h1 {
|
|
margin: 0;
|
|
font-size: 1.5rem;
|
|
font-weight: 600;
|
|
letter-spacing: -0.025em;
|
|
}
|
|
|
|
.header-meta {
|
|
display: flex;
|
|
gap: 20px;
|
|
align-items: center;
|
|
font-size: 0.85rem;
|
|
color: var(--text-muted);
|
|
}
|
|
|
|
.status-badge {
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 8px;
|
|
font-weight: 600;
|
|
}
|
|
|
|
.main-grid {
|
|
display: grid;
|
|
grid-template-columns: 1fr 1fr 1fr;
|
|
gap: 24px;
|
|
flex: 1;
|
|
overflow: hidden;
|
|
}
|
|
|
|
.card {
|
|
background: var(--bg-panel);
|
|
border: 1px solid var(--bg-border);
|
|
border-radius: var(--radius);
|
|
display: flex;
|
|
flex-direction: column;
|
|
overflow: hidden;
|
|
}
|
|
|
|
.card-header {
|
|
padding: 16px 20px;
|
|
background: rgba(255, 255, 255, 0.02);
|
|
border-bottom: 1px solid var(--bg-border);
|
|
display: flex;
|
|
justify-content: space-between;
|
|
align-items: center;
|
|
}
|
|
|
|
.card-title {
|
|
font-size: 0.85rem;
|
|
font-weight: 600;
|
|
color: var(--text-muted);
|
|
text-transform: uppercase;
|
|
letter-spacing: 0.05em;
|
|
}
|
|
|
|
.card-content {
|
|
flex: 1;
|
|
overflow-y: auto;
|
|
padding: 0;
|
|
}
|
|
|
|
/* Status Styles */
|
|
.status-list {
|
|
list-style: none;
|
|
margin: 0;
|
|
padding: 0;
|
|
}
|
|
|
|
.status-item {
|
|
padding: 12px 20px;
|
|
border-bottom: 1px solid var(--bg-border);
|
|
display: flex;
|
|
justify-content: space-between;
|
|
align-items: center;
|
|
}
|
|
|
|
.status-item:last-child {
|
|
border-bottom: none;
|
|
}
|
|
|
|
.item-info {
|
|
display: flex;
|
|
flex-direction: column;
|
|
gap: 2px;
|
|
}
|
|
|
|
.item-title {
|
|
font-weight: 500;
|
|
font-size: 0.95rem;
|
|
}
|
|
|
|
.item-sub {
|
|
font-size: 0.75rem;
|
|
color: var(--text-muted);
|
|
}
|
|
|
|
.status-dot {
|
|
width: 8px;
|
|
height: 8px;
|
|
border-radius: 50%;
|
|
background: var(--bg-border);
|
|
}
|
|
|
|
.dot-online {
|
|
background: var(--success);
|
|
box-shadow: 0 0 8px rgba(16, 185, 129, 0.4);
|
|
}
|
|
|
|
.dot-offline {
|
|
background: var(--danger);
|
|
}
|
|
|
|
.dot-broadcasting {
|
|
background: #3b82f6;
|
|
box-shadow: 0 0 8px rgba(59, 130, 246, 0.6);
|
|
animation: pulse 1s infinite;
|
|
}
|
|
|
|
@keyframes pulse {
|
|
0% { opacity: 1; transform: scale(1); }
|
|
50% { opacity: 0.5; transform: scale(1.5); }
|
|
100% { opacity: 1; transform: scale(1); }
|
|
}
|
|
|
|
/* Train Specifics */
|
|
.train-item {
|
|
cursor: pointer;
|
|
transition: background 0.1s;
|
|
}
|
|
|
|
.train-item:hover {
|
|
background: var(--bg-hover);
|
|
}
|
|
|
|
.trip-log {
|
|
display: grid;
|
|
grid-template-columns: 80px 1fr auto;
|
|
gap: 12px;
|
|
padding: 4px 0;
|
|
border-bottom: 1px dashed var(--bg-border);
|
|
}
|
|
|
|
.trip-log:last-child {
|
|
border-bottom: none;
|
|
}
|
|
|
|
/* Statistics & Messages */
|
|
.log-list {
|
|
padding: 8px;
|
|
margin: 0;
|
|
list-style: none;
|
|
display: flex;
|
|
flex-direction: column;
|
|
gap: 8px;
|
|
}
|
|
|
|
.log-item {
|
|
padding: 12px 16px;
|
|
background: rgba(255, 255, 255, 0.03);
|
|
border: 1px solid var(--bg-border);
|
|
border-radius: 6px;
|
|
font-size: 0.85rem;
|
|
line-height: 1.5;
|
|
display: flex;
|
|
align-items: flex-start;
|
|
gap: 12px;
|
|
animation: slideInRight 0.3s cubic-bezier(0.16, 1, 0.3, 1);
|
|
transition: all 0.2s;
|
|
}
|
|
|
|
.log-item:hover {
|
|
background: rgba(255, 255, 255, 0.05);
|
|
border-color: #3f3f46;
|
|
}
|
|
|
|
@keyframes slideInRight {
|
|
from { opacity: 0; transform: translateX(20px); }
|
|
to { opacity: 1; transform: translateX(0); }
|
|
}
|
|
|
|
.log-icon {
|
|
width: 20px;
|
|
height: 20px;
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
border-radius: 4px;
|
|
flex-shrink: 0;
|
|
margin-top: 2px;
|
|
}
|
|
|
|
.log-body {
|
|
flex: 1;
|
|
display: flex;
|
|
flex-direction: column;
|
|
gap: 2px;
|
|
}
|
|
|
|
.log-time {
|
|
font-family: var(--font-mono);
|
|
font-size: 0.7rem;
|
|
color: var(--text-muted);
|
|
font-weight: 500;
|
|
}
|
|
|
|
.log-content {
|
|
color: var(--text-primary);
|
|
word-break: break-all;
|
|
}
|
|
|
|
/* Message Types */
|
|
.log-info .log-icon { background: rgba(59, 130, 246, 0.15); color: #60a5fa; }
|
|
.log-arrival .log-icon { background: rgba(16, 185, 129, 0.15); color: #34d399; }
|
|
.log-departure .log-icon { background: rgba(245, 158, 11, 0.15); color: #fbbf24; }
|
|
.log-broadcast .log-icon { background: rgba(139, 92, 246, 0.15); color: #a78bfa; }
|
|
.log-important { border-left: 3px solid #3b82f6; }
|
|
|
|
.log-broadcast {
|
|
background: rgba(139, 92, 246, 0.05);
|
|
border-color: rgba(139, 92, 246, 0.2);
|
|
}
|
|
|
|
/* Scrollbar */
|
|
::-webkit-scrollbar {
|
|
width: 6px;
|
|
}
|
|
|
|
::-webkit-scrollbar-track {
|
|
background: transparent;
|
|
}
|
|
|
|
::-webkit-scrollbar-thumb {
|
|
background: var(--bg-hover);
|
|
border-radius: 3px;
|
|
}
|
|
|
|
::-webkit-scrollbar-thumb:hover {
|
|
background: #52525b;
|
|
}
|
|
|
|
@media (max-width: 1024px) {
|
|
.main-grid {
|
|
grid-template-columns: 1fr;
|
|
overflow-y: auto;
|
|
}
|
|
body {
|
|
overflow-y: auto;
|
|
height: auto;
|
|
}
|
|
}
|
|
</style>
|
|
</head>
|
|
|
|
<body>
|
|
<header>
|
|
<h1>实时信息板 - 全局概览</h1>
|
|
<div class="header-meta">
|
|
<div id="clock" style="font-family: var(--font-mono); font-weight: 500;">00:00:00</div>
|
|
<div class="status-badge">
|
|
<div id="conn-dot" class="status-dot dot-offline"></div>
|
|
<span id="conn-status" style="color: var(--danger)">未连接</span>
|
|
</div>
|
|
</div>
|
|
</header>
|
|
|
|
<div class="main-grid">
|
|
<!-- 车站状态 -->
|
|
<div class="card">
|
|
<div class="card-header">
|
|
<div class="card-title">活动车站</div>
|
|
<div id="station-count" style="font-size: 0.75rem; color: var(--text-muted);">0</div>
|
|
</div>
|
|
<div class="card-content">
|
|
<div class="status-list" id="station-list">
|
|
<div style="padding:40px; text-align:center; color:var(--text-muted); font-style:italic;">正在加载车站信息...</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- 列车状态 -->
|
|
<div class="card">
|
|
<div class="card-header">
|
|
<div class="card-title">活跃列车</div>
|
|
<div id="train-count" style="font-size: 0.75rem; color: var(--text-muted);">0</div>
|
|
</div>
|
|
<div class="card-content">
|
|
<div class="status-list" id="train-list">
|
|
<div style="padding:40px; text-align:center; color:var(--text-muted); font-style:italic;">正在加载列车信息...</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- 最新消息 -->
|
|
<div class="card">
|
|
<div class="card-header">
|
|
<div class="card-title">最新消息</div>
|
|
</div>
|
|
<div class="card-content">
|
|
<div class="log-list" id="message-list">
|
|
<div style="padding:40px; text-align:center; color:var(--text-muted); font-style:italic;">暂无消息数据</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<script>
|
|
// --- Icons (SVG) ---
|
|
const ICONS = {
|
|
chevronDown: `<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="6 9 12 15 18 9"/></svg>`,
|
|
chevronUp: `<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="18 15 12 9 6 15"/></svg>`,
|
|
info: `<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"/><line x1="12" y1="16" x2="12" y2="12"/><line x1="12" y1="8" x2="12.01" y2="8"/></svg>`,
|
|
arrival: `<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><path d="M7 10l5 5 5-5"/><path d="M12 3v12"/></svg>`,
|
|
departure: `<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><path d="M17 14l-5-5-5 5"/><path d="M12 21V9"/></svg>`,
|
|
broadcast: `<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><path d="M9 18V5l12-2v13"/><circle cx="6" cy="18" r="3"/><circle cx="18" cy="16" r="3"/></svg>`
|
|
};
|
|
|
|
// --- State ---
|
|
let stationCodeMap = {};
|
|
let broadcastingStations = new Set();
|
|
let messageLog = [];
|
|
const MAX_MESSAGES = 50;
|
|
|
|
// --- Clock ---
|
|
function updateClock() {
|
|
const now = new Date();
|
|
document.getElementById('clock').textContent = now.toLocaleTimeString();
|
|
}
|
|
setInterval(updateClock, 1000);
|
|
updateClock();
|
|
|
|
// --- WebSocket ---
|
|
const connStatus = document.getElementById('conn-status');
|
|
const connDot = document.getElementById('conn-dot');
|
|
let ws;
|
|
|
|
function connect() {
|
|
const wsProto = window.location.protocol === 'https:' ? 'wss' : 'ws';
|
|
ws = new WebSocket(`${wsProto}://${window.location.host}`);
|
|
|
|
ws.onopen = () => {
|
|
connStatus.textContent = '已连接';
|
|
connStatus.style.color = 'var(--success)';
|
|
connDot.className = 'status-dot dot-online';
|
|
ws.send(JSON.stringify({ type: 'console_connect' }));
|
|
};
|
|
|
|
ws.onclose = () => {
|
|
connStatus.textContent = '已断开 (重连中...)';
|
|
connStatus.style.color = 'var(--danger)';
|
|
connDot.className = 'status-dot dot-offline';
|
|
setTimeout(connect, 3000);
|
|
};
|
|
|
|
ws.onmessage = (event) => {
|
|
const data = JSON.parse(event.data);
|
|
if (data.type === 'init_state' || data.type === 'state_update') {
|
|
updateState(data);
|
|
if (data.logs && data.type === 'init_state') {
|
|
data.logs.forEach(l => addMessage(l));
|
|
}
|
|
} else if (data.type === 'log') {
|
|
addMessage(data.data);
|
|
} else if (data.type === 'stream_start') {
|
|
broadcastingStations.add(data.station);
|
|
updateStationDots();
|
|
} else if (data.type === 'stream_end') {
|
|
broadcastingStations.delete(data.station);
|
|
updateStationDots();
|
|
}
|
|
};
|
|
}
|
|
|
|
function addMessage(msg) {
|
|
const time = new Date().toLocaleTimeString();
|
|
let type = 'log-info';
|
|
let icon = ICONS.info;
|
|
let important = false;
|
|
|
|
if (msg.includes('Arrived') || msg.includes('arrival')) {
|
|
type = 'log-arrival';
|
|
icon = ICONS.arrival;
|
|
important = true;
|
|
} else if (msg.includes('Departed') || msg.includes('departure')) {
|
|
type = 'log-departure';
|
|
icon = ICONS.departure;
|
|
important = true;
|
|
} else if (msg.includes('Broadcast') || msg.includes('Stream')) {
|
|
type = 'log-broadcast';
|
|
icon = ICONS.broadcast;
|
|
}
|
|
|
|
messageLog.unshift({ time, content: msg, type, icon, important });
|
|
if (messageLog.length > MAX_MESSAGES) messageLog.pop();
|
|
renderMessages();
|
|
}
|
|
|
|
function renderMessages() {
|
|
const container = document.getElementById('message-list');
|
|
if (messageLog.length === 0) {
|
|
container.innerHTML = '<div style="padding:40px; text-align:center; color:var(--text-muted); font-style:italic;">暂无消息数据</div>';
|
|
return;
|
|
}
|
|
|
|
container.innerHTML = messageLog.map(m => `
|
|
<div class="log-item ${m.type} ${m.important ? 'log-important' : ''}">
|
|
<div class="log-icon">${m.icon}</div>
|
|
<div class="log-body">
|
|
<span class="log-time">${m.time}</span>
|
|
<span class="log-content">${m.content}</span>
|
|
</div>
|
|
</div>
|
|
`).join('');
|
|
}
|
|
|
|
function updateState(state) {
|
|
if (state.stations) {
|
|
const list = document.getElementById('station-list');
|
|
list.innerHTML = '';
|
|
const stList = Array.isArray(state.stations) ? state.stations : Object.values(state.stations);
|
|
|
|
document.getElementById('station-count').textContent = stList.length;
|
|
|
|
stList.forEach(st => {
|
|
stationCodeMap[st.name] = st.code;
|
|
});
|
|
|
|
if (stList.length === 0) {
|
|
list.innerHTML = '<div style="padding:40px;text-align:center;color:var(--text-muted);font-size:0.8rem">暂无活动车站</div>';
|
|
} else {
|
|
stList.forEach(st => {
|
|
const isOnline = (Date.now() - st.lastSeen) < 60000;
|
|
const isBroadcasting = broadcastingStations.has(st.name);
|
|
const dotClass = isBroadcasting ? 'dot-broadcasting' : (isOnline ? 'dot-online' : 'dot-offline');
|
|
const hasCC = Array.isArray(st.tags) && st.tags.includes('CC');
|
|
|
|
const div = document.createElement('div');
|
|
div.className = 'status-item';
|
|
div.innerHTML = `
|
|
<div class="item-info">
|
|
<div class="item-title">
|
|
${st.name}
|
|
${hasCC ? '<span style="font-size:0.65rem; background:rgba(16, 185, 129, 0.1); color:#34d399; padding:1px 5px; border-radius:4px; margin-left:6px; font-weight:normal; border:1px solid rgba(16, 185, 129, 0.2)">CC</span>' : ''}
|
|
</div>
|
|
<div class="item-sub">${st.code}${st.platform ? ` - 站台 ${st.platform}` : ''}</div>
|
|
</div>
|
|
<div class="status-dot ${dotClass}" id="station-dot-${st.name.replace(/[^a-zA-Z0-9]/g, '_')}" data-online="${isOnline}" data-name="${st.name}"></div>
|
|
`;
|
|
list.appendChild(div);
|
|
});
|
|
}
|
|
}
|
|
|
|
if (state.activeTrains) {
|
|
const list = document.getElementById('train-list');
|
|
list.innerHTML = '';
|
|
|
|
document.getElementById('train-count').textContent = state.activeTrains.length;
|
|
|
|
if (!state.activeTrains || state.activeTrains.length === 0) {
|
|
list.innerHTML = '<div style="padding:40px;text-align:center;color:var(--text-muted);font-size:0.8rem">暂无活跃列车</div>';
|
|
} else {
|
|
state.activeTrains.forEach(tr => {
|
|
const div = document.createElement('div');
|
|
div.className = 'status-item train-item';
|
|
|
|
const currentStCode = stationCodeMap[tr.currentStation] || tr.currentStation || '-';
|
|
const statusColor = tr.status === 'At Station' ? 'var(--success)' : 'var(--warning)';
|
|
|
|
div.innerHTML = `
|
|
<div style="width:100%">
|
|
<div style="display:flex; justify-content:space-between; align-items:center;">
|
|
<div class="item-info">
|
|
<div class="item-title">${tr.trainId} <span style="font-size:0.7rem; color:var(--text-muted); font-weight:normal; margin-left:8px;">${tr.destination || ''}</span></div>
|
|
<div class="item-sub">${currentStCode} <span style="color:${statusColor}; margin-left:8px;">${tr.status === 'At Station' ? '在站' : (tr.status === 'Departed' ? '已发车' : '运行中')}</span></div>
|
|
</div>
|
|
<div class="status-dot ${tr.status === 'At Station' ? 'dot-online' : 'dot-warn'}"></div>
|
|
</div>
|
|
</div>
|
|
`;
|
|
list.appendChild(div);
|
|
});
|
|
}
|
|
}
|
|
}
|
|
|
|
function updateStationDots() {
|
|
const dots = document.querySelectorAll('[id^="station-dot-"]');
|
|
dots.forEach(dot => {
|
|
const name = dot.getAttribute('data-name');
|
|
const isOnline = dot.getAttribute('data-online') === 'true';
|
|
const isBroadcasting = broadcastingStations.has(name);
|
|
dot.className = 'status-dot ' + (isBroadcasting ? 'dot-broadcasting' : (isOnline ? 'dot-online' : 'dot-offline'));
|
|
});
|
|
}
|
|
|
|
connect();
|
|
</script>
|
|
</body>
|
|
|
|
</html>
|