mirror of
https://github.com/ExamAware/ExamSchedule.git
synced 2025-04-29 11:06:32 +00:00

* refactor: 史诗级重构拆分多年狮山代码 * style: 添加设置模态框淡出动画,优化关闭和保存设置的用户体验 * style: 添加错误提示系统,优化用户体验,处理设置和全屏操作中的异常 * feat: 添加主题切换功能,支持亮/暗色模式,优化用户界面 * chore: 测试配置 * feat: 更新亮色主题背景和透明度 * style: 滑块居右 * feat: 初步实现 全是Bug * feat: 添加提醒队列功能,支持音频预加载和配置导出 * feat: 优化文件输入和按钮样式,提升用户交互体验 * feat: 添加时间广播功能,优化错误提示系统,移除不必要的设置选项 * feat: 移除不再使用的音频文件,更新课程结束时间,优化音频文件加载和选择功能
46 lines
1.2 KiB
JavaScript
46 lines
1.2 KiB
JavaScript
var reminderQueue = (function() {
|
|
var queue = [];
|
|
var audioCache = {};
|
|
|
|
function addReminder(reminder) {
|
|
queue.push(reminder);
|
|
queue.sort(function(a, b) {
|
|
return a.time - b.time;
|
|
});
|
|
preloadAudio(reminder.audio);
|
|
}
|
|
|
|
function processQueue() {
|
|
var now = Date.now();
|
|
while (queue.length > 0 && queue[0].time <= now) {
|
|
var reminder = queue.shift();
|
|
executeReminder(reminder);
|
|
}
|
|
setTimeout(processQueue, 1000);
|
|
}
|
|
|
|
function executeReminder(reminder) {
|
|
if (audioCache[reminder.audio]) {
|
|
audioCache[reminder.audio].play();
|
|
} else if (audioController.getAudioSrc(reminder.audio)) {
|
|
audioController.play(reminder.audio);
|
|
} else {
|
|
errorSystem.show('音频文件不存在: ' + reminder.audio, 'error');
|
|
}
|
|
}
|
|
|
|
function preloadAudio(audioType) {
|
|
if (!audioCache[audioType] && audioController.getAudioSrc(audioType)) {
|
|
var audio = new Audio(audioController.getAudioSrc(audioType));
|
|
audioCache[audioType] = audio;
|
|
}
|
|
}
|
|
|
|
return {
|
|
addReminder: addReminder,
|
|
processQueue: processQueue
|
|
};
|
|
})();
|
|
|
|
reminderQueue.processQueue();
|