diff --git a/.github/workflows/Deploy.yml b/.github/workflows/Deploy.yml index d4b250f..6440c3f 100644 --- a/.github/workflows/Deploy.yml +++ b/.github/workflows/Deploy.yml @@ -10,33 +10,6 @@ env: ALIYUN_REGISTRY_IMAGE: registry.cn-guangzhou.aliyuncs.com/hamster-home/nezha-dash jobs: - changelog: - name: Generate Changelog - runs-on: ubuntu-latest - outputs: - release_body: ${{ steps.git-cliff.outputs.content }} - steps: - - name: Checkout - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - name: Generate a changelog - uses: orhun/git-cliff-action@v4 - id: git-cliff - with: - config: git-cliff-config/cliff.toml - args: -vv --latest --strip 'footer' - env: - OUTPUT: CHANGES.md - - name: Release - uses: softprops/action-gh-release@v2 - if: startsWith(github.ref, 'refs/tags/') - with: - body: ${{ steps.git-cliff.outputs.content }} - token: ${{ secrets.GITHUB_TOKEN }} - env: - GITHUB_REPOSITORY: ${{ github.repository }} - build-and-push: name: Build and push Docker image runs-on: ubuntu-latest @@ -76,3 +49,31 @@ jobs: push: true tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} + + changelog: + name: Generate Changelog + runs-on: ubuntu-latest + needs: build-and-push + outputs: + release_body: ${{ steps.git-cliff.outputs.content }} + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Generate a changelog + uses: orhun/git-cliff-action@v4 + id: git-cliff + with: + config: git-cliff-config/cliff.toml + args: -vv --latest --strip 'footer' + env: + OUTPUT: CHANGES.md + - name: Release + uses: softprops/action-gh-release@v2 + if: startsWith(github.ref, 'refs/tags/') + with: + body: ${{ steps.git-cliff.outputs.content }} + token: ${{ secrets.GITHUB_TOKEN }} + env: + GITHUB_REPOSITORY: ${{ github.repository }} diff --git a/app/[locale]/(main)/ClientComponents/NetworkChart.tsx b/app/[locale]/(main)/ClientComponents/NetworkChart.tsx index 83fa09b..73db61d 100644 --- a/app/[locale]/(main)/ClientComponents/NetworkChart.tsx +++ b/app/[locale]/(main)/ClientComponents/NetworkChart.tsx @@ -47,12 +47,20 @@ export function NetworkChartClient({ server_id }: { server_id: number }) { }, ); - if (error) + if (error) { return ( -
-

{error.message}

-
+ <> +
+

{error.message}

+

+ {t("chart_fetch_error_message")} +

+
+ + ); + } + if (!data) return ; function transformData(data: NezhaAPIMonitor[]) { diff --git a/app/[locale]/(main)/ClientComponents/NetworkChartLoading.tsx b/app/[locale]/(main)/ClientComponents/NetworkChartLoading.tsx index 6c23ac6..3a9c908 100644 --- a/app/[locale]/(main)/ClientComponents/NetworkChartLoading.tsx +++ b/app/[locale]/(main)/ClientComponents/NetworkChartLoading.tsx @@ -1,13 +1,23 @@ import { BackIcon } from "@/components/Icon"; import { Loader } from "@/components/loading/Loader"; import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card"; +import { useLocale } from "next-intl"; +import { useRouter } from "next/navigation"; export default function NetworkChartLoading() { + const router = useRouter(); + const locale = useLocale(); + return (
- + { + router.push(`/${locale}/`); + }} + className="flex items-center cursor-pointer gap-0.5 text-xl" + >
diff --git a/app/[locale]/(main)/ClientComponents/ServerOverviewClient.tsx b/app/[locale]/(main)/ClientComponents/ServerOverviewClient.tsx index 14ec2a3..a4ebb7e 100644 --- a/app/[locale]/(main)/ClientComponents/ServerOverviewClient.tsx +++ b/app/[locale]/(main)/ClientComponents/ServerOverviewClient.tsx @@ -1,15 +1,14 @@ "use client"; -import { useTranslations } from "next-intl"; -import Image from "next/image"; -import useSWR from "swr"; - +import { ServerApi } from "@/app/[locale]/types/nezha-api"; import { Loader } from "@/components/loading/Loader"; import { Card, CardContent } from "@/components/ui/card"; import getEnv from "@/lib/env-entry"; import { formatBytes, nezhaFetcher } from "@/lib/utils"; import blogMan from "@/public/blog-man.webp"; -import { ServerApi } from "@/app/[locale]/types/nezha-api"; +import { useTranslations } from "next-intl"; +import Image from "next/image"; +import useSWR from "swr"; export default function ServerOverviewClient() { const t = useTranslations("ServerOverviewClient"); diff --git a/app/[locale]/(main)/header.tsx b/app/[locale]/(main)/header.tsx index 260c6a9..ba182b4 100644 --- a/app/[locale]/(main)/header.tsx +++ b/app/[locale]/(main)/header.tsx @@ -45,7 +45,7 @@ function Header() { // https://github.com/streamich/react-use/blob/master/src/useInterval.ts const useInterval = (callback: Function, delay?: number | null) => { - const savedCallback = useRef(() => { }); + const savedCallback = useRef(() => {}); useEffect(() => { savedCallback.current = callback; }); diff --git a/app/[locale]/layout.tsx b/app/[locale]/layout.tsx index 3277eb5..96eb3da 100644 --- a/app/[locale]/layout.tsx +++ b/app/[locale]/layout.tsx @@ -39,7 +39,7 @@ export const viewport: Viewport = { // optimization: force static for vercel export const dynamic = process.env.VERCEL ? "force-static" : "auto"; -export const runtime = 'edge'; +export const runtime = "edge"; export async function generateStaticParams() { return locales.map((locale) => ({ locale })); diff --git a/app/[locale]/not-found.tsx b/app/[locale]/not-found.tsx index 0e1b245..237a1e0 100644 --- a/app/[locale]/not-found.tsx +++ b/app/[locale]/not-found.tsx @@ -2,33 +2,32 @@ import { useTranslations } from "next-intl"; import Image from "next/image"; import Link from "next/link"; -export const runtime = 'edge'; - +export const runtime = "edge"; export default function NotFoundPage() { - const t = useTranslations("NotFoundPage"); - return ( -
-
- TARDIS -
-

- {t("h1_490-590_404NotFound")} -

-

- {t("p_601-665_TARDISERROR")} -

- - {t("Link_676-775_Doctor")} - -
-
-
- ); + const t = useTranslations("NotFoundPage"); + return ( +
+
+ TARDIS +
+

+ {t("h1_490-590_404NotFound")} +

+

+ {t("p_601-665_TARDISERROR")} +

+ + {t("Link_676-775_Doctor")} + +
+
+
+ ); } diff --git a/app/api/monitor/route.ts b/app/api/monitor/route.ts index 556767a..26a51b4 100644 --- a/app/api/monitor/route.ts +++ b/app/api/monitor/route.ts @@ -2,7 +2,7 @@ import { ServerMonitorChart } from "@/app/[locale]/types/nezha-api"; import { GetServerMonitor } from "@/lib/serverFetch"; import { NextResponse } from "next/server"; -export const runtime = 'edge'; +export const runtime = "edge"; export const dynamic = "force-dynamic"; diff --git a/app/api/server/route.ts b/app/api/server/route.ts index 0854a79..9aa6e7d 100644 --- a/app/api/server/route.ts +++ b/app/api/server/route.ts @@ -1,4 +1,3 @@ - import { NezhaAPI, ServerApi } from "@/app/[locale]/types/nezha-api"; import { MakeOptional } from "@/app/[locale]/types/utils"; import getEnv from "@/lib/env-entry"; @@ -6,14 +5,13 @@ import { NextResponse } from "next/server"; export const dynamic = "force-dynamic"; -export const runtime = 'edge'; +export const runtime = "edge"; interface NezhaDataResponse { error?: string; data?: ServerApi; } - export async function GET(_: Request) { const response = (await GetNezhaData()) as NezhaDataResponse; if (response.error) { @@ -24,7 +22,6 @@ export async function GET(_: Request) { } async function GetNezhaData() { - var nezhaBaseUrl = getEnv("NezhaBaseUrl"); if (!nezhaBaseUrl) { console.log("NezhaBaseUrl is not set"); @@ -80,4 +77,4 @@ async function GetNezhaData() { } catch (error) { return error; } -} \ No newline at end of file +} diff --git a/components/ServerCard.tsx b/components/ServerCard.tsx index d9c7970..c03890d 100644 --- a/components/ServerCard.tsx +++ b/components/ServerCard.tsx @@ -1,3 +1,6 @@ +import { NezhaAPISafe } from "@/app/[locale]/types/nezha-api"; +import ServerCardPopover from "@/components/ServerCardPopover"; +import ServerFlag from "@/components/ServerFlag"; import ServerUsageBar from "@/components/ServerUsageBar"; import { Card } from "@/components/ui/card"; import { @@ -10,10 +13,6 @@ import { useLocale, useTranslations } from "next-intl"; import { env } from "next-runtime-env"; import { useRouter } from "next/navigation"; -import { NezhaAPISafe } from "@/app/[locale]/types/nezha-api"; -import ServerCardPopover from "@/components/ServerCardPopover"; -import ServerFlag from "@/components/ServerFlag"; - export default function ServerCard({ serverInfo, }: { diff --git a/components/ServerCardPopover.tsx b/components/ServerCardPopover.tsx index c0f8031..9638802 100644 --- a/components/ServerCardPopover.tsx +++ b/components/ServerCardPopover.tsx @@ -1,8 +1,7 @@ +import { NezhaAPISafe } from "@/app/[locale]/types/nezha-api"; import { cn, formatBytes } from "@/lib/utils"; import { useTranslations } from "next-intl"; -import { NezhaAPISafe } from "@/app/[locale]/types/nezha-api"; - export function ServerCardPopoverCard({ className, title, diff --git a/components/ServerList.tsx b/components/ServerList.tsx index 5152f49..2c6abb2 100644 --- a/components/ServerList.tsx +++ b/components/ServerList.tsx @@ -1,6 +1,5 @@ -import React from "react"; - import ServerListClient from "@/app/[locale]/(main)/ClientComponents/ServerListClient"; +import React from "react"; export default async function ServerList() { return ; diff --git a/lib/serverFetch.tsx b/lib/serverFetch.tsx index 523f8ad..22d2451 100644 --- a/lib/serverFetch.tsx +++ b/lib/serverFetch.tsx @@ -1,10 +1,9 @@ "use server"; -import { unstable_noStore as noStore } from "next/cache"; - import { NezhaAPI, ServerApi } from "@/app/[locale]/types/nezha-api"; import { MakeOptional } from "@/app/[locale]/types/utils"; import getEnv from "@/lib/env-entry"; +import { unstable_noStore as noStore } from "next/cache"; export async function GetNezhaData() { noStore(); diff --git a/lib/utils.ts b/lib/utils.ts index 8abce68..6df8955 100644 --- a/lib/utils.ts +++ b/lib/utils.ts @@ -1,8 +1,7 @@ +import { NezhaAPISafe } from "@/app/[locale]/types/nezha-api"; import { type ClassValue, clsx } from "clsx"; import { twMerge } from "tailwind-merge"; -import { NezhaAPISafe } from "@/app/[locale]/types/nezha-api"; - export function cn(...inputs: ClassValue[]) { return twMerge(clsx(inputs)); } diff --git a/messages/en.json b/messages/en.json index 880aac0..3d09ae7 100644 --- a/messages/en.json +++ b/messages/en.json @@ -29,7 +29,8 @@ "Offline": "Offline" }, "NetworkChartClient": { - "avg_delay": "Latency" + "avg_delay": "Latency", + "chart_fetch_error_message": "Failed to fetch network data, please check if the server monitoring is enabled" }, "NetworkChart": { "ServerMonitorCount": "Services" diff --git a/messages/ja.json b/messages/ja.json index 7e13beb..e308748 100644 --- a/messages/ja.json +++ b/messages/ja.json @@ -29,7 +29,8 @@ "Offline": "オフライン" }, "NetworkChartClient": { - "avg_delay": "遅延" + "avg_delay": "遅延", + "chart_fetch_error_message": "ネットワークデータの取得に失敗しました。サーバーの監視が有効になっているかどうかを確認してください" }, "NetworkChart": { "ServerMonitorCount": "サービス" diff --git a/messages/zh-t.json b/messages/zh-t.json index 8f754cd..9efe44c 100644 --- a/messages/zh-t.json +++ b/messages/zh-t.json @@ -29,7 +29,8 @@ "Offline": "離線" }, "NetworkChartClient": { - "avg_delay": "延遲" + "avg_delay": "延遲", + "chart_fetch_error_message": "獲取網絡數據失敗,請檢查是否開啟服務端監控" }, "NetworkChart": { "ServerMonitorCount": "個監測服務" diff --git a/messages/zh.json b/messages/zh.json index b7b2652..c573923 100644 --- a/messages/zh.json +++ b/messages/zh.json @@ -29,7 +29,8 @@ "Offline": "离线" }, "NetworkChartClient": { - "avg_delay": "延迟" + "avg_delay": "延迟", + "chart_fetch_error_message": "获取网络数据失败,请检查是否开启服务端监控" }, "NetworkChart": { "ServerMonitorCount": "个监控服务"