lex 2 years ago
parent
commit
4453676f4c

+ 6 - 7
src/layout/components/components/conversation-list.vue

@@ -133,7 +133,7 @@ export default {
           contextMenuClickId: 0,
           txt: "会话置顶"
         },
-        { contextMenuClickId: 1, txt: "消息免打扰" },
+        // { contextMenuClickId: 1, txt: "消息免打扰" },
         {
           contextMenuClickId: 2,
           txt: "删除会话"
@@ -164,7 +164,6 @@ export default {
       this.getConversationList(true).then(() => {
         setTimeout(() => {
           this.loading = false;
-
           const length = this.list.length;
           // 处理如果不能 % 不为0则加载完成,如果上一次加载数据和当前加载数据相等,则表示加载完成
           if (20 % length || length === beforeLength) {
@@ -269,11 +268,11 @@ export default {
     },
     onContextmenu(item, e) {
       // contextMenuClickId
-      if (item.conversation.notificationLevel === -1) {
-        this.dropdownList[1].txt = "取消免打扰";
-      } else {
-        this.dropdownList[1].txt = "消息免打扰";
-      }
+      // if (item.conversation.notificationLevel === -1) {
+      //   this.dropdownList[1].txt = "取消免打扰";
+      // } else {
+      //   this.dropdownList[1].txt = "消息免打扰";
+      // }
       if (item.conversation.isTop) {
         this.dropdownList[0].txt = "取消置顶";
       } else {

+ 4 - 0
src/layout/components/components/message-editor.vue

@@ -33,6 +33,7 @@
         class="message-input-text"
         v-model="content"
         rows="3"
+        maxlength="200"
         @keyup.alt.enter="handlePostMessage"
       ></textarea>
       <!-- <div
@@ -42,6 +43,9 @@
         @keyup.alt.enter="handlePostMessage"
       ></div> -->
       <div class="message-input-btn">
+        <div style="font-size: 12px;color: #999;margin-right: 12px;">
+          ↵ 换行 / alt + ↵ 发送
+        </div>
         <el-button type="primary" @click="handlePostMessage">发送</el-button>
       </div>
     </div>

+ 40 - 2
src/layout/components/components/message-item.vue

@@ -28,6 +28,7 @@
               <el-image
                 class="m-image"
                 :src="addBase64head(message.content.content)"
+                :preview-src-list="[addBase64head(message.content.content)]"
                 @error="onError"
               />
             </div>
@@ -56,8 +57,18 @@
               </video>
             </div>
             <!-- 文件 -->
-            <!-- <div v-else-if="MessageType.FILE === message.messageType">
-            </div> -->
+            <div v-else-if="MessageType.FILE === message.messageType">
+              <div class="file-message">
+                <img src="../imkit/images/message-icon-unknown.svg" />
+                <span>{{ message.content.name }}</span>
+
+                <i
+                  class="el-icon-download"
+                  title="下载"
+                  @click="onFileDownload(message.content)"
+                ></i>
+              </div>
+            </div>
             <div v-else>
               {{ locale.message.nonsupport }}
             </div>
@@ -324,6 +335,10 @@ export default {
       if (this.groupMembers && this.groupMembers.length) {
         return this.groupMembers.find(one => one.id == id);
       }
+    },
+    onFileDownload(content) {
+      // window.location.href = content.fileUrl;
+      window.open(content.fileUrl);
     }
   }
 };
@@ -413,4 +428,27 @@ export default {
   font-size: 14px;
   margin: 0 auto;
 }
+.file-message {
+  display: flex;
+  align-items: center;
+  color: #999;
+  img {
+    width: 18px;
+    height: 18px;
+    margin-right: 8px;
+  }
+  span {
+    max-width: 120px;
+    white-space: nowrap;
+    overflow: hidden;
+    text-overflow: ellipsis;
+  }
+
+  .el-icon-download {
+    color: #00a79d;
+    padding-left: 5px;
+    font-size: 16px;
+    cursor: pointer;
+  }
+}
 </style>

+ 2 - 2
src/layout/components/components/message-list.vue

@@ -289,8 +289,8 @@ export default {
         return;
       }
       let lastestTime = Date.now();
-      if (objs.length) {
-        lastestTime = objs[0].sentTime;
+      if (this.messages && this.messages.length) {
+        lastestTime = this.messages[0].sentTime;
       }
       // 先显示正在加载,然后开始请求数据,保证显示效果
 

+ 10 - 4
src/layout/components/modal/chat-model.vue

@@ -165,7 +165,13 @@ export default {
     },
     switchConversation(conversation) {
       console.log(conversation, "switchConversation chat-model");
-      this.currentConversation = conversation;
+      this.currentConversation = conversation
+        ? conversation
+        : {
+            channelId: "",
+            conversationType: 0,
+            targetId: ""
+          };
     }
   },
   destoryed() {
@@ -215,7 +221,7 @@ export default {
       background-size: contain;
 
       &:hover,
-      &:active {
+      &.active {
         background: url("../images/icon_chat.svg") no-repeat;
         background-size: contain;
       }
@@ -225,7 +231,7 @@ export default {
       background: url("../images/icon_message_default.svg") no-repeat;
       background-size: contain;
       &:hover,
-      &:active {
+      &.active {
         background: url("../images/icon_message.svg") no-repeat;
         background-size: contain;
       }
@@ -235,7 +241,7 @@ export default {
       background: url("../images/icon_class_default.svg") no-repeat;
       background-size: contain;
       &:hover,
-      &:active {
+      &.active {
         background: url("../images/icon_class.svg") no-repeat;
         background-size: contain;
       }

+ 4 - 3
src/layout/components/modal/chat.js

@@ -29,7 +29,7 @@ const getInitData = async list => {
         tempItem.memberCount = 0; // memberCount 为群成员数量
       }
       // console.log(findItem, "findItem items");
-      if (findItem.id) {
+      if (findItem && findItem.id) {
         tempItem.name = findItem.name;
         tempItem.portraitUri =
           findItem.avatar ||
@@ -43,8 +43,9 @@ const getInitData = async list => {
       temp.push({ ...item, ...tempItem });
     });
     return temp;
-  } catch {
+  } catch (e) {
     //
+    console.log(e, "e");
     return [];
   }
 };
@@ -78,7 +79,7 @@ export const custom_service = {
     const promises = [];
 
     const tempConversations = await getInitData(conversations);
-    console.log(conversations, tempConversations, "tempConversations");
+    // console.log(conversations, tempConversations, "tempConversations");
 
     // conversations.forEach(conversation => {
     //   const converationInfo = {