From 08881d6b6412822d5035f63a0775ca1f213c8668 Mon Sep 17 00:00:00 2001
From: WXL (wul) <wl_5969728@163.com>
Date: 星期一, 20 十月 2025 10:17:22 +0800
Subject: [PATCH] 测试完成
---
src/views/shortmessage/communication/index.vue | 116 ++++++++++++++++++++++++++++++++-------------------------
1 files changed, 65 insertions(+), 51 deletions(-)
diff --git a/src/views/shortmessage/communication/index.vue b/src/views/shortmessage/communication/index.vue
index 4bb666e..14407b5 100644
--- a/src/views/shortmessage/communication/index.vue
+++ b/src/views/shortmessage/communication/index.vue
@@ -63,8 +63,8 @@
</template>
<script>
-import LemonMessageVoice from "./lemon-message-voice";
import EmojiData from "./database/emoji";
+import { chitchatapi } from "@/api/noteapi/chitchat";
import {
sendWebsocket,
websocketSend,
@@ -106,6 +106,9 @@
};
export default {
name: "communication",
+ provide: {
+ IMUI: "IMUI value",
+ },
data() {
return {
theme: "blue",
@@ -296,19 +299,19 @@
setTimeout(() => {
IMUI.changeContact("contact-1");
}, 500);
-
+ // 宸︿晶鑱旂郴浜烘渶鏂版秷鎭�
IMUI.setLastContentRender("event", (message) => {
return `[鑷畾涔夐�氱煡鍐呭]`;
});
-
let contactList = [
{ ...contactData1 },
{ ...contactData2 },
{ ...contactData3 },
//...Array(100).fill(contactData1)
];
-
+ // 鍒濆鑱旂郴浜�
IMUI.initContacts(contactList);
+ // 鍒濆鍖栧乏渚у鑸�
IMUI.initMenus([
{
name: "messages",
@@ -369,7 +372,7 @@
isBottom: true,
},
]);
-
+ // 宸ュ叿鏍�
IMUI.initEditorTools([
{
name: "emoji",
@@ -436,7 +439,7 @@
// 鐐瑰嚮娑堟伅瑙﹀彂
handleMessageClick(e, key, message, instance) {
console.log("鐐瑰嚮浜嗘秷鎭�", e, key, message);
-
+ console.log(key);
if (key == "status") {
instance.updateMessage({
id: message.id,
@@ -495,6 +498,7 @@
IMUI.messageViewToBottom();
}
},
+ // 瀹氫箟鏂版秷鎭�
appendCustomMessage() {
const { IMUI } = this.$refs;
const message = {
@@ -588,54 +592,66 @@
requstWs(message, next, file) {
console.log("杩炴帴");
// 闃叉鐢ㄦ埛澶氭杩炵画鐐瑰嚮鍙戣捣璇锋眰锛屾墍浠ヨ鍏堝叧闂笂娆$殑ws璇锋眰銆�
- // closeWebsocket();
+ closeWebsocket();
+ let formData = new FormData();
- if (file) {
- const reader = new FileReader();
- console.log(reader);
- console.log(file);
- reader.onload = (file) => {
- console.log(file);
- console.log(reader);
- const imageData = reader.result;
- //鏂囦欢瀛楄妭澶у皬
- // const fileSize = file.loaded;
- const fileSize = imageData.length;
- console.log("byteLength 锛� ", fileSize);
- const chunkSize = 4096; // 璁剧疆姣忎釜鏁版嵁鍧楃殑澶у皬
- let offset = 0;
+ // if (file) {
+ // const reader = new FileReader();
+ // console.log(reader);
+ // console.log(file);
+ // reader.onload = (file) => {
+ // console.log(file);
+ // console.log(reader);
+ // const imageData = reader.result;
+ // //鏂囦欢瀛楄妭澶у皬
+ // // const fileSize = file.loaded;
+ // const fileSize = imageData.length;
+ // console.log("byteLength 锛� ", fileSize);
+ // const chunkSize = 4096; // 璁剧疆姣忎釜鏁版嵁鍧楃殑澶у皬
+ // let offset = 0;
- // 鍒嗗潡浼犺緭鍥剧墖鏁版嵁
- while (offset < imageData.length) {
- const chunk = imageData.slice(offset, offset + chunkSize);
- const obj = {
- type: file.type,
- userId: "1", //鎺ユ敹鏁版嵁鏂�
- fileSize: fileSize,
- image: chunk,
- };
- console.log(JSON.stringify(obj));
- // 鍙戣捣ws璇锋眰
- // sendWebsocket(
- // "ws://192.168.31.121:8080/chat?userId=2",
- // JSON.stringify(obj),
- // this.wsMessage,
- // this.wsError
- // );
- websocketSend(JSON.stringify(obj));
- offset += chunkSize;
+ // // 鍒嗗潡浼犺緭鍥剧墖鏁版嵁
+ // while (offset < imageData.length) {
+ // const chunk = imageData.slice(offset, offset + chunkSize);
+ // const obj = {
+ // type: file.type,
+ // userId: "1", //鎺ユ敹鏁版嵁鏂�
+ // fileSize: fileSize,
+ // image: chunk,
+ // };
+ // console.log(JSON.stringify(obj));
+ // // 鍙戣捣ws璇锋眰
+ // // sendWebsocket(
+ // // "ws://192.168.31.121:8080/chat?userId=2",
+ // // JSON.stringify(obj),
+ // // this.wsMessage,
+ // // this.wsError
+ // // );
+ // websocketSend(JSON.stringify(obj));
+ // offset += chunkSize;
- console.log("offset 锛� ", offset);
- }
+ // console.log("offset 锛� ", offset);
+ // }
- // 鍙戦�佸畬鎴愭爣璁�
- console.log("message ");
- };
+ // // 鍙戦�佸畬鎴愭爣璁�
+ // console.log("message ");
+ // };
- return reader.readAsDataURL(file);
- }
+ // return reader.readAsDataURL(file);
+ // }
// 璺熷悗绔崗鍟嗭紝闇�瑕佷粈涔堝弬鏁版暟鎹粰鍚庡彴
+ if (file) {
+ formData.append("files", file);
+ console.log(formData.get("files"));
+ // img.src = window.URL.createObjectURL(temp);
+ chitchatapi(formData).then((response) => {
+ console.log(response);
+ });
+
+ return console.log(formData);
+ }
+
const obj = {
type: "object",
userId: "1", //鎺ユ敹鏁版嵁鏂�
@@ -644,7 +660,7 @@
};
// 鍙戣捣ws璇锋眰
sendWebsocket(
- "ws://192.168.31.121:8080/chat?userId=2",
+ "ws://localhost:8089/chat?userId=1",
obj,
this.wsMessage,
this.wsError
@@ -686,9 +702,7 @@
},
// 鑾峰彇鑱旂郴浜轰俊鎭垨婊氬姩鍒伴《閮ㄨЕ鍙�
handlePullMessages(contact, next, instance) {
- console.log(contact, "鑾峰彇鑱旂郴浜轰俊鎭疉");
- console.log(instance, "鑾峰彇鑱旂郴浜轰俊鎭疊");
- console.log(next, "鑾峰彇鑱旂郴浜轰俊鎭疌");
+
const otheruser = {
id: contact.id,
displayName: contact.displayName,
--
Gitblit v1.9.3