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
381a6b894f
36
.github/workflows/Deploy.yml
vendored
36
.github/workflows/Deploy.yml
vendored
@ -18,11 +18,10 @@ jobs:
|
|||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Set up QEMU
|
|
||||||
uses: docker/setup-qemu-action@v3
|
|
||||||
|
|
||||||
- name: Set up Docker Buildx
|
- name: Set up Docker Buildx
|
||||||
uses: docker/setup-buildx-action@v3
|
uses: docker/setup-buildx-action@v3
|
||||||
|
with:
|
||||||
|
driver-opts: network=host
|
||||||
|
|
||||||
- name: Login to Docker Hub
|
- name: Login to Docker Hub
|
||||||
uses: docker/login-action@v3
|
uses: docker/login-action@v3
|
||||||
@ -50,30 +49,19 @@ jobs:
|
|||||||
tags: ${{ steps.meta.outputs.tags }}
|
tags: ${{ steps.meta.outputs.tags }}
|
||||||
labels: ${{ steps.meta.outputs.labels }}
|
labels: ${{ steps.meta.outputs.labels }}
|
||||||
|
|
||||||
changelog:
|
release:
|
||||||
name: Generate Changelog
|
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
needs: build-and-push
|
|
||||||
outputs:
|
|
||||||
release_body: ${{ steps.git-cliff.outputs.content }}
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- uses: actions/checkout@v4
|
||||||
uses: actions/checkout@v4
|
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
- name: Generate a changelog
|
|
||||||
uses: orhun/git-cliff-action@v4
|
- name: Set node
|
||||||
id: git-cliff
|
uses: actions/setup-node@v4
|
||||||
with:
|
with:
|
||||||
config: git-cliff-config/cliff.toml
|
registry-url: https://registry.npmjs.org/
|
||||||
args: -vv --latest --strip 'footer'
|
node-version: lts/*
|
||||||
|
|
||||||
|
- run: npx changelogithub
|
||||||
env:
|
env:
|
||||||
OUTPUT: CHANGES.md
|
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
|
||||||
- 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 }}
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
FROM oven/bun:1 AS base
|
FROM --platform=$BUILDPLATFORM oven/bun:1 AS base
|
||||||
|
|
||||||
# Stage 1: Install dependencies
|
# Stage 1: Install dependencies
|
||||||
FROM base AS deps
|
FROM base AS deps
|
||||||
|
@ -18,13 +18,16 @@ export default function ServerOverviewClient() {
|
|||||||
);
|
);
|
||||||
const disableCartoon = getEnv("NEXT_PUBLIC_DisableCartoon") === "true";
|
const disableCartoon = getEnv("NEXT_PUBLIC_DisableCartoon") === "true";
|
||||||
|
|
||||||
if (error)
|
if (error) {
|
||||||
return (
|
return (
|
||||||
<div className="flex flex-col items-center justify-center">
|
<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">
|
||||||
|
Error status:{error.status} {error.info?.cause ?? error.message}
|
||||||
|
</p>
|
||||||
<p className="text-sm font-medium opacity-40">{t("error_message")}</p>
|
<p className="text-sm font-medium opacity-40">{t("error_message")}</p>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
|
import pack from "@/package.json";
|
||||||
import { useTranslations } from "next-intl";
|
import { useTranslations } from "next-intl";
|
||||||
|
|
||||||
export default function Footer() {
|
export default function Footer() {
|
||||||
const t = useTranslations("Footer");
|
const t = useTranslations("Footer");
|
||||||
|
const version = pack.version;
|
||||||
return (
|
return (
|
||||||
<footer className="mx-auto w-full max-w-5xl">
|
<footer className="mx-auto w-full max-w-5xl">
|
||||||
<section className="flex flex-col">
|
<section className="flex flex-col">
|
||||||
@ -14,6 +16,13 @@ export default function Footer() {
|
|||||||
>
|
>
|
||||||
{t("a_303-585_GitHub")}
|
{t("a_303-585_GitHub")}
|
||||||
</a>
|
</a>
|
||||||
|
<a
|
||||||
|
href={`https://github.com/hamster1963/nezha-dash/releases/tag/v${version}`}
|
||||||
|
target="_blank"
|
||||||
|
className="cursor-pointer font-normal underline decoration-yellow-500 decoration-2 underline-offset-2 dark:decoration-yellow-500/50"
|
||||||
|
>
|
||||||
|
v{version}
|
||||||
|
</a>
|
||||||
</p>
|
</p>
|
||||||
<section className="mt-1 flex items-center gap-2 text-[13px] font-light tracking-tight text-neutral-600/50 dark:text-neutral-300/50">
|
<section className="mt-1 flex items-center gap-2 text-[13px] font-light tracking-tight text-neutral-600/50 dark:text-neutral-300/50">
|
||||||
{t("section_607-869_2020")}
|
{t("section_607-869_2020")}
|
||||||
|
@ -12,6 +12,7 @@ export const runtime = "edge";
|
|||||||
interface NezhaDataResponse {
|
interface NezhaDataResponse {
|
||||||
error?: string;
|
error?: string;
|
||||||
data?: ServerApi;
|
data?: ServerApi;
|
||||||
|
cause?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const GET = auth(async function GET(req) {
|
export const GET = auth(async function GET(req) {
|
||||||
@ -21,8 +22,13 @@ export const GET = auth(async function GET(req) {
|
|||||||
|
|
||||||
const response = (await GetNezhaData()) as NezhaDataResponse;
|
const response = (await GetNezhaData()) as NezhaDataResponse;
|
||||||
if (response.error) {
|
if (response.error) {
|
||||||
console.log(response.error);
|
|
||||||
return NextResponse.json({ error: response.error }, { status: 400 });
|
return NextResponse.json({ error: response.error }, { status: 400 });
|
||||||
}
|
}
|
||||||
|
if (response.cause) {
|
||||||
|
return NextResponse.json(
|
||||||
|
{ cause: "server connect error" },
|
||||||
|
{ status: 400 },
|
||||||
|
);
|
||||||
|
}
|
||||||
return NextResponse.json(response, { status: 200 });
|
return NextResponse.json(response, { status: 200 });
|
||||||
});
|
});
|
||||||
|
@ -75,6 +75,7 @@ export async function GetNezhaData() {
|
|||||||
|
|
||||||
return data;
|
return data;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
console.error(error);
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -111,6 +112,7 @@ export async function GetServerMonitor({ server_id }: { server_id: number }) {
|
|||||||
}
|
}
|
||||||
return monitorData;
|
return monitorData;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
console.error(error);
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -163,6 +165,7 @@ export async function GetServerDetail({ server_id }: { server_id: number }) {
|
|||||||
|
|
||||||
return detailData;
|
return detailData;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
console.error(error);
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
27
lib/utils.ts
27
lib/utils.ts
@ -71,19 +71,20 @@ export const fetcher = (url: string) =>
|
|||||||
throw err;
|
throw err;
|
||||||
});
|
});
|
||||||
|
|
||||||
export const nezhaFetcher = (url: string) =>
|
export const nezhaFetcher = async (url: string) => {
|
||||||
fetch(url)
|
const res = await fetch(url);
|
||||||
.then((res) => {
|
|
||||||
if (!res.ok) {
|
if (!res.ok) {
|
||||||
throw new Error(res.statusText);
|
const error = new Error("An error occurred while fetching the data.");
|
||||||
}
|
// @ts-ignore
|
||||||
return res.json();
|
error.info = await res.json();
|
||||||
})
|
// @ts-ignore
|
||||||
.then((data) => data)
|
error.status = res.status;
|
||||||
.catch((err) => {
|
throw error;
|
||||||
console.error(err);
|
}
|
||||||
throw err;
|
|
||||||
});
|
return res.json();
|
||||||
|
};
|
||||||
|
|
||||||
export function formatRelativeTime(timestamp: number): string {
|
export function formatRelativeTime(timestamp: number): string {
|
||||||
const now = Date.now();
|
const now = Date.now();
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "nezha-dash",
|
"name": "nezha-dash",
|
||||||
"version": "0.1.0",
|
"version": "0.7.3",
|
||||||
"private": true,
|
"private": true,
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "next dev -p 3020",
|
"dev": "next dev -p 3020",
|
||||||
|
Loading…
Reference in New Issue
Block a user