From 5b2d96cf0a1d554a91aac677051a10a2e8b55f8d Mon Sep 17 00:00:00 2001 From: shenmo Date: Sun, 29 Mar 2026 14:21:48 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=AE=9E=E7=8E=B0=E6=90=9C=E7=B4=A2?= =?UTF-8?q?=E7=BB=93=E6=9E=9C=E7=9A=84=E5=88=86=E7=B1=BB=E8=AE=A1=E6=95=B0?= =?UTF-8?q?=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 添加搜索关键词时显示匹配结果数量的功能,同时优化了应用卡片和网格的UI样式 --- src/App.vue | 24 ++++++++++++++++++++++++ src/components/AppCard.vue | 18 ++++++++---------- src/components/AppGrid.vue | 13 ++++++++----- 3 files changed, 40 insertions(+), 15 deletions(-) diff --git a/src/App.vue b/src/App.vue index dc94086e..0c4acf1c 100644 --- a/src/App.vue +++ b/src/App.vue @@ -303,6 +303,30 @@ const filteredApps = computed(() => { }); const categoryCounts = computed(() => { + // 如果有搜索关键词,显示搜索结果数量 + if (searchQuery.value.trim()) { + const q = searchQuery.value.toLowerCase().trim(); + const counts: Record = { all: 0 }; + + apps.value.forEach((app) => { + // 检查应用是否匹配搜索条件 + const matches = + (app.name || "").toLowerCase().includes(q) || + (app.pkgname || "").toLowerCase().includes(q) || + (app.tags || "").toLowerCase().includes(q) || + (app.more || "").toLowerCase().includes(q); + + if (matches) { + counts.all++; + if (!counts[app.category]) counts[app.category] = 0; + counts[app.category]++; + } + }); + + return counts; + } + + // 无搜索时显示总数量 const counts: Record = { all: apps.value.length }; apps.value.forEach((app) => { if (!counts[app.category]) counts[app.category] = 0; diff --git a/src/components/AppCard.vue b/src/components/AppCard.vue index 9dac369f..b76297be 100644 --- a/src/components/AppCard.vue +++ b/src/components/AppCard.vue @@ -1,19 +1,17 @@