diff --git a/src/App.vue b/src/App.vue index d97df0c..8793c5c 100644 --- a/src/App.vue +++ b/src/App.vue @@ -40,6 +40,7 @@ @@ -90,6 +92,7 @@ @@ -210,6 +213,35 @@ export default { console.warning("fail to open service"); } }, + filterTag: function (filter) { + this.showMenu = true; + this.$nextTick(() => { + document.getElementById("searchBox").focus(); + }); + this.filter = filter; + + if (!filter) { + this.services = this.config.services; + return; + } + + const searchResultItems = []; + for (const group of this.config.services) { + for (const item of group.items) { + if (this.matchesFilter(item)) { + searchResultItems.push(item); + } + } + } + + this.services = [ + { + name: filter, + icon: "fas fa-search", + items: searchResultItems, + }, + ]; + }, filterServices: function (filter) { this.filter = filter; diff --git a/src/components/SearchInput.vue b/src/components/SearchInput.vue index 9419db3..c4bef47 100644 --- a/src/components/SearchInput.vue +++ b/src/components/SearchInput.vue @@ -2,6 +2,7 @@ -
+
#{{ item.tag }}
@@ -51,6 +56,9 @@ export default { response.json() ); }, + filterTag: function () { + this.$emit("filter", this.item.tag.toLowerCase()); + }, }, };