This commit is contained in:
@@ -317,6 +317,9 @@ def project_detail_api(request, project_id):
|
|||||||
'auto_chapters_data': latest_task.auto_chapters_data
|
'auto_chapters_data': latest_task.auto_chapters_data
|
||||||
}
|
}
|
||||||
|
|
||||||
|
latest_task_any = TranscriptionTask.objects.filter(project=project).order_by('-created_at').first()
|
||||||
|
audio_url = latest_task_any.file_url if latest_task_any else None
|
||||||
|
|
||||||
data = {
|
data = {
|
||||||
'id': project.id,
|
'id': project.id,
|
||||||
'title': project.title,
|
'title': project.title,
|
||||||
@@ -326,6 +329,7 @@ def project_detail_api(request, project_id):
|
|||||||
'history_comments': history,
|
'history_comments': history,
|
||||||
'current_comment': current_comment,
|
'current_comment': current_comment,
|
||||||
'ai_result': ai_data,
|
'ai_result': ai_data,
|
||||||
|
'audio_url': audio_url,
|
||||||
'can_grade': role == 'judge' or (role == 'contestant' and project.contestant.user != user) # Contestant can grade others if allowed
|
'can_grade': role == 'judge' or (role == 'contestant' and project.contestant.user != user) # Contestant can grade others if allowed
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -89,6 +89,13 @@
|
|||||||
<div id="modalDesc" class="bg-gray-50 p-4 rounded-lg text-gray-700 text-sm leading-relaxed border border-gray-100 max-h-48 overflow-y-auto"></div>
|
<div id="modalDesc" class="bg-gray-50 p-4 rounded-lg text-gray-700 text-sm leading-relaxed border border-gray-100 max-h-48 overflow-y-auto"></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<h4 class="text-lg font-semibold text-gray-900 mb-3 flex items-center"><i class="fas fa-headphones mr-2 text-blue-500"></i>项目录音</h4>
|
||||||
|
<div id="modalAudioSection" class="bg-gray-50 p-4 rounded-lg border border-gray-100 flex items-center justify-center min-h-[80px]">
|
||||||
|
<!-- Audio player or "No audio" message will be injected here -->
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div id="aiResultSection" style="display:none;" class="border border-indigo-100 rounded-xl overflow-hidden">
|
<div id="aiResultSection" style="display:none;" class="border border-indigo-100 rounded-xl overflow-hidden">
|
||||||
<div class="bg-indigo-50 px-4 py-3 border-b border-indigo-100 flex items-center">
|
<div class="bg-indigo-50 px-4 py-3 border-b border-indigo-100 flex items-center">
|
||||||
<i class="fas fa-robot text-indigo-600 mr-2"></i>
|
<i class="fas fa-robot text-indigo-600 mr-2"></i>
|
||||||
@@ -252,7 +259,14 @@ function updateFileName(input) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function closeModal(id) {
|
function closeModal(id) {
|
||||||
document.getElementById(id).classList.remove('active');
|
const modal = document.getElementById(id);
|
||||||
|
modal.classList.remove('active');
|
||||||
|
|
||||||
|
// Stop audio if it's playing when modal is closed
|
||||||
|
const audios = modal.querySelectorAll('audio');
|
||||||
|
audios.forEach(audio => {
|
||||||
|
audio.pause();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function openUploadModal() {
|
function openUploadModal() {
|
||||||
@@ -320,6 +334,27 @@ async function viewProject(id) {
|
|||||||
document.getElementById('modalContestant').innerText = data.contestant_name;
|
document.getElementById('modalContestant').innerText = data.contestant_name;
|
||||||
document.getElementById('modalDesc').innerHTML = data.description || '<span class="text-gray-400 italic">暂无简介</span>';
|
document.getElementById('modalDesc').innerHTML = data.description || '<span class="text-gray-400 italic">暂无简介</span>';
|
||||||
|
|
||||||
|
// Render Audio Player
|
||||||
|
const audioSection = document.getElementById('modalAudioSection');
|
||||||
|
if (data.audio_url) {
|
||||||
|
audioSection.innerHTML = `
|
||||||
|
<audio controls class="w-full">
|
||||||
|
<source src="${data.audio_url}" type="audio/mpeg">
|
||||||
|
<source src="${data.audio_url}" type="audio/mp4">
|
||||||
|
您的浏览器不支持音频播放。
|
||||||
|
</audio>
|
||||||
|
`;
|
||||||
|
audioSection.classList.remove('justify-center');
|
||||||
|
} else {
|
||||||
|
audioSection.innerHTML = `
|
||||||
|
<div class="text-center text-gray-400 py-2">
|
||||||
|
<i class="fas fa-microphone-slash text-2xl mb-2 block"></i>
|
||||||
|
<span class="text-sm">暂未上传录音</span>
|
||||||
|
</div>
|
||||||
|
`;
|
||||||
|
audioSection.classList.add('justify-center');
|
||||||
|
}
|
||||||
|
|
||||||
// AI Result
|
// AI Result
|
||||||
const aiSection = document.getElementById('aiResultSection');
|
const aiSection = document.getElementById('aiResultSection');
|
||||||
if (data.ai_result) {
|
if (data.ai_result) {
|
||||||
|
|||||||
Reference in New Issue
Block a user