This commit is contained in:
2025-08-21 14:36:24 +08:00
parent 1ede8c33a2
commit 7704905d82

View File

@@ -241,7 +241,7 @@
instruments: "吉他+贝斯+鼓",
theme: "快乐学习",
teachingSubject: "英语",
duration: 2 // 添加时长字段
duration: 1 // 添加时长字段
},
{
style: "古风",
@@ -251,7 +251,7 @@
instruments: "笛子+古筝",
theme: "诗词歌赋",
teachingSubject: "语文",
duration: 3 // 添加时长字段
duration: 1 // 添加时长字段
},
{
style: "Classical",
@@ -261,7 +261,7 @@
instruments: "钢琴弦乐",
theme: "数学的旋律",
teachingSubject: "数学",
duration: 4 // 添加时长字段
duration: 1 // 添加时长字段
},
{
style: "民谣",
@@ -271,7 +271,7 @@
instruments: "木吉他主奏",
theme: "自然科学的奥秘",
teachingSubject: "科学", // 保留一个teachingSubject属性
duration: 2
duration: 1
},
{
style: "City Pop",
@@ -281,7 +281,7 @@
instruments: "电子合成器",
theme: "阳光沙滩海浪",
teachingSubject: "地理", // 保留一个teachingSubject属性
duration: 2
duration: 1
},
{
style: "电子 R&B",
@@ -291,7 +291,7 @@
instruments: "808 鼓点+萨克斯",
theme: "历史的回声",
teachingSubject: "历史", // 保留一个teachingSubject属性
duration: 2
duration: 1
},
{
style: "摇滚",
@@ -301,7 +301,7 @@
instruments: "吉他+贝斯+鼓",
theme: "运动精神",
teachingSubject: "体育", // 保留一个teachingSubject属性
duration: 2
duration: 1
},
{
style: "爵士",
@@ -311,7 +311,7 @@
instruments: "钢琴弦乐",
theme: "艺术欣赏",
teachingSubject: "美术", // 保留一个teachingSubject属性
duration: 2
duration: 1
}
];
@@ -379,11 +379,38 @@
// 复制结果按钮点击事件
copyResultBtn.addEventListener('click', function() {
const textToCopy = resultContent.textContent;
navigator.clipboard.writeText(textToCopy).then(function() {
alert('提示词已复制到剪贴板!');
}).catch(function(err) {
alert('复制失败: ' + err);
});
// 优先使用clipboard API
if (navigator.clipboard) {
navigator.clipboard.writeText(textToCopy).then(function() {
alert('提示词已复制到剪贴板!');
}).catch(function(err) {
// 失败时使用备用方法
fallbackCopyText(textToCopy);
});
} else {
// 不支持clipboard API时直接使用备用方法
fallbackCopyText(textToCopy);
}
// 备用复制方法
function fallbackCopyText(text) {
const textArea = document.createElement('textarea');
textArea.value = text;
textArea.style.position = 'fixed'; // 避免滚动到视图外
document.body.appendChild(textArea);
textArea.select();
try {
const successful = document.execCommand('copy');
const msg = successful ? '提示词已复制到剪贴板!' : '复制失败,请手动复制';
alert(msg);
} catch (err) {
alert('复制失败: ' + err);
}
document.body.removeChild(textArea);
}
});
// 生成音乐按钮点击事件