| | |
| | | import useAppStore from "../store/modules/app/index.js"; |
| | | import websocketService from "@/utils/websocket.js"; |
| | | // #ifdef APP-PLUS |
| | | import { openDialog, allowFloat, getBatteryCapacity } from '@/uni_modules/lgh-dialog' |
| | | import { openDialog, allowFloat, getBatteryCapacity, showIncomingCallNotification, cancelIncomingCallNotification } from '@/uni_modules/lgh-dialog' |
| | | // #endif |
| | | export function useGlobalWS() { |
| | | const userStore = useUserStore(); |
| | |
| | | // 处理语音通话请求 |
| | | if (t === 'call') { |
| | | console.log('📞 全局收到来电 call,来自', payload.from) |
| | | // 播放铃声 |
| | | // playRingtone(); |
| | | // 触发震动 |
| | | triggerVibration(); |
| | | // 构建来电参数 |
| | |
| | | from: payload.from, |
| | | type: 'incoming' |
| | | }; |
| | | // #ifdef APP-PLUS |
| | | // #ifdef APP-PLUS |
| | | // 发送来电通知(锁屏/后台都会弹出 + 亮屏) |
| | | showIncomingCallNotification(payload.from || '未知来电') |
| | | // 拉起应用到前台 |
| | | openDialog() |
| | | // #endif |
| | | // 转义参数以便在URL中传递 |
| | |
| | | } |
| | | return |
| | | } |
| | | // 通话接听或结束时,取消来电通知 |
| | | if (t === 'accept' || t === 'reject' || t === 'hangup' || t === 'cancel') { |
| | | // #ifdef APP-PLUS |
| | | cancelIncomingCallNotification() |
| | | // #endif |
| | | } |
| | | } |
| | | |
| | | // 播放来电铃声 - 定义在 messageHandler 外部 |