feat: 完成见素起名小程序核心功能
- 实现 AI 起名功能(Kimi API 接入) - 添加用户收藏功能(MySQL 数据库) - 实现海报生成与分享 - 添加音效和触觉反馈 - 配置生产环境部署(WAR 包 + Nginx) - 支持多种起名模式(经典、诗词、自然、现代) - 实现分批加载优化体验
This commit is contained in:
@@ -2,25 +2,38 @@ App({
|
||||
onLaunch() {
|
||||
// 初始化音效上下文
|
||||
this.globalData.audioContexts = {
|
||||
flip: wx.createInnerAudioContext(),
|
||||
success: wx.createInnerAudioContext()
|
||||
flip: wx.createInnerAudioContext(), // 翻页声
|
||||
success: wx.createInnerAudioContext(), // 收藏成功
|
||||
inkDrop: wx.createInnerAudioContext(), // 水滴声
|
||||
swipe: wx.createInnerAudioContext() // 滑动切换
|
||||
};
|
||||
|
||||
// 预设音效资源 (用户可替换为本地或云端 URL)
|
||||
// 示例使用了一些开源的基础音效,仅作占位参考
|
||||
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.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();
|
||||
ctx.play().catch(err => {
|
||||
console.log('音效播放失败:', err);
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
globalData: {
|
||||
audioContexts: {}
|
||||
audioContexts: {},
|
||||
// API 基础地址 - 修改这里即可切换环境
|
||||
// apiBaseUrl: 'http://localhost:8080'
|
||||
apiBaseUrl: 'https://feast.yidaima.cn/jsu'
|
||||
// 生产环境:'https://api.yourdomain.com'
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user