huangbin 4 lat temu
rodzic
commit
37adb5885a
2 zmienionych plików z 14 dodań i 14 usunięć
  1. 1 1
      public/config/app.config.json
  2. 13 13
      src/views/setting/friends/index.vue

+ 1 - 1
public/config/app.config.json

@@ -1,3 +1,3 @@
 {
-    "apiUrl": "http://192.168.31.139:8080/cfg?key=test_139"
+    "apiUrl": "http://192.168.31.204:8080/cfg?key=test_204"
 }

+ 13 - 13
src/views/setting/friends/index.vue

@@ -10,7 +10,7 @@
           <SearchOutlined />
         </template>
       </a-input-search>
-      <div class="mt10">
+      <div class="mt10 friend-content">
         <div class="item"
              v-for="(item, index) in searchFriend"
              :key="index + '11'">
@@ -99,18 +99,11 @@ export default defineComponent({
             loading.value = true;
             queryQueryWrFriend(value)
                 .then((res) => {
-                    if (value) {
-                        const set = new Set<number>([]);
-                        searchFriend.value.forEach((el) => set.add(el.frienduserid));
-                        res.forEach((el) => {
-                            // 防止重复搜索
-                            if (!set.has(el.frienduserid)) {
-                                searchFriend.value.push(el);
-                            }
-                        });
-                    } else {
+                    if (!value) {
                         myFriends.value = res; // 我的朋友
-                        searchFriend.value = res;
+                    } else {
+                        const findResult = myFriends.value.filter((e) => String(e.frienduserid).includes(value));
+                        searchFriend.value = [...findResult, ...res];
                     }
                 })
                 .catch((err: string) => message.error(err))
@@ -121,12 +114,15 @@ export default defineComponent({
 
         function handleSearch(value: string) {
             if (value) {
+                // 模糊 搜索自己的好友
+                // 精准添加 好友
                 const findResult = myFriends.value.filter((e) => String(e.frienduserid).includes(value));
                 if (findResult.length) {
-                    searchFriend.value = findResult;
                     // fix:#1191 搜索好友时,输入的数字包含在已有好友中时,会无法精确匹配到未添加的用户
                     if (!findResult.find((e) => e.frienduserid.toString() === value)) {
                         queryMyFriend(value);
+                    } else {
+                        searchFriend.value = findResult;
                     }
                 } else {
                     queryMyFriend(value);
@@ -212,6 +208,10 @@ export default defineComponent({
             box-shadow: none !important;
         }
     }
+    .friend-content {
+        height: 290px;
+        overflow-y: scroll;
+    }
 }
 </style
 >;