diff --git a/yunkes/src/api/types.ts b/yunkes/src/api/types.ts index ce49ede..e76c648 100644 --- a/yunkes/src/api/types.ts +++ b/yunkes/src/api/types.ts @@ -136,6 +136,8 @@ export interface PhoneCall { sim_phone?: string | null /** OSS URL of the recording — present only when a recording exists. */ record_file?: string | null + /** sha256 media_hash of the localized recording (NULL until downloaded). */ + record_media_hash?: string | null /** * Verbatim upstream call record (camelCase keys: id/startCallTime, * callDuration/callSeconds/ringTime, callStatus/incomingCall, userId/ diff --git a/yunkes/src/utils/callFields.ts b/yunkes/src/utils/callFields.ts index b8cbddc..79c0338 100644 --- a/yunkes/src/utils/callFields.ts +++ b/yunkes/src/utils/callFields.ts @@ -211,6 +211,14 @@ export function toDisplayField(c: PhoneCall, camelKey: string): DisplayField { if (value === null || value === undefined || value === '') { return { key: camelKey, label, value, render: 'empty', text: '' } } + // 录音:优先本地化的 media_hash(/api/media/{hash}),否则原 OSS URL + if (camelKey === 'recordFile') { + const local = c.record_media_hash ? `/api/media/${c.record_media_hash}` : null + const url = local ?? (typeof value === 'string' && value ? value : null) + if (url) { + return { key: camelKey, label, value: url, render: 'audio', text: '' } + } + } if (AUDIO_KEYS.has(camelKey) && typeof value === 'string') { return { key: camelKey, label, value, render: 'audio', text: '' } } diff --git a/yunkes/src/views/CallList.vue b/yunkes/src/views/CallList.vue index 6177988..07513ab 100644 --- a/yunkes/src/views/CallList.vue +++ b/yunkes/src/views/CallList.vue @@ -90,10 +90,11 @@ function timeCell(row: PhoneCall, camelKey: string): number | undefined { } function playRecord(row: PhoneCall): void { + const local = row.record_media_hash ? `/api/media/${row.record_media_hash}` : null const file = - (typeof cell(row, 'recordFile') === 'string' - ? (cell(row, 'recordFile') as string) - : null) ?? row.record_file + local ?? + (typeof cell(row, 'recordFile') === 'string' ? (cell(row, 'recordFile') as string) : null) ?? + row.record_file if (!file) { ElMessage.info('该通话无录音文件') return @@ -185,7 +186,7 @@ onMounted(load) - 播放 + 播放 -- @@ -215,7 +216,7 @@ onMounted(load) {{ formatTime(row.start_call_time) }} - 播放录音 + 播放录音 无录音 @@ -251,7 +252,7 @@ onMounted(load)