Spaces:
Paused
Paused
Peng Ding commited on
Commit ·
65b9bdc
1
Parent(s): 8720e9c
fix: preserve footer links during i18n switch
Browse filesUse data-i18n-html + innerHTML for keys containing markup (footer_author),
plain data-i18n + textContent for everything else. Fixes bug where
applyLang() stripped <a> tags from the footer on every language switch.
src/veilrender/routes/dashboard.py
CHANGED
|
@@ -419,7 +419,7 @@ def _build_html() -> str:
|
|
| 419 |
<div class="ftr in d4">
|
| 420 |
<div class="ftr-row">
|
| 421 |
<span data-i18n="footer_info">Live updates every 5 s · stats are in-memory, reset on restart</span>
|
| 422 |
-
<span data-i18n="footer_author">Built by <a href="https://github.com/Oaklight">Oaklight</a> · <a href="https://github.com/Oaklight/veilrender">source on GitHub</a></span>
|
| 423 |
</div>
|
| 424 |
<div class="ftr-badges">
|
| 425 |
{_BADGES_HTML}
|
|
@@ -450,7 +450,7 @@ def _build_html() -> str:
|
|
| 450 |
th_avg: 'Avg Latency',
|
| 451 |
th_p95: 'P95 Latency',
|
| 452 |
footer_info: 'Live updates every 5 s · stats are in-memory, reset on restart',
|
| 453 |
-
footer_author: 'Built by Oaklight · source on GitHub',
|
| 454 |
alive: 'alive',
|
| 455 |
dead: 'dead'
|
| 456 |
}},
|
|
@@ -473,7 +473,7 @@ def _build_html() -> str:
|
|
| 473 |
th_avg: '平均延迟',
|
| 474 |
th_p95: 'P95 延迟',
|
| 475 |
footer_info: '每 5 秒自动更新 · 统计数据存储在内存中,重启后重置',
|
| 476 |
-
footer_author: '由 Oaklight 构建 · 源码见 GitHub',
|
| 477 |
alive: '运行中',
|
| 478 |
dead: '已停止'
|
| 479 |
}}
|
|
@@ -498,6 +498,10 @@ def _build_html() -> str:
|
|
| 498 |
const key = el.getAttribute('data-i18n');
|
| 499 |
if (t[key] != null) el.textContent = t[key];
|
| 500 |
}});
|
|
|
|
|
|
|
|
|
|
|
|
|
| 501 |
const bv = document.getElementById('browser-val');
|
| 502 |
if (bv.getAttribute('data-i18n-key') === 'browser_status') {{
|
| 503 |
const alive = document.getElementById('dot').classList.contains('dot-on');
|
|
|
|
| 419 |
<div class="ftr in d4">
|
| 420 |
<div class="ftr-row">
|
| 421 |
<span data-i18n="footer_info">Live updates every 5 s · stats are in-memory, reset on restart</span>
|
| 422 |
+
<span data-i18n-html="footer_author">Built by <a href="https://github.com/Oaklight">Oaklight</a> · <a href="https://github.com/Oaklight/veilrender">source on GitHub</a></span>
|
| 423 |
</div>
|
| 424 |
<div class="ftr-badges">
|
| 425 |
{_BADGES_HTML}
|
|
|
|
| 450 |
th_avg: 'Avg Latency',
|
| 451 |
th_p95: 'P95 Latency',
|
| 452 |
footer_info: 'Live updates every 5 s · stats are in-memory, reset on restart',
|
| 453 |
+
footer_author: 'Built by <a href="https://github.com/Oaklight">Oaklight</a> · <a href="https://github.com/Oaklight/veilrender">source on GitHub</a>',
|
| 454 |
alive: 'alive',
|
| 455 |
dead: 'dead'
|
| 456 |
}},
|
|
|
|
| 473 |
th_avg: '平均延迟',
|
| 474 |
th_p95: 'P95 延迟',
|
| 475 |
footer_info: '每 5 秒自动更新 · 统计数据存储在内存中,重启后重置',
|
| 476 |
+
footer_author: '由 <a href="https://github.com/Oaklight">Oaklight</a> 构建 · <a href="https://github.com/Oaklight/veilrender">源码见 GitHub</a>',
|
| 477 |
alive: '运行中',
|
| 478 |
dead: '已停止'
|
| 479 |
}}
|
|
|
|
| 498 |
const key = el.getAttribute('data-i18n');
|
| 499 |
if (t[key] != null) el.textContent = t[key];
|
| 500 |
}});
|
| 501 |
+
document.querySelectorAll('[data-i18n-html]').forEach(el => {{
|
| 502 |
+
const key = el.getAttribute('data-i18n-html');
|
| 503 |
+
if (t[key] != null) el.innerHTML = t[key];
|
| 504 |
+
}});
|
| 505 |
const bv = document.getElementById('browser-val');
|
| 506 |
if (bv.getAttribute('data-i18n-key') === 'browser_status') {{
|
| 507 |
const alive = document.getElementById('dot').classList.contains('dot-on');
|