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
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v3
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
with:
|
||||
driver-opts: network=host
|
||||
|
||||
- name: Login to Docker Hub
|
||||
uses: docker/login-action@v3
|
||||
@ -50,30 +49,19 @@ jobs:
|
||||
tags: ${{ steps.meta.outputs.tags }}
|
||||
labels: ${{ steps.meta.outputs.labels }}
|
||||
|
||||
changelog:
|
||||
name: Generate Changelog
|
||||
release:
|
||||
runs-on: ubuntu-latest
|
||||
needs: build-and-push
|
||||
outputs:
|
||||
release_body: ${{ steps.git-cliff.outputs.content }}
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
- name: Generate a changelog
|
||||
uses: orhun/git-cliff-action@v4
|
||||
id: git-cliff
|
||||
|
||||
- name: Set node
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
config: git-cliff-config/cliff.toml
|
||||
args: -vv --latest --strip 'footer'
|
||||
registry-url: https://registry.npmjs.org/
|
||||
node-version: lts/*
|
||||
|
||||
- run: npx changelogithub
|
||||
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 }}
|
||||
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
|
||||
|
@ -1,4 +1,4 @@
|
||||
FROM oven/bun:1 AS base
|
||||
FROM --platform=$BUILDPLATFORM oven/bun:1 AS base
|
||||
|
||||
# Stage 1: Install dependencies
|
||||
FROM base AS deps
|
||||
|
@ -18,13 +18,16 @@ export default function ServerOverviewClient() {
|
||||
);
|
||||
const disableCartoon = getEnv("NEXT_PUBLIC_DisableCartoon") === "true";
|
||||
|
||||
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>
|
||||
<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>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
|
@ -1,7 +1,9 @@
|
||||
import pack from "@/package.json";
|
||||
import { useTranslations } from "next-intl";
|
||||
|
||||
export default function Footer() {
|
||||
const t = useTranslations("Footer");
|
||||
const version = pack.version;
|
||||
return (
|
||||
<footer className="mx-auto w-full max-w-5xl">
|
||||
<section className="flex flex-col">
|
||||
@ -14,6 +16,13 @@ export default function Footer() {
|
||||
>
|
||||
{t("a_303-585_GitHub")}
|
||||
</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>
|
||||
<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")}
|
||||
|
@ -12,6 +12,7 @@ export const runtime = "edge";
|
||||
interface NezhaDataResponse {
|
||||
error?: string;
|
||||
data?: ServerApi;
|
||||
cause?: string;
|
||||
}
|
||||
|
||||
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;
|
||||
if (response.error) {
|
||||
console.log(response.error);
|
||||
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 });
|
||||
});
|
||||
|
@ -75,6 +75,7 @@ export async function GetNezhaData() {
|
||||
|
||||
return data;
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
return error;
|
||||
}
|
||||
}
|
||||
@ -111,6 +112,7 @@ export async function GetServerMonitor({ server_id }: { server_id: number }) {
|
||||
}
|
||||
return monitorData;
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
return error;
|
||||
}
|
||||
}
|
||||
@ -163,6 +165,7 @@ export async function GetServerDetail({ server_id }: { server_id: number }) {
|
||||
|
||||
return detailData;
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
return error;
|
||||
}
|
||||
}
|
||||
|
27
lib/utils.ts
27
lib/utils.ts
@ -71,19 +71,20 @@ export const fetcher = (url: string) =>
|
||||
throw err;
|
||||
});
|
||||
|
||||
export const nezhaFetcher = (url: string) =>
|
||||
fetch(url)
|
||||
.then((res) => {
|
||||
if (!res.ok) {
|
||||
throw new Error(res.statusText);
|
||||
}
|
||||
return res.json();
|
||||
})
|
||||
.then((data) => data)
|
||||
.catch((err) => {
|
||||
console.error(err);
|
||||
throw err;
|
||||
});
|
||||
export const nezhaFetcher = async (url: string) => {
|
||||
const res = await fetch(url);
|
||||
|
||||
if (!res.ok) {
|
||||
const error = new Error("An error occurred while fetching the data.");
|
||||
// @ts-ignore
|
||||
error.info = await res.json();
|
||||
// @ts-ignore
|
||||
error.status = res.status;
|
||||
throw error;
|
||||
}
|
||||
|
||||
return res.json();
|
||||
};
|
||||
|
||||
export function formatRelativeTime(timestamp: number): string {
|
||||
const now = Date.now();
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "nezha-dash",
|
||||
"version": "0.1.0",
|
||||
"version": "0.7.3",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"dev": "next dev -p 3020",
|
||||
|
Loading…
Reference in New Issue
Block a user