Skip to content

Commit 17acd38

Browse files
committed
Merge branch 'develop'
2 parents 17a3d2b + 0cdad5a commit 17acd38

9 files changed

Lines changed: 1264 additions & 634 deletions

File tree

main.py

Lines changed: 78 additions & 155 deletions
Large diffs are not rendered by default.

mtr_pathfinder_lib/mtr_pathfinder.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1133,6 +1133,7 @@ def remove_duplicate(data, ert):
11331133
dwells = [round(y['dwellTime'] / 1000)
11341134
for y in stations]
11351135
i1 = -1
1136+
i2 = None
11361137
while True:
11371138
try:
11381139
i1 = sta_ids.index(sta1, i1 + 1)
@@ -1146,6 +1147,9 @@ def remove_duplicate(data, ert):
11461147
else:
11471148
break
11481149

1150+
if i2 is None:
1151+
return list(chain(*ert))
1152+
11491153
dwell = sum(dwells[i1 + 1:i2])
11501154
old_leg[k][4] = old_leg[k][4][:3]
11511155
old_leg[k][5] += dwell

mtr_pathfinder_lib/mtr_pathfinder_v4.py

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -817,11 +817,15 @@ def process_path(result: list[tuple], start: str, end: str,
817817
for x in path:
818818
station_1 = x[0]
819819
station_2 = x[1]
820-
sta1_name = station_num_to_name(data, station_1).replace('|', ' ')
821-
sta2_name = station_num_to_name(data, station_2).replace('|', ' ')
820+
sta1_name = station_num_to_name(data, station_1)
821+
sta1_id = station_name_to_id(data, sta1_name, {}, False)
822+
sta1_name = sta1_name.replace('|', ' ')
823+
sta2_name = station_num_to_name(data, station_2)
824+
sta2_id = station_name_to_id(data, sta2_name, {}, False)
825+
sta2_name = sta2_name.replace('|', ' ')
822826
route_name = x[4][0]
823827
if route_name in data['routes']:
824-
z = data['routes'][route_name]
828+
z: dict[str, list] = data['routes'][route_name]
825829
route_name = data['routes'][route_name]['name']
826830
route = (z['number'] + ' ' + route_name.split('||')[0]).strip()
827831
route = route.replace('|', ' ')
@@ -839,7 +843,24 @@ def process_path(result: list[tuple], start: str, end: str,
839843
t1_name = '(逆时针) ' + t1_name
840844
t2_name += ' (Anticlockwise)'
841845
terminus = (t1_name, t2_name)
842-
platform = x[4][2]
846+
i2 = 0
847+
sta_ids = [x['id'] for x in z['stations']]
848+
while True:
849+
try:
850+
sta2_index = sta_ids.index(sta2_id, i2)
851+
i2 = sta2_index + 1
852+
try:
853+
sta1_index = [i for (i, x) in enumerate(sta_ids[:i2])
854+
if x == sta1_id][-1]
855+
except ValueError:
856+
pass
857+
else:
858+
platform = z['stations'][sta1_index]['name']
859+
break
860+
861+
except ValueError:
862+
platform = None
863+
break
843864

844865
color = hex(z['color']).lstrip('0x').rjust(6, '0')
845866
train_type = z['type']

templates/admin.html

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ <h4 class="text-sm font-medium mb-2" style="color: var(--text-primary);">更新
168168
<span id="progress-stage" style="color: var(--text-secondary);">准备中...</span>
169169
<span id="progress-percentage" style="color: var(--text-secondary);">0%</span>
170170
</div>
171-
<div id="progress-message" class="text-sm mt-1" style="color: var(--text-tertiary);"></div>
171+
172172
</div>
173173

174174
<div id="update-status" class="mt-4 p-4 rounded-lg hidden"></div>
@@ -384,14 +384,10 @@ <h3 class="font-medium" style="color: var(--text-primary);">寻路次数统计</
384384
const progressBar = document.getElementById('progress-bar');
385385
const progressStage = document.getElementById('progress-stage');
386386
const progressPercentage = document.getElementById('progress-percentage');
387-
const progressMessage = document.getElementById('progress-message');
388387

389388
progressBar.style.width = `${progress.percentage}%`;
390389
progressStage.textContent = progress.stage;
391390
progressPercentage.textContent = `${progress.percentage}%`;
392-
if (progress.message) {
393-
progressMessage.textContent = progress.message;
394-
}
395391
}
396392

397393
// 开始轮询更新进度

templates/base.html

Lines changed: 95 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,58 @@
258258
background-color: var(--form-input-bg);
259259
color: var(--text-primary);
260260
}
261+
/* 在flex容器中,让form-input元素能正确收缩 */
262+
.flex .form-input {
263+
flex: 1;
264+
min-width: 0;
265+
}
266+
/* 确保flex容器中的元素不换行 */
267+
.flex {
268+
flex-wrap: nowrap;
269+
}
270+
/* 默认隐藏ID列,避免页面加载时闪动 */
271+
th.col-id,
272+
td.col-id {
273+
display: none;
274+
}
275+
/* 统一的叉按钮样式 */
276+
.close-btn {
277+
background: none;
278+
border: none;
279+
width: auto;
280+
height: auto;
281+
cursor: pointer;
282+
font-size: 1rem;
283+
line-height: 1;
284+
padding: 0.8px;
285+
opacity: 0.7;
286+
transition: opacity 0.2s, color 0.2s;
287+
color: var(--text-primary);
288+
margin-left: 8px;
289+
}
290+
.close-btn:hover {
291+
opacity: 1;
292+
color: #ef4444;
293+
}
294+
/* 统一的详情按钮样式 */
295+
.detail-btn {
296+
background: none;
297+
border: none;
298+
width: auto;
299+
height: auto;
300+
cursor: pointer;
301+
font-size: 1rem;
302+
line-height: 1;
303+
padding: 0.8px;
304+
opacity: 0.7;
305+
transition: opacity 0.2s, color 0.2s;
306+
color: var(--text-primary);
307+
margin-left: 8px;
308+
}
309+
.detail-btn:hover {
310+
opacity: 1;
311+
color: #3b82f6;
312+
}
261313
.form-input:focus {
262314
outline: 2px solid var(--form-input-focus);
263315
outline-offset: 2px;
@@ -556,6 +608,9 @@
556608

557609
.route-info {
558610
margin-bottom: 12px;
611+
border-left: 6px solid;
612+
padding-left: 12px;
613+
border-radius: 0;
559614
}
560615

561616
.route-info > :not(:last-child) {
@@ -586,18 +641,17 @@
586641

587642
.route-tag {
588643
font-weight: 600;
589-
color: white;
644+
background-color: transparent !important;
590645
}
591646

592647
.direction-indicator {
593-
background: var(--bg-tertiary);
594648
margin-top: 2px;
595649
color: var(--text-primary);
596650
}
597651

598652
.time-detail {
599-
background: var(--bg-tertiary);
600653
margin-top: 2px;
654+
color: var(--text-primary);
601655
}
602656

603657
.station {
@@ -611,7 +665,7 @@
611665
.divider {
612666
display: inline;
613667
margin-right: 8px;
614-
color: #6c757d;
668+
color: var(--text-tertiary);
615669
font-style: italic;
616670
font-weight: 600;
617671
}
@@ -620,13 +674,43 @@
620674
display: flex;
621675
align-items: center;
622676
padding: 2px 6px;
623-
background: var(--bg-tertiary);
624-
border-radius: 4px;
625677
margin-top: 2px;
626678
font-size: 0.85rem;
627679
color: var(--text-primary);
628680
}
629681

682+
/* 统一的标签样式,用于线路类型和站台编号 */
683+
.route-tag-label {
684+
margin-left: 8px;
685+
opacity: 0.8;
686+
padding: 1px 6px;
687+
background-color: var(--bg-tertiary);
688+
color: var(--text-secondary);
689+
border: 1px solid var(--border-color);
690+
border-radius: 4px;
691+
font-size: 0.85em;
692+
font-family: inherit;
693+
line-height: normal;
694+
white-space: nowrap;
695+
display: inline-flex;
696+
align-items: center;
697+
}
698+
699+
/* 站台编号标签 - 正常粗细 */
700+
.station-info-label {
701+
font-weight: normal;
702+
}
703+
704+
/* 线路类型标签 - 粗体 */
705+
.line-type-label {
706+
font-weight: bold;
707+
}
708+
709+
/* 确保字号统一 */
710+
.route-name {
711+
font-size: 1em;
712+
}
713+
630714
.direction-indicator::before {
631715
content: "→";
632716
margin-right: 4px;
@@ -637,10 +721,9 @@
637721
display: flex;
638722
align-items: center;
639723
padding: 2px 6px;
640-
background: var(--bg-tertiary);
641-
border-radius: 4px;
642724
margin-top: 2px;
643725
font-size: 0.85rem;
726+
color: var(--text-primary);
644727
}
645728

646729
.time-value {
@@ -660,7 +743,7 @@
660743
margin-right: 6px;
661744
margin-top: 2px;
662745
font-size: 0.8rem;
663-
color: #6c757d;
746+
color: var(--text-tertiary);
664747
font-style: italic;
665748
}
666749

@@ -672,14 +755,14 @@
672755
.other-route-tag {
673756
display: inline-block;
674757
padding: 2px 6px;
675-
border-radius: 4px;
676758
font-size: 0.75rem;
677759
font-weight: 500;
678760
margin-right: 4px;
679761
margin-bottom: 4px;
680762
cursor: pointer;
681-
transition: filter 0.2s ease;
763+
transition: opacity 0.2s ease;
682764
vertical-align: top;
765+
background: transparent;
683766
}
684767

685768
/* 移动端菜单样式 */
@@ -741,16 +824,14 @@
741824
display: flex;
742825
align-items: center;
743826
padding: 2px 6px;
744-
border-radius: 4px;
745827
font-size: 0.85rem;
746828
line-height: 1.5;
747829
width: 100%;
748830
margin: 8px 0;
749-
background: var(--bg-tertiary);
831+
color: var(--text-primary);
750832
}
751833

752834
.departure-time, .arrival-time {
753-
background: var(--bg-tertiary);
754835
font-size: 0.85rem;
755836
color: var(--accent-primary);
756837
font-weight: 600;
@@ -759,7 +840,6 @@
759840
.route-departure-time, .route-arrival-time {
760841
font-size: 0.85rem;
761842
color: var(--text-secondary);
762-
background: var(--bg-tertiary);
763843
}
764844

765845
.version-info {

templates/error.html

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{% extends 'base.html' %}
2+
3+
{% block content %}
4+
<div class="card">
5+
<h2 class="text-2xl font-bold mb-4">错误</h2>
6+
<div class="bg-red-50 border border-red-200 text-red-700 px-4 py-3 rounded relative" role="alert">
7+
<strong class="font-bold">错误信息:</strong>
8+
<span class="block sm:inline">{{ message or '发生了一个未知错误' }}</span>
9+
</div>
10+
<div class="mt-6">
11+
<a href="/" class="btn-primary">返回首页</a>
12+
</div>
13+
</div>
14+
{% endblock %}

0 commit comments

Comments
 (0)