mirror of
https://github.com/ExamAware/ExamSchedule.git
synced 2025-04-29 19:16:33 +00:00

* refactor: 史诗级重构拆分多年狮山代码 * style: 添加设置模态框淡出动画,优化关闭和保存设置的用户体验 * style: 添加错误提示系统,优化用户体验,处理设置和全屏操作中的异常 * feat: 添加主题切换功能,支持亮/暗色模式,优化用户界面 * chore: 测试配置 * feat: 更新亮色主题背景和透明度 * style: 滑块居右 * feat: 初步实现 全是Bug * feat: 添加提醒队列功能,支持音频预加载和配置导出 * feat: 优化文件输入和按钮样式,提升用户交互体验 * feat: 添加时间广播功能,优化错误提示系统,移除不必要的设置选项 * feat: 移除不再使用的音频文件,更新课程结束时间,优化音频文件加载和选择功能
64 lines
2.2 KiB
JavaScript
64 lines
2.2 KiB
JavaScript
document.getElementById('importJson').addEventListener('change', function(event) {
|
|
var files = event.target.files;
|
|
if (files.length > 0) {
|
|
Array.from(files).forEach(file => {
|
|
var reader = new FileReader();
|
|
reader.onload = function(e) {
|
|
try {
|
|
var config = JSON.parse(e.target.result);
|
|
applyConfig(config);
|
|
} catch (err) {
|
|
errorSystem.show('导入配置失败: ' + err.message, 'error');
|
|
}
|
|
};
|
|
reader.readAsText(file);
|
|
});
|
|
}
|
|
});
|
|
|
|
function applyConfig(config) {
|
|
try {
|
|
if (config.examInfos) {
|
|
courseSchedule = config.examInfos.map(function(exam) {
|
|
return {
|
|
name: exam.name,
|
|
start: exam.start,
|
|
end: exam.end
|
|
};
|
|
});
|
|
updateScheduleTable();
|
|
}
|
|
if (config.examName) {
|
|
document.title = config.examName;
|
|
}
|
|
if (config.message) {
|
|
document.getElementById('statusLabel').textContent = config.message;
|
|
}
|
|
if (config.room) {
|
|
document.getElementById('timeDescription').textContent = '考场: ' + config.room;
|
|
}
|
|
if (config.reminders) {
|
|
localStorage.setItem('reminders', JSON.stringify(config.reminders));
|
|
}
|
|
} catch (err) {
|
|
errorSystem.show('应用配置失败: ' + err.message, 'error');
|
|
}
|
|
}
|
|
|
|
function exportConfig() {
|
|
var config = {
|
|
examInfos: courseSchedule,
|
|
examName: document.title,
|
|
message: document.getElementById('statusLabel').textContent,
|
|
room: document.getElementById('timeDescription').textContent.replace('考场: ', ''),
|
|
reminders: JSON.parse(localStorage.getItem('reminders') || '[]')
|
|
};
|
|
var dataStr = "data:text/json;charset=utf-8," + encodeURIComponent(JSON.stringify(config));
|
|
var downloadAnchorNode = document.createElement('a');
|
|
downloadAnchorNode.setAttribute("href", dataStr);
|
|
downloadAnchorNode.setAttribute("download", "exam_config.json");
|
|
document.body.appendChild(downloadAnchorNode);
|
|
downloadAnchorNode.click();
|
|
downloadAnchorNode.remove();
|
|
}
|