refactor: 重构文件存储路径并清理冗余代码
- 将项目文件存储从 public/uploads 迁移至项目根目录专用目录 - 更新所有前端页面的路径提示文本与API请求路径 - 移除冗余的列车详情展开收起功能及相关代码 - 重构服务器端文件路径处理逻辑,增强路径访问安全性 - 清理旧注释和未使用的变量与函数
This commit is contained in:
@@ -184,19 +184,6 @@
|
||||
background: var(--bg-hover);
|
||||
}
|
||||
|
||||
.train-details {
|
||||
display: none;
|
||||
background: rgba(0, 0, 0, 0.2);
|
||||
padding: 12px 20px;
|
||||
font-size: 0.8rem;
|
||||
color: var(--text-muted);
|
||||
border-top: 1px solid var(--bg-border);
|
||||
}
|
||||
|
||||
.train-details.open {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.trip-log {
|
||||
display: grid;
|
||||
grid-template-columns: 80px 1fr auto;
|
||||
@@ -380,7 +367,6 @@
|
||||
};
|
||||
|
||||
// --- State ---
|
||||
let expandedTrains = new Set();
|
||||
let stationCodeMap = {};
|
||||
let broadcastingStations = new Set();
|
||||
let messageLog = [];
|
||||
@@ -526,27 +512,8 @@
|
||||
list.innerHTML = '<div style="padding:40px;text-align:center;color:var(--text-muted);font-size:0.8rem">暂无活跃列车</div>';
|
||||
} else {
|
||||
state.activeTrains.forEach(tr => {
|
||||
const isExpanded = expandedTrains.has(tr.trainId);
|
||||
const div = document.createElement('div');
|
||||
div.className = 'status-item train-item';
|
||||
div.onclick = () => toggleTrain(tr.trainId);
|
||||
|
||||
let detailsHtml = '';
|
||||
if (tr.tripLogs && tr.tripLogs.length > 0) {
|
||||
detailsHtml = tr.tripLogs.slice().reverse().map(log => {
|
||||
const time = new Date(log.time).toLocaleTimeString();
|
||||
const stCode = stationCodeMap[log.station] || log.station;
|
||||
return `
|
||||
<div class="trip-log">
|
||||
<span>${time}</span>
|
||||
<span style="color:var(--text-primary)">${stCode}</span>
|
||||
<span style="color:${log.action === 'Arrival' ? 'var(--success)' : 'var(--warning)'}">${log.action === 'Arrival' ? '到达' : '出发'}</span>
|
||||
</div>
|
||||
`;
|
||||
}).join('');
|
||||
} else {
|
||||
detailsHtml = '<div style="font-style:italic">暂无运行历史</div>';
|
||||
}
|
||||
|
||||
const currentStCode = stationCodeMap[tr.currentStation] || tr.currentStation || '-';
|
||||
const statusColor = tr.status === 'At Station' ? 'var(--success)' : 'var(--warning)';
|
||||
@@ -556,13 +523,9 @@
|
||||
<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' ? '在站' : '运行中'}</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 style="color:var(--text-muted)">${isExpanded ? ICONS.chevronUp : ICONS.chevronDown}</div>
|
||||
</div>
|
||||
<div class="train-details ${isExpanded ? 'open' : ''}" id="details-${tr.trainId}">
|
||||
<div style="margin-bottom:8px;font-weight:600;font-size:0.7rem;text-transform:uppercase;color:var(--text-muted)">运行日志 (Trip Logs)</div>
|
||||
${detailsHtml}
|
||||
<div class="status-dot ${tr.status === 'At Station' ? 'dot-online' : 'dot-warn'}"></div>
|
||||
</div>
|
||||
</div>
|
||||
`;
|
||||
@@ -572,15 +535,6 @@
|
||||
}
|
||||
}
|
||||
|
||||
function toggleTrain(id) {
|
||||
if (expandedTrains.has(id)) expandedTrains.delete(id);
|
||||
else expandedTrains.add(id);
|
||||
const details = document.getElementById(`details-${id}`);
|
||||
if (details) {
|
||||
details.classList.toggle('open');
|
||||
}
|
||||
}
|
||||
|
||||
function updateStationDots() {
|
||||
const dots = document.querySelectorAll('[id^="station-dot-"]');
|
||||
dots.forEach(dot => {
|
||||
|
||||
Reference in New Issue
Block a user