From 7e1a74c6f075eb748e676e697dcb47b06f75da84 Mon Sep 17 00:00:00 2001 From: hamster1963 <1410514192@qq.com> Date: Thu, 14 Nov 2024 16:54:10 +0800 Subject: [PATCH] feat: show number within subgroups --- .../ClientComponents/ServerListClient.tsx | 8 ++++++++ bun.lockb | Bin 457566 -> 457566 bytes components/Switch.tsx | 13 ++++++++++--- 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/app/(main)/ClientComponents/ServerListClient.tsx b/app/(main)/ClientComponents/ServerListClient.tsx index ff5345c..d907280 100644 --- a/app/(main)/ClientComponents/ServerListClient.tsx +++ b/app/(main)/ClientComponents/ServerListClient.tsx @@ -82,12 +82,20 @@ export default function ServerListClient() { ? sortedServers : sortedServers.filter((server) => server.tag === tag); + const tagCountMap: Record = {}; + sortedServers.forEach((server) => { + if (server.tag) { + tagCountMap[server.tag] = (tagCountMap[server.tag] || 0) + 1; + } + }); + return ( <> {getEnv("NEXT_PUBLIC_ShowTag") === "true" && uniqueTags.length > 1 && ( )} diff --git a/bun.lockb b/bun.lockb index 12a5c84cb0fea648a7b2a9ed8d6824860a21d7a9..5b87449672cbf959629034f247bd34d185e52ccb 100755 GIT binary patch delta 71 zcmccjP5Rz9>4p}@7N!>FEi8w!7%jIS&SJ@8WHgzsm&4-2Y@%l{opA+=@b(EgEGmqQ ZhTFI1viJjK+gbBjfS7eVYd%|K4*-n|7Ks1= delta 71 zcmccjP5Rz9>4p}@7N!>FEi8w!7%jFR&SJ@8WHg?xm&4-2Y^-N6opA+=@b(EgEGmqQ Z2HUshviJjK+gbBjfS7eVYd%|K4*-l^7K8u* diff --git a/components/Switch.tsx b/components/Switch.tsx index acd68c6..79d6cda 100644 --- a/components/Switch.tsx +++ b/components/Switch.tsx @@ -8,10 +8,12 @@ import React, { createRef, useEffect, useRef } from "react"; export default function Switch({ allTag, nowTag, + tagCountMap, onTagChange, }: { allTag: string[]; nowTag: string; + tagCountMap: Record; onTagChange: (tag: string) => void; }) { const scrollRef = useRef(null); @@ -84,9 +86,14 @@ export default function Switch({ /> )}
-

- {tag === "defaultTag" ? t("defaultTag") : tag} -

+
+ {tag === "defaultTag" ? t("defaultTag") : tag}{" "} + {tag !== "defaultTag" && ( +
+ {tagCountMap[tag]} +
+ )} +
))}