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