Compare commits

...

4 Commits

Author SHA1 Message Date
hamster1963
2302a50484 chore: bump version to 2.8.0 2025-02-21 11:35:42 +08:00
hamster1963
6c3c18fa1e chore: update bun lockfile 2025-02-21 11:26:43 +08:00
hamster1963
fca3a9ab52 feat: add server ID and improve interactive map and tooltip functionality 2025-02-21 11:26:32 +08:00
hamster1963
5b8be03765 feat: update button styles in ServerListClient for improved accessibility and visual consistency 2025-02-21 11:05:45 +08:00
6 changed files with 33 additions and 9 deletions

View File

@ -82,6 +82,7 @@ export function InteractiveMap({
(server: any) => server.host.CountryCode?.toUpperCase() === countryCode,
)
.map((server: any) => ({
id: server.id,
name: server.name,
status: server.online_status,
}))
@ -122,6 +123,7 @@ export function InteractiveMap({
const countryServers = nezhaServerList.result
.filter((server: any) => server.host.CountryCode?.toUpperCase() === countryCode)
.map((server: any) => ({
id: server.id,
name: server.name,
status: server.online_status,
}))

View File

@ -2,6 +2,7 @@
import { useTooltip } from "@/app/context/tooltip-context"
import { useTranslations } from "next-intl"
import Link from "next/link"
import { memo } from "react"
const MapTooltip = memo(function MapTooltip() {
@ -14,6 +15,10 @@ const MapTooltip = memo(function MapTooltip() {
return a.status === b.status ? 0 : a.status ? 1 : -1
})
const saveSession = () => {
sessionStorage.setItem("fromMainPage", "true")
}
return (
<div
className="absolute hidden lg:block bg-white dark:bg-neutral-800 px-2 py-1 rounded shadow-lg text-sm dark:border dark:border-neutral-700 z-50 tooltip-animate"
@ -31,7 +36,7 @@ const MapTooltip = memo(function MapTooltip() {
<p className="font-medium">
{tooltipData.country === "China" ? "Mainland China" : tooltipData.country}
</p>
<p className="text-neutral-600 dark:text-neutral-400 mb-1">
<p className="text-neutral-600 dark:text-neutral-400 font-light text-xs mb-1">
{tooltipData.count} {t("Servers")}
</p>
</div>
@ -43,14 +48,19 @@ const MapTooltip = memo(function MapTooltip() {
}}
>
{sortedServers.map((server) => (
<div key={server.name} className="flex items-center gap-1.5 py-0.5">
<Link
onClick={saveSession}
href={`/server/${server.id}`}
key={server.name}
className="flex items-center gap-1.5 py-0.5 transition-colors text-neutral-500 dark:text-neutral-400 hover:text-black dark:hover:text-white"
>
<span
className={`w-1.5 h-1.5 shrink-0 rounded-full ${
server.status ? "bg-green-500" : "bg-red-500"
}`}
/>
<span className="text-xs">{server.name}</span>
</div>
</Link>
))}
</div>
</div>

View File

@ -115,6 +115,11 @@ export default function ServerListClient() {
setInline(inlineState)
}
const showMapState = localStorage.getItem("showMap")
if (showMapState !== null) {
setShowMap(showMapState === "true")
}
const savedTag = sessionStorage.getItem("selectedTag") || defaultTag
setTag(savedTag)
restoreScrollPosition()
@ -169,11 +174,16 @@ export default function ServerListClient() {
<section className="flex items-center gap-2 w-full overflow-hidden">
<button
type="button"
onClick={() => setShowMap(!showMap)}
onClick={() => {
const newShowMap = !showMap
setShowMap(newShowMap)
localStorage.setItem("showMap", String(newShowMap))
}}
className={cn(
"rounded-[50px] text-white cursor-pointer [text-shadow:_0_1px_0_rgb(0_0_0_/_20%)] bg-blue-600 p-[10px] transition-all shadow-[inset_0_1px_0_rgba(255,255,255,0.2)]",
"rounded-[50px] flex flex-col items-center gap-0 cursor-pointer bg-blue-100 text-blue-600 dark:bg-blue-900 dark:text-blue-100 p-[10px] transition-all inset-shadow-2xs inset-shadow-white/20 ",
{
"shadow-[inset_0_1px_0_rgba(0,0,0,0.2)] bg-blue-500": showMap,
"inset-shadow-black/20 bg-blue-600 text-white dark:bg-blue-100 dark:text-blue-600":
showMap,
},
)}
>
@ -187,9 +197,10 @@ export default function ServerListClient() {
localStorage.setItem("inline", newInline)
}}
className={cn(
"rounded-[50px] text-white cursor-pointer [text-shadow:_0_1px_0_rgb(0_0_0_/_20%)] bg-blue-600 p-[10px] transition-all shadow-[inset_0_1px_0_rgba(255,255,255,0.2)]",
"rounded-[50px] flex flex-col items-center gap-0 cursor-pointer bg-blue-100 text-blue-600 dark:bg-blue-900 dark:text-blue-100 p-[10px] transition-all inset-shadow-2xs inset-shadow-white/20 ",
{
"shadow-[inset_0_1px_0_rgba(0,0,0,0.2)] bg-blue-500": inline === "1",
"inset-shadow-black/20 bg-blue-600 text-white dark:bg-blue-100 dark:text-blue-600":
inline === "1",
},
)}
>

View File

@ -7,6 +7,7 @@ export interface TooltipData {
country: string
count: number
servers: Array<{
id: string
name: string
status: boolean
}>

BIN
bun.lockb

Binary file not shown.

View File

@ -1,6 +1,6 @@
{
"name": "nezha-dash",
"version": "2.7.2",
"version": "2.8.0",
"private": true,
"scripts": {
"dev": "next dev -p 3040",