mirror of
https://github.com/Cola-Echo/Cola.git
synced 2026-06-06 11:55:51 +00:00
Add files via upload
This commit is contained in:
4
chat.js
4
chat.js
@@ -886,9 +886,9 @@ export function renderChatHistory(contact, chatHistory, indexOffset = 0) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 检查是否是通话记录消息
|
// 检查是否是通话记录消息(排除实时语音)
|
||||||
const callRecordMatch = (msg.content || '').match(/^\[通话记录[::](.+?)\]$/);
|
const callRecordMatch = (msg.content || '').match(/^\[通话记录[::](.+?)\]$/);
|
||||||
if (msg.isCallRecord || callRecordMatch) {
|
if ((msg.isCallRecord && !msg.isRealVoice) || callRecordMatch) {
|
||||||
const callInfo = callRecordMatch ? callRecordMatch[1] : '00:00';
|
const callInfo = callRecordMatch ? callRecordMatch[1] : '00:00';
|
||||||
const isDuration = /^\d{2}:\d{2}$/.test(callInfo);
|
const isDuration = /^\d{2}:\d{2}$/.test(callInfo);
|
||||||
const isCancelled = callInfo === '已取消';
|
const isCancelled = callInfo === '已取消';
|
||||||
|
|||||||
@@ -79,6 +79,8 @@ export function startRealVoiceCall(initiator = 'user', contactIndex = currentCha
|
|||||||
callState.isProcessing = false;
|
callState.isProcessing = false;
|
||||||
callState.isPlaying = false;
|
callState.isPlaying = false;
|
||||||
callState.recorder = new AudioRecorder();
|
callState.recorder = new AudioRecorder();
|
||||||
|
callState.voiceCache = []; // 重置语音缓存
|
||||||
|
callState.isHangingUp = false; // 重置挂断标志
|
||||||
|
|
||||||
showCallPage();
|
showCallPage();
|
||||||
startConnecting();
|
startConnecting();
|
||||||
@@ -723,6 +725,14 @@ export async function hangupCall() {
|
|||||||
if (callState.isHangingUp) return;
|
if (callState.isHangingUp) return;
|
||||||
callState.isHangingUp = true;
|
callState.isHangingUp = true;
|
||||||
|
|
||||||
|
// 先保存需要的值(后面状态会变)
|
||||||
|
const wasConnected = callState.isConnected;
|
||||||
|
const cachedVoices = callState.voiceCache ? [...callState.voiceCache] : [];
|
||||||
|
const contactIdx = callState.contactIndex;
|
||||||
|
const callTimestamp = callState.startTime || Date.now();
|
||||||
|
|
||||||
|
console.log('[可乐] 挂断时状态:', { wasConnected, voiceCacheLength: cachedVoices.length });
|
||||||
|
|
||||||
// 停止录音
|
// 停止录音
|
||||||
if (callState.recorder) {
|
if (callState.recorder) {
|
||||||
callState.recorder.cancel();
|
callState.recorder.cancel();
|
||||||
@@ -853,12 +863,10 @@ export async function hangupCall() {
|
|||||||
clearInterval(callState.timerInterval);
|
clearInterval(callState.timerInterval);
|
||||||
clearInterval(callState.dotsInterval);
|
clearInterval(callState.dotsInterval);
|
||||||
|
|
||||||
// 如果有缓存的语音,显示保存弹窗
|
// 如果有缓存的语音,显示保存弹窗(使用之前保存的变量,因为 callState 可能已被修改)
|
||||||
if (callState.voiceCache && callState.voiceCache.length > 0 && callState.isConnected) {
|
console.log('[可乐] 检查是否显示语音保存弹窗:', { wasConnected, cachedVoicesLength: cachedVoices.length });
|
||||||
const callTimestamp = callState.startTime || Date.now();
|
|
||||||
const contactIdx = callState.contactIndex;
|
|
||||||
const cachedVoices = [...callState.voiceCache]; // 复制一份
|
|
||||||
|
|
||||||
|
if (cachedVoices.length > 0 && wasConnected) {
|
||||||
// 重置状态
|
// 重置状态
|
||||||
resetCallState();
|
resetCallState();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user