|
|
|
class RightSection { |
|
constructor() { |
|
this.currentTab = 'status-panel'; |
|
|
|
|
|
setTimeout(() => { |
|
this.settingsPanel = new SettingsPanel(); |
|
console.log('RightSection: SettingsPanel初始化完成'); |
|
}, 200); |
|
|
|
this.init(); |
|
} |
|
|
|
init() { |
|
this.initTabSwitching(); |
|
|
|
|
|
window.addEventListener('websocket-message', (event) => { |
|
const message = event.detail; |
|
if (message.type === 'initial_data' && message.data.settings) { |
|
this.settingsPanel.updateSettings(message.data.settings); |
|
} |
|
}); |
|
} |
|
|
|
initTabSwitching() { |
|
const tabButtons = document.querySelectorAll('.right-toolbar .tab-btn'); |
|
|
|
tabButtons.forEach(button => { |
|
button.addEventListener('click', (e) => { |
|
e.preventDefault(); |
|
|
|
const targetPanelId = button.getAttribute('data-target'); |
|
|
|
tabButtons.forEach(btn => btn.classList.remove('active')); |
|
button.classList.add('active'); |
|
|
|
document.querySelectorAll('.tab-panel').forEach(panel => { |
|
panel.classList.remove('active'); |
|
}); |
|
document.getElementById(targetPanelId).classList.add('active'); |
|
|
|
this.currentTab = targetPanelId; |
|
|
|
|
|
|
|
}); |
|
}); |
|
} |
|
} |
|
|
|
|
|
|
|
window.RightSection = RightSection; |
|
|
|
|
|
|
|
|
|
|