diff --git a/ui/static/graph.html b/ui/static/graph.html index b419940..c7ee296 100644 --- a/ui/static/graph.html +++ b/ui/static/graph.html @@ -52,6 +52,73 @@ color: #ffffff; font-weight: bold; } + /* 开关切换 */ + .toggle-row { + margin-top: 8px; + display: flex; + align-items: center; + gap: 12px; + } + .toggle-row .label-text { + color: #8888aa; + font-size: 12px; + } + .toggle-switch { + position: relative; + width: 36px; + height: 20px; + cursor: pointer; + flex-shrink: 0; + } + .toggle-track { + position: absolute; + inset: 0; + background: rgba(60,60,80,0.8); + border-radius: 10px; + transition: all 0.3s; + border: 1px solid rgba(100,100,255,0.2); + } + .toggle-track.on { + background: rgba(68,136,255,0.5); + border-color: #4488ff; + } + .toggle-knob { + position: absolute; + width: 16px; + height: 16px; + left: 2px; + top: 2px; + background: #6666aa; + border-radius: 50%; + transition: all 0.3s; + } + .toggle-knob.on { + left: 18px; + background: #4488ff; + } + .toggle-btn { + display: flex; + align-items: center; + gap: 4px; + padding: 2px 8px; + border-radius: 4px; + border: 1px solid rgba(100,100,255,0.15); + background: transparent; + color: #8888aa; + font-size: 12px; + font-family: 'Courier New', monospace; + cursor: pointer; + transition: all 0.2s; + } + .toggle-btn:hover { + background: rgba(68,136,255,0.15); + color: #fff; + } + .toggle-btn.on { + background: rgba(68,136,255,0.3); + color: #4488ff; + border-color: #4488ff; + } #node-info { position: absolute; top: 20px; @@ -328,17 +395,17 @@

节点: 0

边: 0

状态: 初始化中...

-

+

- 自动视角 - - 活动 -

+ +

@@ -491,15 +558,36 @@ function init() { // 自动视角开关事件 var autoViewToggle = document.getElementById("autoViewToggle"); + var autoTrack = document.getElementById("autoTrack"); + var autoKnob = document.getElementById("autoKnob"); + var activityToggle = document.getElementById("activityToggle"); + + function updateAutoViewUI() { + if (autoViewToggle.checked) { + autoTrack.className = "toggle-track on"; + autoKnob.className = "toggle-knob on"; + } else { + autoTrack.className = "toggle-track"; + autoKnob.className = "toggle-knob"; + } + } + function updateActivityUI() { + activityToggle.classList.toggle("on"); + } + autoViewToggle.addEventListener("change", function() { autoViewEnabled = this.checked; + updateAutoViewUI(); }); - // 确保标签点击也能触发切换 document.getElementById("autoViewLabel").addEventListener("click", function(e) { - // 防止事件冒泡,直接切换 autoViewToggle.checked = !autoViewToggle.checked; autoViewToggle.dispatchEvent(new Event('change')); }); + activityToggle.addEventListener("click", function() { + updateActivityUI(); + // 活动切换逻辑(默认由后端处理) + this.blur(); + }); function createStarField() { const starCount = 3000;