本周任务:完成历史记录功能(2)
播放功能
在每条信息下新增播放按钮
按钮调用函数
async playAudio (blob) {
// 将 Blob 转换为 URL
console.log(blob)
if (typeof blob === 'string') {
const binary = atob(blob)
const array = []
for (let i = 0; i < binary.length; i++) {
array.push(binary.charCodeAt(i))
}
blob = new Blob([new Uint8Array(array)], { type: 'audio/wav' })
}
if (!(blob instanceof Blob)) {
console.error('The provided data is not a Blob')
return
}
const url = URL.createObjectURL(blob)
// 创建音频对象
const audio = new Audio(url)
console.log('begin')
// 播放音频
audio.play()
// 处理音频播放结束后的清理工作
audio.onended = () => {
URL.revokeObjectURL(url) // 释放 URL 对象
}
},
查看详情功能
查看考试评价与成绩
在考试时间下新增查看详情按钮
点击后可查看考试评价与成绩
前端实现:
删除功能
通过返回当前记录的examid,从数据库中刷新该页面