feat: port duck quack sound (Ya1/Ya2) + system.audio lazy playback on mascot tap

This commit is contained in:
2026-09-01 20:14:50 +08:00
parent 96e13a85b5
commit 8667a47c20
4 changed files with 26 additions and 2 deletions
Binary file not shown.
Binary file not shown.
+2 -1
View File
@@ -11,7 +11,8 @@
], ],
"features": [ "features": [
{ "name": "system.router" }, { "name": "system.router" },
{ "name": "system.interconnect" } { "name": "system.interconnect" },
{ "name": "system.audio" }
], ],
"config": { "config": {
"logLevel": "log", "logLevel": "log",
+24 -1
View File
@@ -18,6 +18,28 @@
</template> </template>
<script> <script>
// 懒加载 @system.audio,避免模拟器/无扬声器时崩
let audioModule = null
let audioTried = false
function loadAudio() {
if (audioTried) return audioModule
audioTried = true
try {
audioModule = require('@system.audio')
} catch (e) {
audioModule = null
}
return audioModule
}
function playDuckSound() {
const a = loadAudio()
if (!a) return
try {
a.src = '/common/Ya1.mp3'
a.play()
} catch (e) {}
}
export default { export default {
private: { private: {
isPeak: false, isPeak: false,
@@ -59,7 +81,8 @@ export default {
}, },
onTap() { onTap() {
// Q 弹互动 // Q 弹互动 + 小黄鸭叫声(无扬声器时静默)
playDuckSound()
this.tapAnim = true this.tapAnim = true
const self = this const self = this
setTimeout(() => { self.tapAnim = false }, 400) setTimeout(() => { self.tapAnim = false }, 400)