mirror of
https://gitee.com/spark-store-project/spark-store
synced 2026-06-22 06:03:49 +08:00
feat: 实现搜索结果的分类计数功能
添加搜索关键词时显示匹配结果数量的功能,同时优化了应用卡片和网格的UI样式
This commit is contained in:
+24
@@ -303,6 +303,30 @@ const filteredApps = computed(() => {
|
||||
});
|
||||
|
||||
const categoryCounts = computed(() => {
|
||||
// 如果有搜索关键词,显示搜索结果数量
|
||||
if (searchQuery.value.trim()) {
|
||||
const q = searchQuery.value.toLowerCase().trim();
|
||||
const counts: Record<string, number> = { 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<string, number> = { all: apps.value.length };
|
||||
apps.value.forEach((app) => {
|
||||
if (!counts[app.category]) counts[app.category] = 0;
|
||||
|
||||
Reference in New Issue
Block a user