From 7c6cdc5b67c57f0e1aa10aeeff331e56af090c14 Mon Sep 17 00:00:00 2001 From: Jerry Yan <792602257@qq.com> Date: Wed, 15 Jul 2026 18:01:10 +0800 Subject: [PATCH] feat(host-agent): persist OCR/UI overlay toggle preference Save the "Show OCR/UI-tree bounding boxes" checkbox state to localStorage so it persists across page refreshes in the task detail view. --- .../host_agent/web/templates/task_detail.html | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/apps/device-host-agent/host_agent/web/templates/task_detail.html b/apps/device-host-agent/host_agent/web/templates/task_detail.html index c474126..e5ea7b6 100644 --- a/apps/device-host-agent/host_agent/web/templates/task_detail.html +++ b/apps/device-host-agent/host_agent/web/templates/task_detail.html @@ -225,9 +225,24 @@ const toggle = document.getElementById("overlay-boxes-toggle"); if (toggle) { - toggle.addEventListener("change", function () { + const STORAGE_KEY = "task-detail-overlay-boxes-visible"; + + // 页面加载时恢复之前的选择 + const savedState = localStorage.getItem(STORAGE_KEY); + if (savedState !== null) { + const shouldShow = savedState === "true"; + toggle.checked = shouldShow; document.querySelectorAll("svg.overlay-svg").forEach(function (svg) { - svg.classList.toggle("show-boxes", toggle.checked); + svg.classList.toggle("show-boxes", shouldShow); + }); + } + + toggle.addEventListener("change", function () { + const isChecked = toggle.checked; + // 保存状态到 localStorage + localStorage.setItem(STORAGE_KEY, String(isChecked)); + document.querySelectorAll("svg.overlay-svg").forEach(function (svg) { + svg.classList.toggle("show-boxes", isChecked); }); }); }