Kaynağa Gözat

update packages/components/index.vue.
将当前联系人根据菜单拆分,在消息页面和联系人页面,分别有属于当前页面的当前联系人。IMUI.getCurrentContact()为当前聊天窗口联系人信息,再联系人菜单进行联系人点击不会影响该值。解决了如下BUG【在demo(http://june000.gitee.io/lemon-im/)中,页面加载完成后,切换到联系人页面,点击铁牛(不点击发消息),后切换到消息菜单页,此时在消息菜单页,默认打开与铁牛的会话窗口,但是会话内容是默认联系人(工作协作群)的内容】

Signed-off-by: 张华宇 <7506206+zhang_huayu@user.noreply.gitee.com>

张华宇 2 yıl önce
ebeveyn
işleme
9593900f36
1 değiştirilmiş dosya ile 17 ekleme ve 5 silme
  1. 17 5
      packages/components/index.vue

+ 17 - 5
packages/components/index.vue

@@ -101,7 +101,8 @@ export default {
     this.CacheDraft = new MemoryCache();
     return {
       drawerVisible: !this.hideDrawer,
-      currentContactId: null,
+      currentContactId: null, // 消息菜单下当前联系人
+      currentContactIdSidebarContact: null, // 联系人菜单下当前联系人
       currentMessages: [],
       activeSidebar: DEFAULT_MENU_LASTMESSAGES,
       contacts: [],
@@ -133,6 +134,9 @@ export default {
     currentContact() {
       return this.contacts.find(item => item.id == this.currentContactId) || {};
     },
+    currentContactSidebarContact() {
+      return this.contacts.find(item => item.id == this.currentContactIdSidebarContact) || {};
+    },
     currentMenu() {
       return this.menus.find(item => item.name == this.activeSidebar) || {};
     },
@@ -397,7 +401,7 @@ export default {
       return (
         <lemon-contact
           class={{
-            "lemon-contact--active": this.currentContactId == props.contact.id,
+            "lemon-contact--active": this.activeSidebar == DEFAULT_MENU_CONTACTS ? this.currentContactIdSidebarContact == props.contact.id : this.currentContactId == props.contact.id
           }}
           v-lemon-contextmenu_contact={this.contactContextmenu}
           props={props}
@@ -469,7 +473,7 @@ export default {
     _renderContainer() {
       const nodes = [];
       const cls = "lemon-container";
-      const curact = this.currentContact;
+      const curact = this.activeSidebar == DEFAULT_MENU_CONTACTS ? this.currentContactSidebarContact : this.currentContact;
       let defIsShow = true;
       for (const name in this.CacheContactContainer.get()) {
         const show = curact.id == name && this.currentIsDefSidebar;
@@ -682,7 +686,10 @@ export default {
       if (menuName) {
         this.changeMenu(menuName);
       } else {
-        if (this._changeContactLock || this.currentContactId == contactId)
+        if (this._changeContactLock ||
+            (this.activeSidebar == DEFAULT_MENU_LASTMESSAGES && this.currentContactId == contactId) ||
+            (this.activeSidebar == DEFAULT_MENU_CONTACTS && this.currentContactIdSidebarContact == contactId)
+        )
           return false;
       }
 
@@ -697,7 +704,12 @@ export default {
         }
       }
 
-      this.currentContactId = contactId;
+
+      if (this.activeSidebar == DEFAULT_MENU_CONTACTS) {
+        this.currentContactIdSidebarContact = contactId
+      } else {
+        this.currentContactId = contactId;
+      }
       if (!this.currentContactId) return false;
 
       this.$emit("change-contact", this.currentContact, this);