diff --git a/banban-mini/src/pages/chat/detail/index.tsx b/banban-mini/src/pages/chat/detail/index.tsx index 3b0866b..c4bf853 100644 --- a/banban-mini/src/pages/chat/detail/index.tsx +++ b/banban-mini/src/pages/chat/detail/index.tsx @@ -173,6 +173,7 @@ function getAudioUrlDebugInfo(rawUrl: string) { } catch { host = '' } + return { rawUrl, protocol: protocolMatch?.[1]?.toLowerCase() || '', @@ -249,31 +250,30 @@ export default function ChatDetail() { useEffect(() => { if (typeof Taro.createInnerAudioContext !== 'function') { - console.warn('[audio] InnerAudioContext unavailable', runtimeInfoRef.current) - return + console.warn('[audio] InnerAudioContext unavailable'); + return; } - const audioContext = Taro.createInnerAudioContext() - audioContextRef.current = audioContext + // 关键1: 忽略 iOS 静音开关 + Taro.setInnerAudioOption({ obeyMuteSwitch: false }); + + // 关键2: 使用 useWebAudioImplement 尝试绕过原生问题 + const audioContext = Taro.createInnerAudioContext({ + useWebAudioImplement: true, // 基础库 2.19.0+ + }); + audioContextRef.current = audioContext; audioContext.onEnded(() => { - console.info('[audio] ended', { playingMessageId: playingMessageIdRef.current }) - setPlayingMessageId(null) - }) + setPlayingMessageId(null); + }); audioContext.onStop(() => { - console.info('[audio] stopped', { playingMessageId: playingMessageIdRef.current }) - setPlayingMessageId(null) - }) + setPlayingMessageId(null); + }); audioContext.onError((error) => { - setPlayingMessageId(null) - console.error('[audio] error', { - playingMessageId: playingMessageIdRef.current, - src: audioContext.src, - error, - runtime: runtimeInfoRef.current, - }) - Taro.showToast({ title: '语音播放失败', icon: 'none' }) - }) + console.error('[audio] error detail:', JSON.stringify(error)); + setPlayingMessageId(null); + Taro.showToast({ title: `播放失败: ${error.errMsg || '错误'}`, icon: 'none' }); + }); audioContext.onPlay(() => { console.info('[audio] play event', { playingMessageId: playingMessageIdRef.current, src: audioContext.src }) }) diff --git a/talkingq-url/banban/middleware/auth.py b/talkingq-url/banban/middleware/auth.py index 152115c..9149399 100644 --- a/talkingq-url/banban/middleware/auth.py +++ b/talkingq-url/banban/middleware/auth.py @@ -187,7 +187,7 @@ def install_auth_middleware(app: FastAPI) -> None: if not await is_device_sleep(device_id): return JSONResponse( status_code=400, # 或 403 / 409 - content={"detail": f"设备 {device_id} 不在线或已配置睡眠时间,请稍后再试"} + content={"detail": f"设备不在线或在休眠中"} ) else: # 路径格式不符合预期,可以放行或返回错误(根据业务决定)