Skip to content

Commit

Permalink
feat: disableShowNetTransfer env
Browse files Browse the repository at this point in the history
  • Loading branch information
hamster1963 committed Dec 14, 2024
1 parent 9921a9a commit ffcbf44
Showing 1 changed file with 20 additions and 15 deletions.
35 changes: 20 additions & 15 deletions src/components/ServerCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ export default function ServerCard({ now, serverInfo }: { now: number; serverInf
} = formatNezhaInfo(now, serverInfo)

const showFlag = true
// @ts-expect-error ShowNetTransfer is a global variable
const disableShowNetTransfer = window.ShowNetTransfer === "false"

const parsedData = parsePublicNote(public_note)

Expand Down Expand Up @@ -121,27 +123,30 @@ export default function ServerCard({ now, serverInfo }: { now: number; serverInf
</div>
</div>
</section>
<section className={"flex items-center justify-between gap-1"}>
<Badge
variant="secondary"
className="items-center flex-1 justify-center rounded-[8px] text-nowrap text-[11px] border-muted-50 shadow-md shadow-neutral-200/30 dark:shadow-none"
>
{t("serverCard.upload")}:{formatBytes(net_out_transfer)}
</Badge>
<Badge
variant="outline"
className="items-center flex-1 justify-center rounded-[8px] text-nowrap text-[11px] shadow-md shadow-neutral-200/30 dark:shadow-none"
>
{t("serverCard.download")}:{formatBytes(net_in_transfer)}
</Badge>
</section>
{!disableShowNetTransfer && (
<section className={"flex items-center justify-between gap-1"}>
<Badge
variant="secondary"
className="items-center flex-1 justify-center rounded-[8px] text-nowrap text-[11px] border-muted-50 shadow-md shadow-neutral-200/30 dark:shadow-none"
>
{t("serverCard.upload")}:{formatBytes(net_out_transfer)}
</Badge>
<Badge
variant="outline"
className="items-center flex-1 justify-center rounded-[8px] text-nowrap text-[11px] shadow-md shadow-neutral-200/30 dark:shadow-none"
>
{t("serverCard.download")}:{formatBytes(net_in_transfer)}
</Badge>
</section>
)}
</div>
</Card>
</section>
) : (
<Card
className={cn(
"flex flex-col lg:min-h-[91px] min-h-[123px] items-center justify-start gap-3 p-3 md:px-5 lg:flex-row cursor-pointer hover:bg-accent/50 transition-colors",
"flex flex-col items-center justify-start gap-3 p-3 md:px-5 lg:flex-row cursor-pointer hover:bg-accent/50 transition-colors",
!disableShowNetTransfer ? "lg:min-h-[91px] min-h-[123px]" : "lg:min-h-[61px] min-h-[93px]",
)}
onClick={() => navigate(`/server/${serverInfo.id}`, { replace: true })}
>
Expand Down

0 comments on commit ffcbf44

Please sign in to comment.