(function () { 'use strict'; const pollSlider = document.getElementById('pollInterval'); const pollVal = document.getElementById('pollVal'); const showHealthToggle = document.getElementById('showHealth'); const statusDot = document.getElementById('statusDot'); const statusText = document.getElementById('statusText'); // $settings is the SDK-provided settings proxy (auto-persists) $settings = $settings || {}; function applySettings(settings) { if (settings.pollInterval !== undefined) { pollSlider.value = settings.pollInterval; pollVal.textContent = settings.pollInterval + 'ms'; } if (settings.showHealth !== undefined) { showHealthToggle.checked = settings.showHealth; } } pollSlider.addEventListener('input', function () { const val = parseInt(this.value, 10); pollVal.textContent = val + 'ms'; $settings.pollInterval = val; }); showHealthToggle.addEventListener('change', function () { $settings.showHealth = this.checked; }); // 监听插件传来的状态更新 $websocket.on('sendToPropertyInspector', function (data) { if (data.payload && data.payload.status) { const st = data.payload.status; statusText.textContent = st; statusDot.className = 'status-dot'; if (st.indexOf('Think') >= 0 || st.indexOf('思考') >= 0) statusDot.classList.add('thinking'); else if (st.indexOf('Work') >= 0 || st.indexOf('执行') >= 0) statusDot.classList.add('working'); else if (st.indexOf('Error') >= 0 || st.indexOf('错误') >= 0) statusDot.classList.add('error'); else if (st.indexOf('Recon') >= 0 || st.indexOf('重连') >= 0) statusDot.classList.add('error'); } }); // 初始化时加载已有设置 if ($settings.pollInterval) applySettings($settings); else { $settings.pollInterval = 1000; $settings.showHealth = true; } $websocket.on('didReceiveSettings', function (data) { applySettings(data.payload.settings); }); // 启用自动翻译 $local = true; })();