fix: 测试页同时兼容 base64 与 URL 图片字段

直连 worker 返回 *_base64、经网关则改写为 *_url;统一 resolveImgSrc 后接口1/2/3/5/6 测试页都能正确显示结果图。

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
xsl
2026-07-19 15:49:46 +08:00
co-authored by Cursor
parent 51e313e845
commit 08b31a3baa
6 changed files with 60 additions and 30 deletions
+3 -6
View File
@@ -62,7 +62,7 @@
@media (max-width: 768px) { .results { flex-direction: column; } }
.hidden { display: none !important; }
</style>
<script src="/static/img_downscale.js"></script>
<script src="/static/img_downscale.js?v=2"></script>
</head>
<body>
<div class="container">
@@ -159,12 +159,9 @@ async function submitTest() {
if (json.code === 0) {
setStatus('✅ 请求成功 (' + _elapsed + 's) — request_id: ' + json.request_id, 'success');
// 兼容本地直连 worker返回 *_base64)与网关(改写为 *_url两种情况
// 兼容本地直连 worker*_base64)与网关(*_url
const _d = json.data || {};
const annoUrl = _d.annotated_image_url
|| (_d.annotated_image_base64
? ('data:image/png;base64,' + _d.annotated_image_base64.replace(/^data:image\/\w+;base64,/, ''))
: '');
const annoUrl = resolveImgSrc(_d.annotated_image_url, _d.annotated_image_base64, 'image/png');
showOverlay(annoUrl);
renderMetrics(json.data);
$('metricsBar').classList.remove('hidden');