2026-04-16 11:25:29 +08:00
|
|
|
App({
|
|
|
|
|
onLaunch() {
|
|
|
|
|
// 初始化音效上下文
|
|
|
|
|
this.globalData.audioContexts = {
|
2026-04-17 15:34:51 +08:00
|
|
|
flip: wx.createInnerAudioContext(), // 翻页声
|
|
|
|
|
success: wx.createInnerAudioContext(), // 收藏成功
|
|
|
|
|
inkDrop: wx.createInnerAudioContext(), // 水滴声
|
|
|
|
|
swipe: wx.createInnerAudioContext() // 滑动切换
|
2026-04-16 11:25:29 +08:00
|
|
|
};
|
|
|
|
|
|
2026-04-17 15:34:51 +08:00
|
|
|
// 预设音效资源
|
|
|
|
|
// 翻页声 - 纸张摩擦
|
|
|
|
|
this.globalData.audioContexts.flip.src = 'https://assets.mixkit.co/active_storage/sfx/2571/2571-preview.mp3';
|
|
|
|
|
// 收藏成功 - 清脆铃声
|
|
|
|
|
this.globalData.audioContexts.success.src = 'https://assets.mixkit.co/active_storage/sfx/2000/2000-preview.mp3';
|
|
|
|
|
// 水滴声 - 水墨滴落
|
|
|
|
|
this.globalData.audioContexts.inkDrop.src = 'https://assets.mixkit.co/active_storage/sfx/2578/2578-preview.mp3';
|
|
|
|
|
// 滑动声
|
|
|
|
|
this.globalData.audioContexts.swipe.src = 'https://assets.mixkit.co/active_storage/sfx/2571/2571-preview.mp3';
|
2026-04-16 11:25:29 +08:00
|
|
|
},
|
|
|
|
|
|
|
|
|
|
playAudio(type) {
|
|
|
|
|
const ctx = this.globalData.audioContexts[type];
|
|
|
|
|
if (ctx) {
|
|
|
|
|
ctx.stop();
|
2026-04-17 15:34:51 +08:00
|
|
|
ctx.play().catch(err => {
|
|
|
|
|
console.log('音效播放失败:', err);
|
|
|
|
|
});
|
2026-04-16 11:25:29 +08:00
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
globalData: {
|
2026-04-17 15:34:51 +08:00
|
|
|
audioContexts: {},
|
|
|
|
|
// API 基础地址 - 修改这里即可切换环境
|
|
|
|
|
// apiBaseUrl: 'http://localhost:8080'
|
|
|
|
|
apiBaseUrl: 'https://feast.yidaima.cn/jsu'
|
|
|
|
|
// 生产环境:'https://api.yourdomain.com'
|
2026-04-16 11:25:29 +08:00
|
|
|
}
|
2026-04-17 15:34:51 +08:00
|
|
|
});
|