"use client"; import { useMemo, useState } from "react"; import Link from "next/link"; import { CategoryTabs } from "@/components/sections"; import { AppResource } from "@/lib/types"; export function AppsExplorer({ apps }: { apps: AppResource[] }) { const [query, setQuery] = useState(""); const [category, setCategory] = useState("all"); const [sort, setSort] = useState("latest"); const [count, setCount] = useState(6); const filtered = useMemo(() => { let list = [...apps].filter((a) => [a.name, a.subtitle, ...a.tags].join(" ").toLowerCase().includes(query.toLowerCase()) ); if (category !== "all") list = list.filter((a) => a.category === category); list.sort((a, b) => { if (sort === "hot") return b.downloads - a.downloads; if (sort === "update") return b.updatedAt.localeCompare(a.updatedAt); return b.uploadedAt.localeCompare(a.uploadedAt); }); return list; }, [apps, query, category, sort]); return (
setQuery(e.target.value)} />
已找到资源 {filtered.length}
排序方式: {[ { id: "latest", label: "最新上架" }, { id: "hot", label: "热度优先" }, { id: "update", label: "最近更新" }, ].map((s) => ( ))}
{filtered.length > 0 ? (
{filtered.slice(0, count).map((app) => (
{app.icon}
{app.name} {app.version}

{app.subtitle}

{app.tags.slice(0, 3).map((tag) => ( {tag} ))}

更新

{app.updatedAt}

体积

{app.size}

下载

{app.downloads}

))}
) : (

没有找到匹配资源,换个关键词试试。

)} {count < filtered.length && (
)}
); }