|
|
@ -384,7 +384,7 @@ export default { |
|
|
method: "post", |
|
|
method: "post", |
|
|
data: replyMsgInfo |
|
|
data: replyMsgInfo |
|
|
}).then(res => { |
|
|
}).then(res => { |
|
|
console.log("自动回复发送成功", res); |
|
|
//console.log("自动回复发送成功", res); |
|
|
|
|
|
|
|
|
// 删除"正在输入"的临时消息 |
|
|
// 删除"正在输入"的临时消息 |
|
|
this.chatStore.deleteMessage(typingMessage, this.chat); |
|
|
this.chatStore.deleteMessage(typingMessage, this.chat); |
|
|
@ -429,7 +429,7 @@ export default { |
|
|
// recvId: this.mine.id, // 当前用户作为接收者 |
|
|
// recvId: this.mine.id, // 当前用户作为接收者 |
|
|
// type: autoReply.replyType, // 回复类型 |
|
|
// type: autoReply.replyType, // 回复类型 |
|
|
// }; |
|
|
// }; |
|
|
// console.log(replyMsgInfo) |
|
|
// //console.log(replyMsgInfo) |
|
|
// // 根据类型设置内容 |
|
|
// // 根据类型设置内容 |
|
|
// if (autoReply.replyType === 0) { |
|
|
// if (autoReply.replyType === 0) { |
|
|
// // 文本回复 |
|
|
// // 文本回复 |
|
|
@ -448,7 +448,7 @@ export default { |
|
|
// method: "post", |
|
|
// method: "post", |
|
|
// data: replyMsgInfo |
|
|
// data: replyMsgInfo |
|
|
// }).then(res => { |
|
|
// }).then(res => { |
|
|
// console.log("自动回复发送成功", res); |
|
|
// //console.log("自动回复发送成功", res); |
|
|
// // 消息会通过 WebSocket 推送过来,前端会自动接收并显示 |
|
|
// // 消息会通过 WebSocket 推送过来,前端会自动接收并显示 |
|
|
// }).catch(err => { |
|
|
// }).catch(err => { |
|
|
// console.error("自动回复发送失败", err); |
|
|
// console.error("自动回复发送失败", err); |
|
|
@ -1090,7 +1090,7 @@ export default { |
|
|
if (window.__isPasting__ === undefined) { |
|
|
if (window.__isPasting__ === undefined) { |
|
|
window.__isPasting__ = false; |
|
|
window.__isPasting__ = false; |
|
|
} |
|
|
} |
|
|
console.log('[chat-box] 首次添加粘贴事件监听器'); |
|
|
//console.log('[chat-box] 首次添加粘贴事件监听器'); |
|
|
|
|
|
|
|
|
// 移除所有可能的旧监听器 |
|
|
// 移除所有可能的旧监听器 |
|
|
if (this.pasteHandler) { |
|
|
if (this.pasteHandler) { |
|
|
@ -1117,7 +1117,7 @@ export default { |
|
|
async onDocumentPaste(e) { |
|
|
async onDocumentPaste(e) { |
|
|
// #ifdef H5 |
|
|
// #ifdef H5 |
|
|
const timestamp = new Date().toISOString(); |
|
|
const timestamp = new Date().toISOString(); |
|
|
console.log(`[${timestamp}] 粘贴事件触发, isPasting: ${window.__isPasting__}`); |
|
|
//console.log(`[${timestamp}] 粘贴事件触发, isPasting: ${window.__isPasting__}`); |
|
|
|
|
|
|
|
|
// 检查是否在editor中粘贴 |
|
|
// 检查是否在editor中粘贴 |
|
|
const activeElement = document.activeElement; |
|
|
const activeElement = document.activeElement; |
|
|
@ -1127,13 +1127,13 @@ export default { |
|
|
); |
|
|
); |
|
|
|
|
|
|
|
|
if (!isInEditor) { |
|
|
if (!isInEditor) { |
|
|
console.log(`[${timestamp}] 不在editor中,忽略`); |
|
|
//console.log(`[${timestamp}] 不在editor中,忽略`); |
|
|
return; |
|
|
return; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// 使用全局变量防止重复触发 |
|
|
// 使用全局变量防止重复触发 |
|
|
if (window.__isPasting__) { |
|
|
if (window.__isPasting__) { |
|
|
console.log(`[${timestamp}] 全局isPasting为true,忽略重复触发`); |
|
|
//console.log(`[${timestamp}] 全局isPasting为true,忽略重复触发`); |
|
|
e.preventDefault(); |
|
|
e.preventDefault(); |
|
|
e.stopPropagation(); |
|
|
e.stopPropagation(); |
|
|
return; |
|
|
return; |
|
|
@ -1145,7 +1145,7 @@ export default { |
|
|
for (let i = 0; i < items.length; i++) { |
|
|
for (let i = 0; i < items.length; i++) { |
|
|
const item = items[i]; |
|
|
const item = items[i]; |
|
|
if (item.kind === 'file' && item.type.startsWith('image/')) { |
|
|
if (item.kind === 'file' && item.type.startsWith('image/')) { |
|
|
console.log(`[${timestamp}] 检测到图片,开始处理`); |
|
|
//console.log(`[${timestamp}] 检测到图片,开始处理`); |
|
|
e.preventDefault(); |
|
|
e.preventDefault(); |
|
|
e.stopPropagation(); |
|
|
e.stopPropagation(); |
|
|
hasImage = true; |
|
|
hasImage = true; |
|
|
@ -1156,7 +1156,7 @@ export default { |
|
|
|
|
|
|
|
|
// 将文件转换为base64 |
|
|
// 将文件转换为base64 |
|
|
const base64 = await this.fileToBase64(file); |
|
|
const base64 = await this.fileToBase64(file); |
|
|
console.log(`[${timestamp}] base64转换完成,长度: ${base64.length}`); |
|
|
//console.log(`[${timestamp}] base64转换完成,长度: ${base64.length}`); |
|
|
|
|
|
|
|
|
// 创建临时文件对象 |
|
|
// 创建临时文件对象 |
|
|
const tempFile = { |
|
|
const tempFile = { |
|
|
@ -1169,7 +1169,7 @@ export default { |
|
|
// 调用现有的图片上传逻辑 |
|
|
// 调用现有的图片上传逻辑 |
|
|
await this.handlePasteImage(tempFile); |
|
|
await this.handlePasteImage(tempFile); |
|
|
} catch (error) { |
|
|
} catch (error) { |
|
|
console.log(`[${timestamp}] 处理粘贴图片失败:`, error); |
|
|
//console.log(`[${timestamp}] 处理粘贴图片失败:`, error); |
|
|
} finally { |
|
|
} finally { |
|
|
window.__isPasting__ = false; |
|
|
window.__isPasting__ = false; |
|
|
} |
|
|
} |
|
|
@ -1180,7 +1180,7 @@ export default { |
|
|
|
|
|
|
|
|
// 如果没有图片,立即重置标志 |
|
|
// 如果没有图片,立即重置标志 |
|
|
if (!hasImage) { |
|
|
if (!hasImage) { |
|
|
console.log(`[${timestamp}] 没有检测到图片`); |
|
|
//console.log(`[${timestamp}] 没有检测到图片`); |
|
|
this.isPasting = false; |
|
|
this.isPasting = false; |
|
|
} |
|
|
} |
|
|
// #endif |
|
|
// #endif |
|
|
@ -1188,15 +1188,15 @@ export default { |
|
|
|
|
|
|
|
|
async fileToBase64(file) { |
|
|
async fileToBase64(file) { |
|
|
const timestamp = new Date().toISOString(); |
|
|
const timestamp = new Date().toISOString(); |
|
|
console.log(`[${timestamp}] fileToBase64被调用,文件大小:`, file.size); |
|
|
//console.log(`[${timestamp}] fileToBase64被调用,文件大小:`, file.size); |
|
|
return new Promise((resolve, reject) => { |
|
|
return new Promise((resolve, reject) => { |
|
|
const reader = new FileReader(); |
|
|
const reader = new FileReader(); |
|
|
reader.onload = (event) => { |
|
|
reader.onload = (event) => { |
|
|
console.log(`[${timestamp}] fileToBase64 onload,结果长度:`, event.target.result.length); |
|
|
//console.log(`[${timestamp}] fileToBase64 onload,结果长度:`, event.target.result.length); |
|
|
resolve(event.target.result); |
|
|
resolve(event.target.result); |
|
|
}; |
|
|
}; |
|
|
reader.onerror = (error) => { |
|
|
reader.onerror = (error) => { |
|
|
console.log(`[${timestamp}] fileToBase64 onerror:`, error); |
|
|
//console.log(`[${timestamp}] fileToBase64 onerror:`, error); |
|
|
reject(error); |
|
|
reject(error); |
|
|
}; |
|
|
}; |
|
|
reader.readAsDataURL(file); |
|
|
reader.readAsDataURL(file); |
|
|
@ -1205,11 +1205,11 @@ export default { |
|
|
|
|
|
|
|
|
async handlePasteImage(file) { |
|
|
async handlePasteImage(file) { |
|
|
const timestamp = new Date().toISOString(); |
|
|
const timestamp = new Date().toISOString(); |
|
|
console.log(`[${timestamp}] handlePasteImage被调用, isPasting: ${window.__isPasting__}, chat:`, this.chat); |
|
|
//console.log(`[${timestamp}] handlePasteImage被调用, isPasting: ${window.__isPasting__}, chat:`, this.chat); |
|
|
|
|
|
|
|
|
// 检查chat是否存在 |
|
|
// 检查chat是否存在 |
|
|
if (!this.chat) { |
|
|
if (!this.chat) { |
|
|
console.log(`[${timestamp}] handlePasteImage: chat为空,忽略`); |
|
|
//console.log(`[${timestamp}] handlePasteImage: chat为空,忽略`); |
|
|
return; |
|
|
return; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@ -1263,14 +1263,14 @@ export default { |
|
|
await this.uploadPastedImage(file); |
|
|
await this.uploadPastedImage(file); |
|
|
|
|
|
|
|
|
} catch (error) { |
|
|
} catch (error) { |
|
|
console.log(`[${timestamp}] 处理粘贴图片失败:`, error); |
|
|
//console.log(`[${timestamp}] 处理粘贴图片失败:`, error); |
|
|
this.isPasting = false; |
|
|
this.isPasting = false; |
|
|
} |
|
|
} |
|
|
}, |
|
|
}, |
|
|
|
|
|
|
|
|
async uploadPastedImage(file) { |
|
|
async uploadPastedImage(file) { |
|
|
const timestamp = new Date().toISOString(); |
|
|
const timestamp = new Date().toISOString(); |
|
|
console.log(`[${timestamp}] uploadPastedImage被调用`); |
|
|
//console.log(`[${timestamp}] uploadPastedImage被调用`); |
|
|
|
|
|
|
|
|
// #ifdef H5 |
|
|
// #ifdef H5 |
|
|
try { |
|
|
try { |
|
|
@ -1293,7 +1293,7 @@ export default { |
|
|
const formData = new FormData(); |
|
|
const formData = new FormData(); |
|
|
formData.append('file', blob, file.name); |
|
|
formData.append('file', blob, file.name); |
|
|
|
|
|
|
|
|
console.log(`[${timestamp}] 开始上传图片`); |
|
|
//console.log(`[${timestamp}] 开始上传图片`); |
|
|
|
|
|
|
|
|
// 使用fetch上传 |
|
|
// 使用fetch上传 |
|
|
const response = await fetch(UNI_APP.BASE_URL + `/image/upload?isPermanent=false&thumbSize=50`, { |
|
|
const response = await fetch(UNI_APP.BASE_URL + `/image/upload?isPermanent=false&thumbSize=50`, { |
|
|
@ -1302,10 +1302,10 @@ export default { |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
const data = await response.json(); |
|
|
const data = await response.json(); |
|
|
console.log(`[${timestamp}] 上传响应:`, data); |
|
|
//console.log(`[${timestamp}] 上传响应:`, data); |
|
|
|
|
|
|
|
|
if (data.code === 200) { |
|
|
if (data.code === 200) { |
|
|
console.log(`[${timestamp}] 上传成功,准备发送消息`); |
|
|
//console.log(`[${timestamp}] 上传成功,准备发送消息`); |
|
|
// 上传成功,更新消息内容 |
|
|
// 上传成功,更新消息内容 |
|
|
let msgInfo = JSON.parse(JSON.stringify(file.msgInfo)); |
|
|
let msgInfo = JSON.parse(JSON.stringify(file.msgInfo)); |
|
|
msgInfo.content = JSON.stringify(data.data); |
|
|
msgInfo.content = JSON.stringify(data.data); |
|
|
@ -1314,13 +1314,13 @@ export default { |
|
|
|
|
|
|
|
|
// 发送消息 |
|
|
// 发送消息 |
|
|
const m = await this.sendMessageRequest(msgInfo); |
|
|
const m = await this.sendMessageRequest(msgInfo); |
|
|
console.log(`[${timestamp}] 消息发送成功`); |
|
|
//console.log(`[${timestamp}] 消息发送成功`); |
|
|
msgInfo.id = m.id; |
|
|
msgInfo.id = m.id; |
|
|
msgInfo.status = m.status; |
|
|
msgInfo.status = m.status; |
|
|
this.isReceipt = false; |
|
|
this.isReceipt = false; |
|
|
this.chatStore.updateMessage(msgInfo, file.chat); |
|
|
this.chatStore.updateMessage(msgInfo, file.chat); |
|
|
} else { |
|
|
} else { |
|
|
console.log(`[${timestamp}] 上传失败:`, data); |
|
|
//console.log(`[${timestamp}] 上传失败:`, data); |
|
|
uni.showToast({ |
|
|
uni.showToast({ |
|
|
icon: "none", |
|
|
icon: "none", |
|
|
title: data.message || "上传失败", |
|
|
title: data.message || "上传失败", |
|
|
@ -1330,7 +1330,7 @@ export default { |
|
|
this.chatStore.updateMessage(msgInfo, file.chat); |
|
|
this.chatStore.updateMessage(msgInfo, file.chat); |
|
|
} |
|
|
} |
|
|
} catch (error) { |
|
|
} catch (error) { |
|
|
console.log(`[${timestamp}] 上传异常:`, error); |
|
|
//console.log(`[${timestamp}] 上传异常:`, error); |
|
|
uni.showToast({ |
|
|
uni.showToast({ |
|
|
icon: "none", |
|
|
icon: "none", |
|
|
title: "上传失败", |
|
|
title: "上传失败", |
|
|
@ -1438,7 +1438,7 @@ export default { |
|
|
if (this.reqQueue.length && !this.isSending) { |
|
|
if (this.reqQueue.length && !this.isSending) { |
|
|
this.isSending = true; |
|
|
this.isSending = true; |
|
|
const reqData = this.reqQueue.shift(); |
|
|
const reqData = this.reqQueue.shift(); |
|
|
console.log(reqData.msgInfo); |
|
|
//console.log(reqData.msgInfo); |
|
|
this.$http({ |
|
|
this.$http({ |
|
|
url: this.messageAction, |
|
|
url: this.messageAction, |
|
|
method: "post", |
|
|
method: "post", |
|
|
@ -1493,7 +1493,7 @@ export default { |
|
|
// #ifdef H5 |
|
|
// #ifdef H5 |
|
|
if (navigator.platform == "Win32") { |
|
|
if (navigator.platform == "Win32") { |
|
|
// 电脑端不需要弹出键盘 |
|
|
// 电脑端不需要弹出键盘 |
|
|
console.log("navigator.platform:", navigator.platform); |
|
|
//console.log("navigator.platform:", navigator.platform); |
|
|
return; |
|
|
return; |
|
|
} |
|
|
} |
|
|
if (uni.getSystemInfoSync().platform == "ios") { |
|
|
if (uni.getSystemInfoSync().platform == "ios") { |
|
|
|