Merge branch 'hamster1963:main' into main

This commit is contained in:
kattocloud 2024-11-04 20:48:44 +08:00 committed by GitHub
commit 82114cc65b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 44 additions and 72 deletions

View File

@ -8,6 +8,7 @@ NEXT_PUBLIC_DisableCartoon=false
NEXT_PUBLIC_ShowTag=true NEXT_PUBLIC_ShowTag=true
NEXT_PUBLIC_ShowNetTransfer=false NEXT_PUBLIC_ShowNetTransfer=false
NEXT_PUBLIC_ForceUseSvgFlag=false NEXT_PUBLIC_ForceUseSvgFlag=false
NEXT_PUBLIC_FixedTopServerName=false
NEXT_PUBLIC_CustomLogo=https://nezha-cf.buycoffee.top/apple-touch-icon.png NEXT_PUBLIC_CustomLogo=https://nezha-cf.buycoffee.top/apple-touch-icon.png
NEXT_PUBLIC_CustomTitle=NezhaDash NEXT_PUBLIC_CustomTitle=NezhaDash
NEXT_PUBLIC_CustomDescription=NezhaDash is a dashboard for Nezha. NEXT_PUBLIC_CustomDescription=NezhaDash is a dashboard for Nezha.

BIN
bun.lockb

Binary file not shown.

View File

@ -3,18 +3,11 @@ import ServerFlag from "@/components/ServerFlag";
import ServerUsageBar from "@/components/ServerUsageBar"; import ServerUsageBar from "@/components/ServerUsageBar";
import { Badge } from "@/components/ui/badge"; import { Badge } from "@/components/ui/badge";
import { Card } from "@/components/ui/card"; import { Card } from "@/components/ui/card";
import {
Tooltip,
TooltipContent,
TooltipProvider,
TooltipTrigger,
} from "@/components/ui/tooltip";
import getEnv from "@/lib/env-entry"; import getEnv from "@/lib/env-entry";
import { cn, formatBytes, formatNezhaInfo } from "@/lib/utils"; import { cn, formatBytes, formatNezhaInfo } from "@/lib/utils";
import { useTranslations } from "next-intl"; import { useTranslations } from "next-intl";
import Link from "next/link"; import Link from "next/link";
import { useRouter } from "next/navigation"; import { useRouter } from "next/navigation";
import { useEffect, useRef, useState } from "react";
export default function ServerCard({ export default function ServerCard({
serverInfo, serverInfo,
@ -28,27 +21,24 @@ export default function ServerCard({
const showFlag = getEnv("NEXT_PUBLIC_ShowFlag") === "true"; const showFlag = getEnv("NEXT_PUBLIC_ShowFlag") === "true";
const showNetTransfer = getEnv("NEXT_PUBLIC_ShowNetTransfer") === "true"; const showNetTransfer = getEnv("NEXT_PUBLIC_ShowNetTransfer") === "true";
const fixedTopServerName =
const nameRef = useRef<HTMLParagraphElement | null>(null); getEnv("NEXT_PUBLIC_FixedTopServerName") === "true";
const [isNameOverflow, setIsNameOverflow] = useState(false);
useEffect(() => {
if (nameRef.current) {
setIsNameOverflow(
nameRef.current.scrollWidth > nameRef.current.clientWidth,
);
}
}, [name]);
return online ? ( return online ? (
<Link href={`/${id}`} prefetch={true}> <Link href={`/${id}`} prefetch={true}>
<Card <Card
className={ className={cn(
"flex flex-col items-center justify-start gap-3 p-3 md:px-5 lg:flex-row cursor-pointer" "flex flex-col items-center justify-start gap-3 p-3 md:px-5 cursor-pointer",
} {
"flex-col": fixedTopServerName,
"lg:flex-row": !fixedTopServerName,
},
)}
> >
<section <section
className="grid items-center gap-2 lg:w-28" className={cn("grid items-center gap-2", {
"lg:w-40": !fixedTopServerName,
})}
style={{ gridTemplateColumns: "auto auto 1fr" }} style={{ gridTemplateColumns: "auto auto 1fr" }}
> >
<span className="h-2 w-2 shrink-0 rounded-full bg-green-500 self-center"></span> <span className="h-2 w-2 shrink-0 rounded-full bg-green-500 self-center"></span>
@ -60,30 +50,16 @@ export default function ServerCard({
> >
{showFlag ? <ServerFlag country_code={country_code} /> : null} {showFlag ? <ServerFlag country_code={country_code} /> : null}
</div> </div>
<TooltipProvider delayDuration={50}>
<Tooltip>
<TooltipTrigger asChild>
<div className="relative"> <div className="relative">
<p <p
ref={nameRef}
className={cn( className={cn(
"break-all font-bold tracking-tight text-nowrap lg:max-w-[80px] overflow-x-scroll scrollbar-hidden pr-4", "break-all font-bold tracking-tight",
showFlag ? "text-[11px]" : "text-sm", showFlag ? "text-xs" : "text-sm",
)} )}
> >
{name} {name}
</p> </p>
{isNameOverflow && (
<div className="absolute inset-y-0 right-0 w-4 bg-gradient-to-l from-background to-transparent pointer-events-none" />
)}
</div> </div>
</TooltipTrigger>
<TooltipContent>
<p className="text-xs text-muted-foreground">{name}</p>
</TooltipContent>
</Tooltip>
</TooltipProvider>
</section> </section>
<div className="flex flex-col gap-2"> <div className="flex flex-col gap-2">
<section className={"grid grid-cols-5 items-center gap-3"}> <section className={"grid grid-cols-5 items-center gap-3"}>
@ -152,14 +128,20 @@ export default function ServerCard({
) : ( ) : (
<Card <Card
className={cn( className={cn(
"flex flex-col items-center justify-start gap-3 p-3 md:px-5 lg:flex-row", "flex flex-col items-center justify-start gap-3 p-3 md:px-5",
showNetTransfer showNetTransfer
? "lg:min-h-[91px] min-h-[123px]" ? "lg:min-h-[91px] min-h-[123px]"
: "lg:min-h-[61px] min-h-[93px]", : "lg:min-h-[61px] min-h-[93px]",
{
"flex-col": fixedTopServerName,
"lg:flex-row": !fixedTopServerName,
},
)} )}
> >
<section <section
className="grid items-center gap-2 lg:w-28" className={cn("grid items-center gap-2", {
"lg:w-40": !fixedTopServerName,
})}
style={{ gridTemplateColumns: "auto auto 1fr" }} style={{ gridTemplateColumns: "auto auto 1fr" }}
> >
<span className="h-2 w-2 shrink-0 rounded-full bg-red-500 self-center"></span> <span className="h-2 w-2 shrink-0 rounded-full bg-red-500 self-center"></span>
@ -171,28 +153,16 @@ export default function ServerCard({
> >
{showFlag ? <ServerFlag country_code={country_code} /> : null} {showFlag ? <ServerFlag country_code={country_code} /> : null}
</div> </div>
<TooltipProvider delayDuration={50}>
<Tooltip>
<TooltipTrigger asChild>
<div className="relative"> <div className="relative">
<p <p
className={cn( className={cn(
"break-all font-bold tracking-tight text-nowrap overflow-x-scroll scrollbar-hidden pr-4", "break-all font-bold tracking-tight",
showFlag ? "text-xs max-w-[80px]" : "text-sm", showFlag ? "text-xs max-w-[80px]" : "text-sm",
)} )}
> >
{name} {name}
</p> </p>
{isNameOverflow && (
<div className="absolute inset-y-0 right-0 w-4 bg-gradient-to-l from-background to-transparent pointer-events-none" />
)}
</div> </div>
</TooltipTrigger>
<TooltipContent>
<p className="text-xs text-muted-foreground">{name}</p>
</TooltipContent>
</Tooltip>
</TooltipProvider>
</section> </section>
</Card> </Card>
); );

View File

@ -8,6 +8,7 @@ NEXT_PUBLIC_DisableCartoon=false
NEXT_PUBLIC_ShowTag=true NEXT_PUBLIC_ShowTag=true
NEXT_PUBLIC_ShowNetTransfer=false NEXT_PUBLIC_ShowNetTransfer=false
NEXT_PUBLIC_ForceUseSvgFlag=false NEXT_PUBLIC_ForceUseSvgFlag=false
NEXT_PUBLIC_FixedTopServerName=false
NEXT_PUBLIC_CustomLogo=https://nezha-cf.buycoffee.top/apple-touch-icon.png NEXT_PUBLIC_CustomLogo=https://nezha-cf.buycoffee.top/apple-touch-icon.png
NEXT_PUBLIC_CustomTitle=NezhaDash NEXT_PUBLIC_CustomTitle=NezhaDash
NEXT_PUBLIC_CustomDescription=NezhaDash is a dashboard for Nezha. NEXT_PUBLIC_CustomDescription=NezhaDash is a dashboard for Nezha.

View File

@ -1,6 +1,6 @@
{ {
"name": "nezha-dash", "name": "nezha-dash",
"version": "1.2.1", "version": "1.2.2",
"private": true, "private": true,
"scripts": { "scripts": {
"dev": "next dev -p 3020", "dev": "next dev -p 3020",
@ -32,7 +32,7 @@
"framer-motion": "^12.0.0-alpha.1", "framer-motion": "^12.0.0-alpha.1",
"lucide-react": "^0.454.0", "lucide-react": "^0.454.0",
"luxon": "^3.5.0", "luxon": "^3.5.0",
"next": "^15.0.3-canary.4", "next": "^15.0.3-canary.5",
"next-auth": "^5.0.0-beta.25", "next-auth": "^5.0.0-beta.25",
"next-intl": "^3.24.0", "next-intl": "^3.24.0",
"next-runtime-env": "^3.2.2", "next-runtime-env": "^3.2.2",