精修 WebUI 第十五轮:设备下拉框状态点
- decorateDeviceSelect: 把 #device select 包裹进 .deviceSelectWrap,在右侧自定义箭头之前插入状态点 - 状态点:选中具体设备或自动模式下有在线设备 → 绿色 ok;无设备 → 灰色 idle;refreshDevices/change 时更新 - cache-bust v17 → v18
This commit is contained in:
1 parent
16042d7fd2
commit
94e8d37d18
3 files changed
+56
-2
No files matched your search
@@ -1370,6 +1370,32 @@ async function refreshDevices() {
|
|||||||
$("adbStatus").textContent = data.adb ? `adb: ${data.adb}` : "未找到 adb.exe(请安装 platform-tools)";
|
$("adbStatus").textContent = data.adb ? `adb: ${data.adb}` : "未找到 adb.exe(请安装 platform-tools)";
|
||||||
deviceOverviewState = { devices, adb: data.adb || "" };
|
deviceOverviewState = { devices, adb: data.adb || "" };
|
||||||
updateDeviceOverview();
|
updateDeviceOverview();
|
||||||
|
|
||||||
|
// 选中后在外层包装上反映状态点
|
||||||
|
decorateDeviceSelect();
|
||||||
|
sel.addEventListener("change", decorateDeviceSelect);
|
||||||
|
}
|
||||||
|
|
||||||
|
function decorateDeviceSelect() {
|
||||||
|
const sel = document.getElementById("device");
|
||||||
|
if (!sel) return;
|
||||||
|
const wrap = sel.closest(".deviceSelectWrap") || (() => {
|
||||||
|
const w = document.createElement("div");
|
||||||
|
w.className = "deviceSelectWrap";
|
||||||
|
sel.parentNode.insertBefore(w, sel);
|
||||||
|
w.appendChild(sel);
|
||||||
|
const dot = document.createElement("span");
|
||||||
|
dot.className = "deviceSelectDot";
|
||||||
|
dot.setAttribute("aria-hidden", "true");
|
||||||
|
w.appendChild(dot);
|
||||||
|
return w;
|
||||||
|
})();
|
||||||
|
const dot = wrap.querySelector(".deviceSelectDot");
|
||||||
|
const hasDevices = (deviceOverviewState.devices || []).length > 0;
|
||||||
|
const selected = sel.value;
|
||||||
|
// 选中具体设备 → 绿;选 auto + 有在线设备 → 绿;无设备 → 灰
|
||||||
|
const ok = !!(selected || hasDevices);
|
||||||
|
if (dot) dot.dataset.state = ok ? "ok" : "idle";
|
||||||
}
|
}
|
||||||
|
|
||||||
function getConfigBoundElements() {
|
function getConfigBoundElements() {
|
||||||
|
|||||||
+2
-2
@@ -15,7 +15,7 @@
|
|||||||
} catch (e) {}
|
} catch (e) {}
|
||||||
})();
|
})();
|
||||||
</script>
|
</script>
|
||||||
<link rel="stylesheet" href="styles.css?v=console-20260520-theme-v17" />
|
<link rel="stylesheet" href="styles.css?v=console-20260520-theme-v18" />
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div class="app">
|
<div class="app">
|
||||||
@@ -1252,6 +1252,6 @@
|
|||||||
</footer>
|
</footer>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script src="app.js?v=console-20260520-theme-v17"></script>
|
<script src="app.js?v=console-20260520-theme-v18"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
@@ -2324,6 +2324,34 @@ details[open] > summary.sectionTitle::before {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Device select wrapper with status dot */
|
||||||
|
.deviceSelectWrap {
|
||||||
|
position: relative;
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
|
||||||
|
.deviceSelectWrap select {
|
||||||
|
padding-right: 40px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.deviceSelectDot {
|
||||||
|
position: absolute;
|
||||||
|
right: 28px;
|
||||||
|
top: 50%;
|
||||||
|
transform: translateY(-50%);
|
||||||
|
width: 6px;
|
||||||
|
height: 6px;
|
||||||
|
border-radius: 50%;
|
||||||
|
background: var(--muted-soft);
|
||||||
|
box-shadow: 0 0 0 2px color-mix(in oklab, var(--muted-soft) 16%, transparent);
|
||||||
|
pointer-events: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.deviceSelectDot[data-state="ok"] {
|
||||||
|
background: var(--success);
|
||||||
|
box-shadow: 0 0 0 2px color-mix(in oklab, var(--success) 16%, transparent);
|
||||||
|
}
|
||||||
|
|
||||||
/* ==================== Tooltip (data-tooltip) ==================== */
|
/* ==================== Tooltip (data-tooltip) ==================== */
|
||||||
[data-tooltip] {
|
[data-tooltip] {
|
||||||
position: relative;
|
position: relative;
|
||||||
|
|||||||
Reference in new issue
Block a user