/** * 教师端功能管理 */ class TeacherManager { constructor() { this.apiBase = '/api/teacher'; this.init(); } init() { this.initDashboard(); this.updateCurrentTime(); setInterval(() => this.updateCurrentTime(), 1000); } updateCurrentTime() { const timeElement = document.getElementById('currentTime'); if (timeElement) { const now = new Date(); const options = { year: 'numeric', month: 'long', day: 'numeric', hour: '2-digit', minute: '2-digit', second: '2-digit' }; timeElement.textContent = now.toLocaleString('zh-CN', options); } } async initDashboard() { // 检查是否在仪表板页面 if (!document.getElementById('courseList')) return; try { const response = await fetch(`${this.apiBase}/courses`); const result = await response.json(); if (result.success) { this.renderDashboard(result.data.courses); } else { if (window.authManager) { window.authManager.showNotification(result.message || '获取课程失败', 'error'); } } } catch (error) { console.error('Fetch teacher data failed:', error); } } renderDashboard(courses) { const courseList = document.getElementById('courseList'); if (!courseList) return; if (!courses || courses.length === 0) { courseList.innerHTML = '