chore: nextjs15

This commit is contained in:
hamster1963 2024-10-30 12:08:06 +08:00
parent ccecf219af
commit 1110b23dbf
6 changed files with 45 additions and 30 deletions

View File

@ -5,9 +5,10 @@ import ServerDetailChartClient from "@/app/(main)/ClientComponents/ServerDetailC
import ServerDetailClient from "@/app/(main)/ClientComponents/ServerDetailClient"; import ServerDetailClient from "@/app/(main)/ClientComponents/ServerDetailClient";
import TabSwitch from "@/components/TabSwitch"; import TabSwitch from "@/components/TabSwitch";
import { Separator } from "@/components/ui/separator"; import { Separator } from "@/components/ui/separator";
import { useState } from "react"; import { use, useState } from "react";
export default function Page({ params }: { params: { id: string } }) { export default function Page(props: { params: Promise<{ id: string }> }) {
const params = use(props.params);
const tabs = ["Detail", "Network"]; const tabs = ["Detail", "Network"];
const [currentTab, setCurrentTab] = useState(tabs[0]); const [currentTab, setCurrentTab] = useState(tabs[0]);
return ( return (

View File

@ -2,12 +2,14 @@ import { auth } from "@/auth";
import getEnv from "@/lib/env-entry"; import getEnv from "@/lib/env-entry";
import { GetServerDetail } from "@/lib/serverFetch"; import { GetServerDetail } from "@/lib/serverFetch";
import { redirect } from "next/navigation"; import { redirect } from "next/navigation";
import { NextResponse } from "next/server"; import { NextRequest, NextResponse } from "next/server";
export const dynamic = "force-dynamic"; export const dynamic = "force-dynamic";
export const GET = auth(async function GET(req) { export async function GET(req: NextRequest) {
if (!req.auth && getEnv("SitePassword")) { const session = await auth();
if (!session && getEnv("SitePassword")) {
redirect("/"); redirect("/");
} }
@ -40,4 +42,4 @@ export const GET = auth(async function GET(req) {
const message = error.message || "Internal Server Error"; const message = error.message || "Internal Server Error";
return NextResponse.json({ error: message }, { status: statusCode }); return NextResponse.json({ error: message }, { status: statusCode });
} }
}); }

View File

@ -2,12 +2,14 @@ import { auth } from "@/auth";
import getEnv from "@/lib/env-entry"; import getEnv from "@/lib/env-entry";
import { GetServerMonitor } from "@/lib/serverFetch"; import { GetServerMonitor } from "@/lib/serverFetch";
import { redirect } from "next/navigation"; import { redirect } from "next/navigation";
import { NextResponse } from "next/server"; import { NextRequest, NextResponse } from "next/server";
export const dynamic = "force-dynamic"; export const dynamic = "force-dynamic";
export const GET = auth(async function GET(req) { export async function GET(req: NextRequest) {
if (!req.auth && getEnv("SitePassword")) { const session = await auth();
if (!session && getEnv("SitePassword")) {
redirect("/"); redirect("/");
} }
@ -41,4 +43,4 @@ export const GET = auth(async function GET(req) {
const message = error.message || "Internal Server Error"; const message = error.message || "Internal Server Error";
return NextResponse.json({ error: message }, { status: statusCode }); return NextResponse.json({ error: message }, { status: statusCode });
} }
}); }

View File

@ -2,12 +2,14 @@ import { auth } from "@/auth";
import getEnv from "@/lib/env-entry"; import getEnv from "@/lib/env-entry";
import { GetNezhaData } from "@/lib/serverFetch"; import { GetNezhaData } from "@/lib/serverFetch";
import { redirect } from "next/navigation"; import { redirect } from "next/navigation";
import { NextResponse } from "next/server"; import { NextRequest, NextResponse } from "next/server";
export const dynamic = "force-dynamic"; export const dynamic = "force-dynamic";
export const GET = auth(async function GET(req) { export async function GET(req: NextRequest) {
if (!req.auth && getEnv("SitePassword")) { const session = await auth();
if (!session && getEnv("SitePassword")) {
redirect("/"); redirect("/");
} }
@ -22,4 +24,4 @@ export const GET = auth(async function GET(req) {
const message = error.message || "Internal Server Error"; const message = error.message || "Internal Server Error";
return NextResponse.json({ error: message }, { status: statusCode }); return NextResponse.json({ error: message }, { status: statusCode });
} }
}); }

View File

@ -6,9 +6,12 @@ import { cookies } from "next/headers";
const COOKIE_NAME = "NEXT_LOCALE"; const COOKIE_NAME = "NEXT_LOCALE";
export async function getUserLocale() { export async function getUserLocale() {
return cookies().get(COOKIE_NAME)?.value || (getEnv("DefaultLocale") ?? "en"); return (
(await cookies()).get(COOKIE_NAME)?.value ||
(getEnv("DefaultLocale") ?? "en")
);
} }
export async function setUserLocale(locale: string) { export async function setUserLocale(locale: string) {
cookies().set(COOKIE_NAME, locale); (await cookies()).set(COOKIE_NAME, locale);
} }

View File

@ -22,46 +22,51 @@
"@radix-ui/react-tooltip": "^1.1.3", "@radix-ui/react-tooltip": "^1.1.3",
"@trivago/prettier-plugin-sort-imports": "^4.3.0", "@trivago/prettier-plugin-sort-imports": "^4.3.0",
"@types/luxon": "^3.4.2", "@types/luxon": "^3.4.2",
"@typescript-eslint/eslint-plugin": "^8.10.0", "@typescript-eslint/eslint-plugin": "^8.12.2",
"caniuse-lite": "^1.0.30001669", "caniuse-lite": "^1.0.30001674",
"class-variance-authority": "^0.7.0", "class-variance-authority": "^0.7.0",
"clsx": "^2.1.1", "clsx": "^2.1.1",
"country-flag-icons": "^1.5.13", "country-flag-icons": "^1.5.13",
"eslint-plugin-simple-import-sort": "^12.1.1", "eslint-plugin-simple-import-sort": "^12.1.1",
"flag-icons": "^7.2.3", "flag-icons": "^7.2.3",
"framer-motion": "^11.11.9", "framer-motion": "^12.0.0-alpha.1",
"lucide-react": "^0.451.0", "lucide-react": "^0.451.0",
"luxon": "^3.5.0", "luxon": "^3.5.0",
"next": "^14.2.15", "next": "15.0.2",
"next-auth": "^5.0.0-beta.25", "next-auth": "^5.0.0-beta.25",
"next-intl": "^3.21.1", "next-intl": "^3.23.5",
"next-runtime-env": "^3.2.2", "next-runtime-env": "^3.2.2",
"next-themes": "^0.3.0", "next-themes": "^0.3.0",
"react": "^18.3.1", "react": "19.0.0-rc-02c0e824-20241028",
"react-device-detect": "^2.2.3", "react-device-detect": "^2.2.3",
"react-dom": "^18.3.1", "react-dom": "19.0.0-rc-02c0e824-20241028",
"react-intersection-observer": "^9.13.1", "react-intersection-observer": "^9.13.1",
"react-wrap-balancer": "^1.1.1", "react-wrap-balancer": "^1.1.1",
"recharts": "2.12.7", "recharts": "2.13.1",
"sharp": "^0.33.5", "sharp": "^0.33.5",
"swr": "^2.2.6-beta.4", "swr": "^2.2.6-beta.4",
"tailwind-merge": "^2.5.4", "tailwind-merge": "^2.5.4",
"tailwindcss-animate": "^1.0.7" "tailwindcss-animate": "^1.0.7"
}, },
"devDependencies": { "devDependencies": {
"eslint-plugin-turbo": "^2.2.1", "eslint-plugin-turbo": "^2.2.3",
"eslint-plugin-unused-imports": "^4.1.4", "eslint-plugin-unused-imports": "^4.1.4",
"@next/bundle-analyzer": "^14.2.15", "@next/bundle-analyzer": "15.0.2",
"@types/node": "^22.7.7", "@types/node": "^22.8.4",
"@types/react": "^18.3.11", "@types/react": "npm:types-react@19.0.0-rc.1",
"@types/react-dom": "^18.3.1", "@types/react-dom": "npm:types-react-dom@19.0.0-rc.1",
"autoprefixer": "^10.4.20", "autoprefixer": "^10.4.20",
"eslint": "^9.13.0", "eslint": "^9.13.0",
"eslint-config-next": "^14.2.15", "eslint-config-next": "15.0.2",
"postcss": "^8.4.47", "postcss": "^8.4.47",
"prettier": "^3.3.3", "prettier": "^3.3.3",
"prettier-plugin-tailwindcss": "^0.6.8", "prettier-plugin-tailwindcss": "^0.6.8",
"tailwindcss": "^3.4.14", "tailwindcss": "^3.4.14",
"typescript": "^5.6.3" "typescript": "^5.6.3"
},
"overrides": {
"@types/react": "npm:types-react@19.0.0-rc.1",
"@types/react-dom": "npm:types-react-dom@19.0.0-rc.1",
"react-is": "^19.0.0-rc-69d4b800-20241021"
} }
} }