Skip to content

Commit e675682

Browse files
fix(web): enhance throughput display in health check results
- Updated the health check results display to show download and upload speeds separately. - Introduced a new `fmtSpeed` function to format speeds in KB/s or MB/s for better readability. - Removed the previous single speed display and replaced it with a more informative output. These changes improve the clarity of health check results, providing users with a better understanding of network performance.
1 parent 92950f4 commit e675682

2 files changed

Lines changed: 12 additions & 5 deletions

File tree

hiddify-health

0 Bytes
Binary file not shown.

internal/web/static/index.html

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -151,16 +151,23 @@ <h2 id="title">Select an example</h2>
151151
const cls = 'fp-'+fp.Verdict;
152152
meta += `<span class="fp-badge ${cls}" style="margin:4px 6px 0 0;font-size:.65rem;padding:1px 6px">${fp.Verdict}</span>`;
153153
}
154-
let speed = '';
154+
let dl = 0, ul = 0;
155155
(rec.Checks||[]).forEach(c => {
156-
if ((c.Name==='download'||c.Name==='speedtest') && c.Throughput) {
157-
speed = (c.Throughput/1024).toFixed(0)+' KB/s';
158-
}
156+
if ((c.Name==='download'||c.Name==='speedtest') && c.Throughput) dl = c.Throughput;
157+
if (c.Name==='upload' && c.Throughput) ul = c.Throughput;
159158
});
160-
if (speed) meta += `<span class="ex-meta" style="display:inline">⚡ ${speed}</span>`;
159+
let speed = '';
160+
if (dl) speed += `↓ ${fmtSpeed(dl)}`;
161+
if (ul) speed += `${dl?' ':''}${fmtSpeed(ul)}`;
162+
if (speed) meta += `<span class="ex-meta" style="display:inline">${speed}</span>`;
161163
return `<div style="margin-top:4px">${badge}${meta}</div>`;
162164
}
163165

166+
// fmtSpeed renders bytes/sec as KB/s or MB/s.
167+
function fmtSpeed(bps) {
168+
return bps >= 1048576 ? (bps/1048576).toFixed(1)+' MB/s' : (bps/1024).toFixed(0)+' KB/s';
169+
}
170+
164171
function selectExample(item) {
165172
selectedDir = item.dir;
166173
document.getElementById('title').textContent = item.name;

0 commit comments

Comments
 (0)