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 | 95 ++++++++++++++++++++++++++++++++++++++++-------
1 files changed, 80 insertions(+), 15 deletions(-)
diff --git a/src/views/shortmessage/communication/index.vue b/src/views/shortmessage/communication/index.vue
index 18df674..14407b5 100644
--- a/src/views/shortmessage/communication/index.vue
+++ b/src/views/shortmessage/communication/index.vue
@@ -63,9 +63,13 @@
</template>
<script>
-import LemonMessageVoice from "./lemon-message-voice";
import EmojiData from "./database/emoji";
-import { sendWebsocket, closeWebsocket } from "@/websocket/websocket.js";
+import { chitchatapi } from "@/api/noteapi/chitchat";
+import {
+ sendWebsocket,
+ websocketSend,
+ closeWebsocket,
+} from "@/websocket/websocket.js";
// Vue.component(LemonMessageVoice.name, LemonMessageVoice);
// 鑾峰彇鏃堕棿
const getTime = () => {
@@ -102,6 +106,9 @@
};
export default {
name: "communication",
+ provide: {
+ IMUI: "IMUI value",
+ },
data() {
return {
theme: "blue",
@@ -292,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",
@@ -365,7 +372,7 @@
isBottom: true,
},
]);
-
+ // 宸ュ叿鏍�
IMUI.initEditorTools([
{
name: "emoji",
@@ -432,7 +439,7 @@
// 鐐瑰嚮娑堟伅瑙﹀彂
handleMessageClick(e, key, message, instance) {
console.log("鐐瑰嚮浜嗘秷鎭�", e, key, message);
-
+ console.log(key);
if (key == "status") {
instance.updateMessage({
id: message.id,
@@ -491,6 +498,7 @@
IMUI.messageViewToBottom();
}
},
+ // 瀹氫箟鏂版秷鎭�
appendCustomMessage() {
const { IMUI } = this.$refs;
const message = {
@@ -581,19 +589,78 @@
instance.closeDrawer();
},
// 寤虹珛杩炴帴
- requstWs() {
+ requstWs(message, next, file) {
console.log("杩炴帴");
// 闃叉鐢ㄦ埛澶氭杩炵画鐐瑰嚮鍙戣捣璇锋眰锛屾墍浠ヨ鍏堝叧闂笂娆$殑ws璇锋眰銆�
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;
+
+ // // 鍒嗗潡浼犺緭鍥剧墖鏁版嵁
+ // 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("message ");
+ // };
+
+ // 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: "text",
- content: "甯濆緱鍦g浉鐩告洶搴�",
+ type: "object",
userId: "1", //鎺ユ敹鏁版嵁鏂�
+ fileSize: "1212",
+ image: "12",
};
// 鍙戣捣ws璇锋眰
sendWebsocket(
- "ws://192.168.1.4:8080/chat?userId=2",
+ "ws://localhost:8089/chat?userId=1",
obj,
this.wsMessage,
this.wsError
@@ -628,16 +695,14 @@
console.log(message);
console.log(file);
console.log(next);
- this.requstWs();
+ this.requstWs(message, next, file);
setTimeout(() => {
next();
}, 1000);
},
// 鑾峰彇鑱旂郴浜轰俊鎭垨婊氬姩鍒伴《閮ㄨЕ鍙�
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