mirror of
https://github.com/hamster1963/nezha-dash.git
synced 2025-04-24 21:10:45 +08:00
feat: show number within subgroups
This commit is contained in:
parent
f931a9c487
commit
7e1a74c6f0
@ -82,12 +82,20 @@ export default function ServerListClient() {
|
|||||||
? sortedServers
|
? sortedServers
|
||||||
: sortedServers.filter((server) => server.tag === tag);
|
: sortedServers.filter((server) => server.tag === tag);
|
||||||
|
|
||||||
|
const tagCountMap: Record<string, number> = {};
|
||||||
|
sortedServers.forEach((server) => {
|
||||||
|
if (server.tag) {
|
||||||
|
tagCountMap[server.tag] = (tagCountMap[server.tag] || 0) + 1;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{getEnv("NEXT_PUBLIC_ShowTag") === "true" && uniqueTags.length > 1 && (
|
{getEnv("NEXT_PUBLIC_ShowTag") === "true" && uniqueTags.length > 1 && (
|
||||||
<Switch
|
<Switch
|
||||||
allTag={uniqueTags}
|
allTag={uniqueTags}
|
||||||
nowTag={tag}
|
nowTag={tag}
|
||||||
|
tagCountMap={tagCountMap}
|
||||||
onTagChange={handleTagChange}
|
onTagChange={handleTagChange}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
@ -8,10 +8,12 @@ import React, { createRef, useEffect, useRef } from "react";
|
|||||||
export default function Switch({
|
export default function Switch({
|
||||||
allTag,
|
allTag,
|
||||||
nowTag,
|
nowTag,
|
||||||
|
tagCountMap,
|
||||||
onTagChange,
|
onTagChange,
|
||||||
}: {
|
}: {
|
||||||
allTag: string[];
|
allTag: string[];
|
||||||
nowTag: string;
|
nowTag: string;
|
||||||
|
tagCountMap: Record<string, number>;
|
||||||
onTagChange: (tag: string) => void;
|
onTagChange: (tag: string) => void;
|
||||||
}) {
|
}) {
|
||||||
const scrollRef = useRef<HTMLDivElement>(null);
|
const scrollRef = useRef<HTMLDivElement>(null);
|
||||||
@ -84,9 +86,14 @@ export default function Switch({
|
|||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
<div className="relative z-20 flex items-center gap-1">
|
<div className="relative z-20 flex items-center gap-1">
|
||||||
<p className="whitespace-nowrap">
|
<div className="whitespace-nowrap flex items-center gap-2">
|
||||||
{tag === "defaultTag" ? t("defaultTag") : tag}
|
{tag === "defaultTag" ? t("defaultTag") : tag}{" "}
|
||||||
</p>
|
{tag !== "defaultTag" && (
|
||||||
|
<div className="w-fit px-1.5 rounded-full bg-muted">
|
||||||
|
{tagCountMap[tag]}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
))}
|
))}
|
||||||
|
Loading…
Reference in New Issue
Block a user