Save the "Show OCR/UI-tree bounding boxes" checkbox state to localStorage so it persists across page refreshes in the task detail view.
This commit is contained in:
@@ -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);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user