- 实现 AI 起名功能(Kimi API 接入) - 添加用户收藏功能(MySQL 数据库) - 实现海报生成与分享 - 添加音效和触觉反馈 - 配置生产环境部署(WAR 包 + Nginx) - 支持多种起名模式(经典、诗词、自然、现代) - 实现分批加载优化体验
40 lines
1.4 KiB
JavaScript
40 lines
1.4 KiB
JavaScript
App({
|
|
onLaunch() {
|
|
// 初始化音效上下文
|
|
this.globalData.audioContexts = {
|
|
flip: wx.createInnerAudioContext(), // 翻页声
|
|
success: wx.createInnerAudioContext(), // 收藏成功
|
|
inkDrop: wx.createInnerAudioContext(), // 水滴声
|
|
swipe: wx.createInnerAudioContext() // 滑动切换
|
|
};
|
|
|
|
// 预设音效资源
|
|
// 翻页声 - 纸张摩擦
|
|
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';
|
|
},
|
|
|
|
playAudio(type) {
|
|
const ctx = this.globalData.audioContexts[type];
|
|
if (ctx) {
|
|
ctx.stop();
|
|
ctx.play().catch(err => {
|
|
console.log('音效播放失败:', err);
|
|
});
|
|
}
|
|
},
|
|
|
|
globalData: {
|
|
audioContexts: {},
|
|
// API 基础地址 - 修改这里即可切换环境
|
|
// apiBaseUrl: 'http://localhost:8080'
|
|
apiBaseUrl: 'https://feast.yidaima.cn/jsu'
|
|
// 生产环境:'https://api.yourdomain.com'
|
|
}
|
|
});
|