mirror of
https://github.com/hamster1963/nezha-dash.git
synced 2025-04-24 21:10:45 +08:00
refactor: core lib
This commit is contained in:
parent
bc0886e8c0
commit
b76ab55cb2
@ -4,7 +4,7 @@ import {
|
|||||||
MAX_HISTORY_LENGTH,
|
MAX_HISTORY_LENGTH,
|
||||||
ServerDataWithTimestamp,
|
ServerDataWithTimestamp,
|
||||||
useServerData,
|
useServerData,
|
||||||
} from "@/app/lib/server-data-context"
|
} from "@/app/context/server-data-context"
|
||||||
import { NezhaAPISafe } from "@/app/types/nezha-api"
|
import { NezhaAPISafe } from "@/app/types/nezha-api"
|
||||||
import { ServerDetailChartLoading } from "@/components/loading/ServerDetailLoading"
|
import { ServerDetailChartLoading } from "@/components/loading/ServerDetailLoading"
|
||||||
import AnimatedCircularProgressBar from "@/components/ui/animated-circular-progress-bar"
|
import AnimatedCircularProgressBar from "@/components/ui/animated-circular-progress-bar"
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
"use client"
|
"use client"
|
||||||
|
|
||||||
import { useServerData } from "@/app/lib/server-data-context"
|
import { useServerData } from "@/app/context/server-data-context"
|
||||||
import { BackIcon } from "@/components/Icon"
|
import { BackIcon } from "@/components/Icon"
|
||||||
import ServerFlag from "@/components/ServerFlag"
|
import ServerFlag from "@/components/ServerFlag"
|
||||||
import { ServerDetailLoading } from "@/components/loading/ServerDetailLoading"
|
import { ServerDetailLoading } from "@/components/loading/ServerDetailLoading"
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
"use client"
|
"use client"
|
||||||
|
|
||||||
import { TooltipProvider } from "@/app/(main)/ClientComponents/detail/TooltipContext"
|
|
||||||
import GlobalInfo from "@/app/(main)/ClientComponents/main/GlobalInfo"
|
import GlobalInfo from "@/app/(main)/ClientComponents/main/GlobalInfo"
|
||||||
import { InteractiveMap } from "@/app/(main)/ClientComponents/main/InteractiveMap"
|
import { InteractiveMap } from "@/app/(main)/ClientComponents/main/InteractiveMap"
|
||||||
import { useServerData } from "@/app/lib/server-data-context"
|
import { useServerData } from "@/app/context/server-data-context"
|
||||||
|
import { TooltipProvider } from "@/app/context/tooltip-context"
|
||||||
import GlobalLoading from "@/components/loading/GlobalLoading"
|
import GlobalLoading from "@/components/loading/GlobalLoading"
|
||||||
import { geoJsonString } from "@/lib/geo-json-string"
|
import { geoJsonString } from "@/lib/geo/geo-json-string"
|
||||||
|
|
||||||
export default function ServerGlobal() {
|
export default function ServerGlobal() {
|
||||||
const { data: nezhaServerList, error } = useServerData()
|
const { data: nezhaServerList, error } = useServerData()
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
"use client"
|
"use client"
|
||||||
|
|
||||||
import { useTooltip } from "@/app/(main)/ClientComponents/detail/TooltipContext"
|
|
||||||
import MapTooltip from "@/app/(main)/ClientComponents/main/MapTooltip"
|
import MapTooltip from "@/app/(main)/ClientComponents/main/MapTooltip"
|
||||||
import { countryCoordinates } from "@/lib/geo-limit"
|
import { useTooltip } from "@/app/context/tooltip-context"
|
||||||
|
import { countryCoordinates } from "@/lib/geo/geo-limit"
|
||||||
import { geoEquirectangular, geoPath } from "d3-geo"
|
import { geoEquirectangular, geoPath } from "d3-geo"
|
||||||
|
|
||||||
interface InteractiveMapProps {
|
interface InteractiveMapProps {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
"use client"
|
"use client"
|
||||||
|
|
||||||
import { useTooltip } from "@/app/(main)/ClientComponents/detail/TooltipContext"
|
import { useTooltip } from "@/app/context/tooltip-context"
|
||||||
import { useTranslations } from "next-intl"
|
import { useTranslations } from "next-intl"
|
||||||
import { memo } from "react"
|
import { memo } from "react"
|
||||||
|
|
||||||
|
@ -1,14 +1,14 @@
|
|||||||
"use client"
|
"use client"
|
||||||
|
|
||||||
import { useServerData } from "@/app/lib/server-data-context"
|
import { useFilter } from "@/app/context/network-filter-context"
|
||||||
|
import { useServerData } from "@/app/context/server-data-context"
|
||||||
|
import { useStatus } from "@/app/context/status-context"
|
||||||
import ServerCard from "@/components/ServerCard"
|
import ServerCard from "@/components/ServerCard"
|
||||||
import ServerCardInline from "@/components/ServerCardInline"
|
import ServerCardInline from "@/components/ServerCardInline"
|
||||||
import Switch from "@/components/Switch"
|
import Switch from "@/components/Switch"
|
||||||
import GlobalLoading from "@/components/loading/GlobalLoading"
|
import GlobalLoading from "@/components/loading/GlobalLoading"
|
||||||
import { Loader } from "@/components/loading/Loader"
|
import { Loader } from "@/components/loading/Loader"
|
||||||
import getEnv from "@/lib/env-entry"
|
import getEnv from "@/lib/env-entry"
|
||||||
import { useFilter } from "@/lib/network-filter-context"
|
|
||||||
import { useStatus } from "@/lib/status-context"
|
|
||||||
import { cn } from "@/lib/utils"
|
import { cn } from "@/lib/utils"
|
||||||
import { MapIcon, ViewColumnsIcon } from "@heroicons/react/20/solid"
|
import { MapIcon, ViewColumnsIcon } from "@heroicons/react/20/solid"
|
||||||
import { useTranslations } from "next-intl"
|
import { useTranslations } from "next-intl"
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
"use client"
|
"use client"
|
||||||
|
|
||||||
import { useServerData } from "@/app/lib/server-data-context"
|
import { useFilter } from "@/app/context/network-filter-context"
|
||||||
|
import { useServerData } from "@/app/context/server-data-context"
|
||||||
|
import { useStatus } from "@/app/context/status-context"
|
||||||
import { Loader } from "@/components/loading/Loader"
|
import { Loader } from "@/components/loading/Loader"
|
||||||
import { Card, CardContent } from "@/components/ui/card"
|
import { Card, CardContent } from "@/components/ui/card"
|
||||||
import getEnv from "@/lib/env-entry"
|
import getEnv from "@/lib/env-entry"
|
||||||
import { useFilter } from "@/lib/network-filter-context"
|
|
||||||
import { useStatus } from "@/lib/status-context"
|
|
||||||
import { cn, formatBytes } from "@/lib/utils"
|
import { cn, formatBytes } from "@/lib/utils"
|
||||||
import blogMan from "@/public/blog-man.webp"
|
import blogMan from "@/public/blog-man.webp"
|
||||||
import { ArrowDownCircleIcon, ArrowUpCircleIcon } from "@heroicons/react/20/solid"
|
import { ArrowDownCircleIcon, ArrowUpCircleIcon } from "@heroicons/react/20/solid"
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import Footer from "@/app/(main)/footer"
|
import Footer from "@/app/(main)/footer"
|
||||||
import Header from "@/app/(main)/header"
|
import Header from "@/app/(main)/header"
|
||||||
import { ServerDataProvider } from "@/app/lib/server-data-context"
|
import { ServerDataProvider } from "@/app/context/server-data-context"
|
||||||
import { auth } from "@/auth"
|
import { auth } from "@/auth"
|
||||||
import { SignIn } from "@/components/SignIn"
|
import { SignIn } from "@/components/SignIn"
|
||||||
import getEnv from "@/lib/env-entry"
|
import getEnv from "@/lib/env-entry"
|
||||||
|
@ -41,9 +41,9 @@ export async function GET(req: NextRequest) {
|
|||||||
try {
|
try {
|
||||||
const ip = await GetServerIP({ server_id: Number(server_id) })
|
const ip = await GetServerIP({ server_id: Number(server_id) })
|
||||||
|
|
||||||
const cityDbPath = path.join(process.cwd(), "lib", "GeoLite2-City.mmdb")
|
const cityDbPath = path.join(process.cwd(), "lib", "maxmind-db", "GeoLite2-City.mmdb")
|
||||||
|
|
||||||
const asnDbPath = path.join(process.cwd(), "lib", "GeoLite2-ASN.mmdb")
|
const asnDbPath = path.join(process.cwd(), "lib", "maxmind-db", "GeoLite2-ASN.mmdb")
|
||||||
|
|
||||||
const cityDbBuffer = fs.readFileSync(cityDbPath)
|
const cityDbBuffer = fs.readFileSync(cityDbPath)
|
||||||
const asnDbBuffer = fs.readFileSync(asnDbPath)
|
const asnDbBuffer = fs.readFileSync(asnDbPath)
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
|
import { FilterProvider } from "@/app/context/network-filter-context"
|
||||||
|
import { StatusProvider } from "@/app/context/status-context"
|
||||||
// @auto-i18n-check. Please do not delete the line.
|
// @auto-i18n-check. Please do not delete the line.
|
||||||
import { ThemeColorManager } from "@/components/ThemeColorManager"
|
import { ThemeColorManager } from "@/components/ThemeColorManager"
|
||||||
import getEnv from "@/lib/env-entry"
|
import getEnv from "@/lib/env-entry"
|
||||||
import { FilterProvider } from "@/lib/network-filter-context"
|
|
||||||
import { StatusProvider } from "@/lib/status-context"
|
|
||||||
import { cn } from "@/lib/utils"
|
import { cn } from "@/lib/utils"
|
||||||
import "@/styles/globals.css"
|
import "@/styles/globals.css"
|
||||||
import type { Metadata } from "next"
|
import type { Metadata } from "next"
|
||||||
|
183
lib/dev-geo.ts
183
lib/dev-geo.ts
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Before Width: | Height: | Size: 56 MiB After Width: | Height: | Size: 56 MiB |
Loading…
Reference in New Issue
Block a user