Răsfoiți Sursa

搜索优化

shish 5 luni în urmă
părinte
comite
0bafa8ee23

+ 11 - 4
ghsPad/src/pages/home/components/rightItem.vue

@@ -7,7 +7,7 @@
                 <input 
                 <input 
                     v-model="searchKeyword" 
                     v-model="searchKeyword" 
                     class="search-input" 
                     class="search-input" 
-                    placeholder="输入中文搜索"
+                    placeholder="输入中文或拼音首字母搜索"
                     @input="handleSearch"
                     @input="handleSearch"
                     @confirm="handleSearch"
                     @confirm="handleSearch"
                     @focus="clearSearch"
                     @focus="clearSearch"
@@ -106,7 +106,7 @@ export default {
             if(!this.searchKeyword.trim()){
             if(!this.searchKeyword.trim()){
                 return this.globalRightItemInfloList || []
                 return this.globalRightItemInfloList || []
             }
             }
-            // 按花材名称搜索,不区分大小写,搜索所有分类
+            // 按花材名称和拼音搜索,不区分大小写
             const keyword = this.searchKeyword.toLowerCase().trim()
             const keyword = this.searchKeyword.toLowerCase().trim()
             let allItems = []
             let allItems = []
             
             
@@ -119,9 +119,16 @@ export default {
                     }
                     }
                 }
                 }
             }
             }
-            
             return allItems.filter(item => {
             return allItems.filter(item => {
-                return item.name && item.name.toLowerCase().includes(keyword)
+                // 支持名称搜索
+                if(item.name && item.name.toLowerCase().includes(keyword)){
+                    return true
+                }
+                // 支持拼音搜索
+                if(item.py && item.py.toLowerCase().includes(keyword)){
+                    return true
+                }
+                return false
             })
             })
         }
         }
     },
     },

+ 11 - 3
hdPad/src/pages/home/components/rightItem.vue

@@ -7,7 +7,7 @@
                 <input 
                 <input 
                     v-model="searchKeyword" 
                     v-model="searchKeyword" 
                     class="search-input" 
                     class="search-input" 
-                    placeholder="输入中文搜索"
+                    placeholder="输入中文或拼音首字母搜索"
                     @input="handleSearch"
                     @input="handleSearch"
                     @confirm="handleSearch"
                     @confirm="handleSearch"
                     @focus="clearSearch"
                     @focus="clearSearch"
@@ -98,7 +98,7 @@ export default {
             if(!this.searchKeyword.trim()){
             if(!this.searchKeyword.trim()){
                 return this.globalItemInfoList || []
                 return this.globalItemInfoList || []
             }
             }
-            // 按花材名称搜索,不区分大小写,搜索所有分类
+            // 按花材名称和拼音搜索,不区分大小写
             const keyword = this.searchKeyword.toLowerCase().trim()
             const keyword = this.searchKeyword.toLowerCase().trim()
             let allItems = []
             let allItems = []
             
             
@@ -116,7 +116,15 @@ export default {
             }
             }
             
             
             return allItems.filter(item => {
             return allItems.filter(item => {
-                return item.name && item.name.toLowerCase().includes(keyword)
+                // 支持名称搜索
+                if(item.name && item.name.toLowerCase().includes(keyword)){
+                    return true
+                }
+                // 支持拼音搜索
+                if(item.py && item.py.toLowerCase().includes(keyword)){
+                    return true
+                }
+                return false
             })
             })
         }
         }
     },
     },