This commit is contained in:
Your Name
2026-04-11 18:06:02 +08:00
parent 4909ec6daa
commit abcecf66e7
325 changed files with 4199 additions and 633 deletions
+38 -15
View File
@@ -16,25 +16,49 @@ export function formatBizTime(t: unknown): string | undefined {
}
export function parseRtcInner(inner: Record<string, unknown>): FriendlyParse {
const callType = inner.call_type
const callType = inner.call_type ?? inner.callType ?? 2
const callTypeLabel =
callType === 2 ? '视频通话' : callType === 1 ? '语音通话' : '通话'
const cmd = String(inner.cmd || '')
callType === 2 ? '视频' : callType === 1 ? '语音通话' : '通话'
let cmd = String(inner.cmd || inner.action || '').toLowerCase()
if (!cmd) {
const at = Number(inner.actionType ?? inner.action_type ?? inner.call_action)
if (at === 1) cmd = 'invite'
else if (at === 2) cmd = 'cancel'
else if (at === 3) cmd = 'accept'
else if (at === 4) cmd = 'reject'
else if (at === 5) cmd = 'timeout'
else if (at === 6) cmd = 'hangup'
else if (at === 7) cmd = 'linebusy'
}
const cmdMap: Record<string, string> = {
hangup: '已结束',
invite: '发起通话',
linebusy: '对方忙线',
cancel: '已取消',
reject: '已拒绝',
cancel: '已取消呼叫',
reject: '已拒绝接听',
accept: '已接听',
timeout: '无人接听'
}
const action = cmdMap[cmd] || (cmd ? `状态:${cmd}` : '')
const main = action ? `${callTypeLabel} · ${action}` : callTypeLabel
// 如果有通话时长,追加显示
const duration = Number(inner.duration ?? inner.call_duration)
const durationText = (duration > 0 && (action === '已结束' || action === '已挂断')) ? ` (${Math.floor(duration / 60)}${duration % 60}秒)` : ''
const main = action ? `${callTypeLabel} · ${action}${durationText}` : callTypeLabel
const parts: string[] = []
if (inner.inviter) parts.push(`发起方 ${inner.inviter}`)
if (inner.invitee) parts.push(`对方 ${inner.invitee}`)
if (inner.groupID) parts.push(`群组 ${inner.groupID}`)
//if (inner.inviter) parts.push(`发起方: ${inner.inviter}`)
if (inner.invitee) parts.push(`对方: ${inner.invitee}`)
if (inner.groupID) parts.push(`群组: ${inner.groupID}`)
// 强制输出兜底调试信息(仅未识别到 action 时触发)
if (!action) {
const dbg = JSON.stringify(inner).replace(/"/g, '')
parts.push(`(原始参数: ${dbg})`)
}
return {
main,
sub: parts.length ? parts.join('') : undefined,
@@ -83,19 +107,18 @@ export function parseImBusinessPayload(raw: string): FriendlyParse | null {
return { main: '问诊已完成', sub: formatBizTime(o.time), tag: '诊室' }
}
if (o.businessID === 1 || o.businessID === '1') {
if (o.businessID === 1 || o.businessID === '1' || o.businessID === 'av_call') {
let inner: unknown = o.data
if (typeof inner === 'string') {
try {
inner = JSON.parse(inner)
} catch {
return { main: '通话信令', sub: '内层数据解析失败', tag: '通话' }
// fallback
}
}
if (inner && typeof inner === 'object') {
return parseRtcInner(inner as Record<string, unknown>)
}
return null
// 深远兼容:合并外层字段和 data 层字段,避免各端版本取参有遗漏
const merged = { ...o, ...(typeof inner === 'object' && inner ? inner : {}) }
return parseRtcInner(merged as Record<string, unknown>)
}
if (o.businessID === 'rtc_call' || o.cmd) {