'commit'
This commit is contained in:
@@ -441,11 +441,11 @@
|
||||
generateMusicBtn.disabled = false;
|
||||
generateMusicBtn.innerHTML = '<i class="fas fa-play"></i> 生成音乐';
|
||||
|
||||
if (data.id) {
|
||||
if (data.data && data.data.task_id) {
|
||||
// 跳转到进度页面
|
||||
window.location.href = `/static/Suno/music_progress.html?task_id=${data.id}`;
|
||||
window.location.href = `/static/Suno/music_progress.html?task_id=${data.data.task_id}`;
|
||||
} else {
|
||||
alert('生成音乐任务失败: ' + (data.error || '未知错误'));
|
||||
alert('生成音乐任务失败: ' + (data.error || data.message || '未知错误'));
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
|
@@ -76,9 +76,12 @@
|
||||
const progressFill = document.getElementById('progressFill');
|
||||
const progressText = document.getElementById('progressText');
|
||||
|
||||
if (data.status === 'error') {
|
||||
// 正确获取数据部分
|
||||
const responseData = data.data || data;
|
||||
|
||||
if (responseData.status === 'error') {
|
||||
clearInterval(progressInterval);
|
||||
statusMessage.innerHTML = `<i class="fas fa-exclamation-circle"></i> 生成失败: ${data.error || '未知错误'}`;
|
||||
statusMessage.innerHTML = `<i class="fas fa-exclamation-circle"></i> 生成失败: ${responseData.error || responseData.error_message || '未知错误'}`;
|
||||
statusMessage.style.backgroundColor = '#ffebee';
|
||||
statusMessage.style.borderColor = '#ef9a9a';
|
||||
return;
|
||||
@@ -87,22 +90,24 @@
|
||||
statusMessage.innerHTML = `<i class="fas fa-spinner fa-spin"></i> ${data.message || '正在生成音乐...'}`;
|
||||
|
||||
// 更新进度条
|
||||
if (data.progress) {
|
||||
progress = Math.min(data.progress, 100);
|
||||
} else if (data.status === 'completed') {
|
||||
if (responseData.progress) {
|
||||
progress = Math.min(responseData.progress, 100);
|
||||
} else if (responseData.status === 'completed') {
|
||||
progress = 100;
|
||||
} else if (data.status === 'processing') {
|
||||
// 如果没有具体进度,模拟进度增加
|
||||
if (progress < 90) {
|
||||
progress += 1;
|
||||
} else if (responseData.status === 'processing') {
|
||||
// 改进模拟进度增加逻辑
|
||||
if (progress < 95) {
|
||||
progress += 0.5;
|
||||
} else if (progress < 100) {
|
||||
progress += 0.1;
|
||||
}
|
||||
}
|
||||
|
||||
progressFill.style.width = `${progress}%`;
|
||||
progressText.textContent = `${progress}%`;
|
||||
progressText.textContent = `${Math.round(progress)}%`;
|
||||
|
||||
// 任务完成
|
||||
if (data.status === 'completed') {
|
||||
if (responseData.status === 'completed') {
|
||||
clearInterval(progressInterval);
|
||||
statusMessage.innerHTML = '<i class="fas fa-check-circle"></i> 音乐生成完成!';
|
||||
statusMessage.style.backgroundColor = '#e8f5e9';
|
||||
@@ -113,9 +118,9 @@
|
||||
playerContainer.style.display = 'block';
|
||||
|
||||
// 设置音乐标题和源
|
||||
document.getElementById('musicTitle').textContent = data.title || '生成的音乐';
|
||||
document.getElementById('musicTitle').textContent = responseData.title || '生成的音乐';
|
||||
const audioSource = document.getElementById('audioSource');
|
||||
audioSource.src = data.audio_url || '';
|
||||
audioSource.src = responseData.audio_url || '';
|
||||
document.getElementById('audioPlayer').load();
|
||||
}
|
||||
})
|
||||
|
Reference in New Issue
Block a user