mirror of
https://github.com/hamster1963/nezha-dash.git
synced 2025-04-24 21:10:45 +08:00
Merge branch 'main' into cloudflare
This commit is contained in:
commit
8e4545f72a
55
.github/workflows/Deploy.yml
vendored
55
.github/workflows/Deploy.yml
vendored
@ -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 }}
|
||||
|
@ -47,12 +47,20 @@ export function NetworkChartClient({ server_id }: { server_id: number }) {
|
||||
},
|
||||
);
|
||||
|
||||
if (error)
|
||||
if (error) {
|
||||
return (
|
||||
<div className="flex flex-col items-center justify-center">
|
||||
<p className="text-sm font-medium opacity-40">{error.message}</p>
|
||||
</div>
|
||||
<>
|
||||
<div className="flex flex-col items-center justify-center">
|
||||
<p className="text-sm font-medium opacity-40">{error.message}</p>
|
||||
<p className="text-sm font-medium opacity-40">
|
||||
{t("chart_fetch_error_message")}
|
||||
</p>
|
||||
</div>
|
||||
<NetworkChartLoading />
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
if (!data) return <NetworkChartLoading />;
|
||||
|
||||
function transformData(data: NezhaAPIMonitor[]) {
|
||||
|
@ -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 (
|
||||
<Card>
|
||||
<CardHeader className="flex flex-col items-stretch space-y-0 border-b p-0 sm:flex-row">
|
||||
<div className="flex flex-1 flex-col justify-center gap-1 px-6 py-5">
|
||||
<CardTitle className="flex items-center gap-0.5 text-xl">
|
||||
<CardTitle
|
||||
onClick={() => {
|
||||
router.push(`/${locale}/`);
|
||||
}}
|
||||
className="flex items-center cursor-pointer gap-0.5 text-xl"
|
||||
>
|
||||
<BackIcon />
|
||||
<div className="aspect-auto h-[20px] w-24 bg-muted"></div>
|
||||
</CardTitle>
|
||||
|
@ -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");
|
||||
|
@ -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<Function>(() => { });
|
||||
const savedCallback = useRef<Function>(() => {});
|
||||
useEffect(() => {
|
||||
savedCallback.current = callback;
|
||||
});
|
||||
|
@ -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 }));
|
||||
|
@ -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 (
|
||||
<main className="relative h-screen w-full">
|
||||
<div className="absolute inset-0 m-4 flex items-center justify-center">
|
||||
<Image
|
||||
priority
|
||||
className="rounded-3xl object-cover"
|
||||
src="/tardis.jpg"
|
||||
fill={true}
|
||||
alt="TARDIS"
|
||||
/>
|
||||
<div className="text-container absolute right-4 p-4 md:right-20">
|
||||
<h1 className="text-2xl font-bold opacity-80 md:text-5xl">
|
||||
{t("h1_490-590_404NotFound")}
|
||||
</h1>
|
||||
<p className="text-lg opacity-60 md:text-base">
|
||||
{t("p_601-665_TARDISERROR")}
|
||||
</p>
|
||||
<Link href={"/"} className="text-2xl opacity-80 md:text-3xl">
|
||||
{t("Link_676-775_Doctor")}
|
||||
</Link>
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
);
|
||||
const t = useTranslations("NotFoundPage");
|
||||
return (
|
||||
<main className="relative h-screen w-full">
|
||||
<div className="absolute inset-0 m-4 flex items-center justify-center">
|
||||
<Image
|
||||
priority
|
||||
className="rounded-3xl object-cover"
|
||||
src="/tardis.jpg"
|
||||
fill={true}
|
||||
alt="TARDIS"
|
||||
/>
|
||||
<div className="text-container absolute right-4 p-4 md:right-20">
|
||||
<h1 className="text-2xl font-bold opacity-80 md:text-5xl">
|
||||
{t("h1_490-590_404NotFound")}
|
||||
</h1>
|
||||
<p className="text-lg opacity-60 md:text-base">
|
||||
{t("p_601-665_TARDISERROR")}
|
||||
</p>
|
||||
<Link href={"/"} className="text-2xl opacity-80 md:text-3xl">
|
||||
{t("Link_676-775_Doctor")}
|
||||
</Link>
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
);
|
||||
}
|
||||
|
@ -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";
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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,
|
||||
}: {
|
||||
|
@ -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,
|
||||
|
@ -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 <ServerListClient />;
|
||||
|
@ -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();
|
||||
|
@ -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));
|
||||
}
|
||||
|
@ -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"
|
||||
|
@ -29,7 +29,8 @@
|
||||
"Offline": "オフライン"
|
||||
},
|
||||
"NetworkChartClient": {
|
||||
"avg_delay": "遅延"
|
||||
"avg_delay": "遅延",
|
||||
"chart_fetch_error_message": "ネットワークデータの取得に失敗しました。サーバーの監視が有効になっているかどうかを確認してください"
|
||||
},
|
||||
"NetworkChart": {
|
||||
"ServerMonitorCount": "サービス"
|
||||
|
@ -29,7 +29,8 @@
|
||||
"Offline": "離線"
|
||||
},
|
||||
"NetworkChartClient": {
|
||||
"avg_delay": "延遲"
|
||||
"avg_delay": "延遲",
|
||||
"chart_fetch_error_message": "獲取網絡數據失敗,請檢查是否開啟服務端監控"
|
||||
},
|
||||
"NetworkChart": {
|
||||
"ServerMonitorCount": "個監測服務"
|
||||
|
@ -29,7 +29,8 @@
|
||||
"Offline": "离线"
|
||||
},
|
||||
"NetworkChartClient": {
|
||||
"avg_delay": "延迟"
|
||||
"avg_delay": "延迟",
|
||||
"chart_fetch_error_message": "获取网络数据失败,请检查是否开启服务端监控"
|
||||
},
|
||||
"NetworkChart": {
|
||||
"ServerMonitorCount": "个监控服务"
|
||||
|
Loading…
Reference in New Issue
Block a user