mirror of
https://github.com/hamster1963/nezha-dash.git
synced 2025-04-24 21:10:45 +08:00
Compare commits
4 Commits
1dae136edb
...
2302a50484
Author | SHA1 | Date | |
---|---|---|---|
|
2302a50484 | ||
|
6c3c18fa1e | ||
|
fca3a9ab52 | ||
|
5b8be03765 |
@ -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,
|
||||
}))
|
||||
|
@ -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>
|
||||
|
@ -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",
|
||||
},
|
||||
)}
|
||||
>
|
||||
|
@ -7,6 +7,7 @@ export interface TooltipData {
|
||||
country: string
|
||||
count: number
|
||||
servers: Array<{
|
||||
id: string
|
||||
name: string
|
||||
status: boolean
|
||||
}>
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "nezha-dash",
|
||||
"version": "2.7.2",
|
||||
"version": "2.8.0",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"dev": "next dev -p 3040",
|
||||
|
Loading…
Reference in New Issue
Block a user