两层原因都修:
1. 微信限制(声明后台音频权限):
InnerAudioContext 默认在小程序进后台时被强制暂停。
必须显式声明 requiredBackgroundModes,iOS 才允许后台继续发声。
- manifest.json mp-weixin 全局加 requiredBackgroundModes:["audio"]
- pages.json 节拍器页 style 也加,双保险
说明:Android 大部分情况无需此声明也能后台,iOS 必需。
2. 代码层(onHide 不再主动 stop):
原 onHide 里 if(isPlaying) stop() 会在切后台/小窗时
立刻把节拍器自己关掉,跟需求相反。
新策略:
- onHide 留空 → 切后台/小窗时节拍器继续工作
- onUnmounted 才真正 stop + 释放屏幕常亮 → 用户主动离开
节拍器页(navigateBack/重启)时清理资源
实际场景:健走时把手机塞口袋,锁屏或切到微信聊天,
节拍声依然继续响,无需把手机一直拿着看。
Co-authored-by: Cursor <cursoragent@cursor.com>
156 lines
2.9 KiB
JSON
156 lines
2.9 KiB
JSON
{
|
|
"pages": [
|
|
{
|
|
"path": "pages/index/index",
|
|
"style": {
|
|
"navigationBarTitleText": "甄养堂"
|
|
}
|
|
},
|
|
{
|
|
"path": "pages/login/login",
|
|
"style": {
|
|
"navigationBarTitleText": "视频问诊"
|
|
}
|
|
},
|
|
{
|
|
"path": "pages/user/userinfo",
|
|
"style": {
|
|
"navigationBarTitleText": "个人资料"
|
|
}
|
|
},
|
|
{
|
|
"path": "pages/index/video",
|
|
"style": {
|
|
"navigationBarTitleText": "甄养堂"
|
|
}
|
|
},
|
|
{
|
|
"path": "TUICallKit/src/Components/TUICallKit",
|
|
"style": {
|
|
"navigationBarTitleText": "视频问诊",
|
|
"navigationBarHidden": true,
|
|
"navigationStyle": "custom"
|
|
}
|
|
},
|
|
{
|
|
"path": "pages/order/monad/monad",
|
|
"style": {
|
|
"navigationBarTitleText": "诊单确认",
|
|
"navigationBarHidden": true,
|
|
"navigationStyle": "custom"
|
|
}
|
|
},
|
|
{
|
|
"path": "pages/user/user",
|
|
"style": {
|
|
"navigationBarTitleText": "我的"
|
|
}
|
|
},
|
|
{
|
|
"path": "pages/Card/Card",
|
|
"style": {
|
|
"navigationBarTitleText": "就诊卡"
|
|
}
|
|
},
|
|
{
|
|
"path": "pages/Card/edit_card",
|
|
"style": {
|
|
"navigationBarTitleText": "修改就诊卡"
|
|
}
|
|
},
|
|
{
|
|
"path": "pages/Card/contact",
|
|
"style": {
|
|
"navigationBarTitleText": "服务"
|
|
}
|
|
},
|
|
{
|
|
"path": "pages/order/order",
|
|
"style": {
|
|
"navigationBarTitleText": "付款"
|
|
}
|
|
}
|
|
],
|
|
"subPackages": [
|
|
{
|
|
"root": "TUIKit",
|
|
"pages": [
|
|
{
|
|
"path": "pages/chat/chat",
|
|
"style": {
|
|
"navigationBarTitleText": "问诊"
|
|
}
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"root": "doctor",
|
|
"pages": [
|
|
{
|
|
"path": "pages/doctor/doctor",
|
|
"style": {
|
|
"navigationBarTitleText": "医生信息"
|
|
}
|
|
},
|
|
{
|
|
"path": "pages/doctor/list/list",
|
|
"style": {
|
|
"navigationBarTitleText": "执业医生列表"
|
|
}
|
|
},
|
|
{
|
|
"path": "pages/article/article",
|
|
"style": {
|
|
"navigationBarTitleText": "健康百科"
|
|
}
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"root": "training",
|
|
"pages": [
|
|
{
|
|
"path": "pages/index",
|
|
"style": {
|
|
"navigationBarTitleText": "练一练"
|
|
}
|
|
},
|
|
{
|
|
"path": "pages/metronome",
|
|
"style": {
|
|
"navigationBarTitleText": "节拍器",
|
|
"navigationBarBackgroundColor": "#f8fafc",
|
|
"navigationBarTextStyle": "black",
|
|
"backgroundColor": "#f8fafc",
|
|
"disableScroll": true,
|
|
"requiredBackgroundModes": ["audio"]
|
|
}
|
|
}
|
|
]
|
|
}
|
|
],
|
|
"tabBar": {
|
|
"color": "#8a8a8a",
|
|
"selectedColor": "#204e2b",
|
|
"borderStyle": "black",
|
|
"backgroundColor": "#ffffff",
|
|
"list": [{
|
|
"pagePath": "pages/index/index",
|
|
"iconPath": "/static/user/home.png",
|
|
"selectedIconPath": "/static/user/home_no.png",
|
|
"text": "首页"
|
|
},{
|
|
"pagePath": "pages/user/user",
|
|
"iconPath": "/static/user/user.png",
|
|
"selectedIconPath": "/static/user/user_no.png",
|
|
"text": "我的"
|
|
}]
|
|
},
|
|
"globalStyle": {
|
|
"navigationBarTextStyle": "black",
|
|
"navigationBarTitleText": "甄养堂互联网医院",
|
|
"navigationBarBackgroundColor": "#F8F8F8",
|
|
"backgroundColor": "#F8F8F8"
|
|
}
|
|
}
|