From a9c6cd607e8bb75475f9ecdaa3c57a71e1fc3b51 Mon Sep 17 00:00:00 2001 From: hamster1963 <1410514192@qq.com> Date: Thu, 24 Oct 2024 21:13:08 +0800 Subject: [PATCH] refactor: i18n --- .../(main)/ClientComponents/NetworkChart.tsx | 9 +--- .../ClientComponents/NetworkChartLoading.tsx | 6 --- .../ServerDetailChartClient.tsx | 4 +- .../ClientComponents/ServerDetailClient.tsx | 8 ++-- .../ClientComponents/ServerDetailLoading.tsx | 3 +- .../ClientComponents/ServerListClient.tsx | 2 +- .../ClientComponents/ServerOverviewClient.tsx | 2 +- app/{[locale] => }/(main)/[id]/page.tsx | 6 +-- app/{[locale] => }/(main)/footer.tsx | 0 app/{[locale] => }/(main)/header.tsx | 3 +- app/{[locale] => }/(main)/layout.tsx | 4 +- app/{[locale] => }/(main)/page.tsx | 0 app/{[locale] => }/android-chrome-192x192.png | Bin app/{[locale] => }/android-chrome-512x512.png | Bin app/api/detail/route.ts | 1 - app/{[locale] => }/apple-touch-icon.png | Bin app/{[locale] => }/favicon-16x16.png | Bin app/{[locale] => }/favicon-32x32.png | Bin app/{[locale] => }/layout.tsx | 20 +++----- app/{[locale] => }/not-found.tsx | 0 app/{[locale] => }/types/nezha-api.ts | 0 app/{[locale] => }/types/utils.ts | 0 auto-i18n-config.json | 10 ---- components/LanguageSwitcher.tsx | 44 +++--------------- components/ServerCard.tsx | 9 ++-- components/ServerCardPopover.tsx | 2 +- components/ServerList.tsx | 2 +- components/ServerOverview.tsx | 2 +- i18n.ts | 14 ------ i18n/locale.ts | 14 ++++++ i18n/request.ts | 11 +++++ lib/serverFetch.tsx | 4 +- lib/utils.ts | 2 +- middleware.ts | 23 --------- next.config.mjs | 2 +- 35 files changed, 65 insertions(+), 142 deletions(-) rename app/{[locale] => }/(main)/ClientComponents/NetworkChart.tsx (96%) rename app/{[locale] => }/(main)/ClientComponents/NetworkChartLoading.tsx (82%) rename app/{[locale] => }/(main)/ClientComponents/ServerDetailChartClient.tsx (99%) rename app/{[locale] => }/(main)/ClientComponents/ServerDetailClient.tsx (96%) rename app/{[locale] => }/(main)/ClientComponents/ServerDetailLoading.tsx (95%) rename app/{[locale] => }/(main)/ClientComponents/ServerListClient.tsx (98%) rename app/{[locale] => }/(main)/ClientComponents/ServerOverviewClient.tsx (99%) rename app/{[locale] => }/(main)/[id]/page.tsx (82%) rename app/{[locale] => }/(main)/footer.tsx (100%) rename app/{[locale] => }/(main)/header.tsx (98%) rename app/{[locale] => }/(main)/layout.tsx (86%) rename app/{[locale] => }/(main)/page.tsx (100%) rename app/{[locale] => }/android-chrome-192x192.png (100%) rename app/{[locale] => }/android-chrome-512x512.png (100%) rename app/{[locale] => }/apple-touch-icon.png (100%) rename app/{[locale] => }/favicon-16x16.png (100%) rename app/{[locale] => }/favicon-32x32.png (100%) rename app/{[locale] => }/layout.tsx (77%) rename app/{[locale] => }/not-found.tsx (100%) rename app/{[locale] => }/types/nezha-api.ts (100%) rename app/{[locale] => }/types/utils.ts (100%) delete mode 100644 auto-i18n-config.json delete mode 100644 i18n.ts create mode 100644 i18n/locale.ts create mode 100644 i18n/request.ts delete mode 100644 middleware.ts diff --git a/app/[locale]/(main)/ClientComponents/NetworkChart.tsx b/app/(main)/ClientComponents/NetworkChart.tsx similarity index 96% rename from app/[locale]/(main)/ClientComponents/NetworkChart.tsx rename to app/(main)/ClientComponents/NetworkChart.tsx index bbbda4f..45243e1 100644 --- a/app/[locale]/(main)/ClientComponents/NetworkChart.tsx +++ b/app/(main)/ClientComponents/NetworkChart.tsx @@ -1,10 +1,7 @@ "use client"; -import NetworkChartLoading from "@/app/[locale]/(main)/ClientComponents/NetworkChartLoading"; -import { - NezhaAPIMonitor, - ServerMonitorChart, -} from "@/app/[locale]/types/nezha-api"; +import NetworkChartLoading from "@/app/(main)/ClientComponents/NetworkChartLoading"; +import { NezhaAPIMonitor, ServerMonitorChart } from "@/app/types/nezha-api"; import { BackIcon } from "@/components/Icon"; import { Card, @@ -108,8 +105,6 @@ export const NetworkChart = React.memo(function NetworkChart({ formattedData: ResultItem[]; }) { const t = useTranslations("NetworkChart"); - const router = useRouter(); - const locale = useLocale(); const defaultChart = "All"; diff --git a/app/[locale]/(main)/ClientComponents/NetworkChartLoading.tsx b/app/(main)/ClientComponents/NetworkChartLoading.tsx similarity index 82% rename from app/[locale]/(main)/ClientComponents/NetworkChartLoading.tsx rename to app/(main)/ClientComponents/NetworkChartLoading.tsx index 6c3d383..c9c58c7 100644 --- a/app/[locale]/(main)/ClientComponents/NetworkChartLoading.tsx +++ b/app/(main)/ClientComponents/NetworkChartLoading.tsx @@ -1,13 +1,7 @@ -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 ( diff --git a/app/[locale]/(main)/ClientComponents/ServerDetailChartClient.tsx b/app/(main)/ClientComponents/ServerDetailChartClient.tsx similarity index 99% rename from app/[locale]/(main)/ClientComponents/ServerDetailChartClient.tsx rename to app/(main)/ClientComponents/ServerDetailChartClient.tsx index ba04a7e..c2fb955 100644 --- a/app/[locale]/(main)/ClientComponents/ServerDetailChartClient.tsx +++ b/app/(main)/ClientComponents/ServerDetailChartClient.tsx @@ -1,7 +1,7 @@ "use client"; -import { ServerDetailChartLoading } from "@/app/[locale]/(main)/ClientComponents/ServerDetailLoading"; -import { NezhaAPISafe, ServerApi } from "@/app/[locale]/types/nezha-api"; +import { ServerDetailChartLoading } from "@/app/(main)/ClientComponents/ServerDetailLoading"; +import { NezhaAPISafe, ServerApi } from "@/app/types/nezha-api"; import AnimatedCircularProgressBar from "@/components/ui/animated-circular-progress-bar"; import { Card, CardContent } from "@/components/ui/card"; import { ChartConfig, ChartContainer } from "@/components/ui/chart"; diff --git a/app/[locale]/(main)/ClientComponents/ServerDetailClient.tsx b/app/(main)/ClientComponents/ServerDetailClient.tsx similarity index 96% rename from app/[locale]/(main)/ClientComponents/ServerDetailClient.tsx rename to app/(main)/ClientComponents/ServerDetailClient.tsx index a3236d7..ad695bb 100644 --- a/app/[locale]/(main)/ClientComponents/ServerDetailClient.tsx +++ b/app/(main)/ClientComponents/ServerDetailClient.tsx @@ -1,7 +1,7 @@ "use client"; -import { ServerDetailLoading } from "@/app/[locale]/(main)/ClientComponents/ServerDetailLoading"; -import { NezhaAPISafe, ServerApi } from "@/app/[locale]/types/nezha-api"; +import { ServerDetailLoading } from "@/app/(main)/ClientComponents/ServerDetailLoading"; +import { NezhaAPISafe, ServerApi } from "@/app/types/nezha-api"; import { BackIcon } from "@/components/Icon"; import ServerFlag from "@/components/ServerFlag"; import { Badge } from "@/components/ui/badge"; @@ -21,7 +21,6 @@ export default function ServerDetailClient({ }) { const t = useTranslations("ServerDetailClient"); const router = useRouter(); - const locale = useLocale(); const [hasHistory, setHasHistory] = useState(false); @@ -43,7 +42,7 @@ export default function ServerDetailClient({ if (hasHistory) { router.back(); } else { - router.push(`/${locale}/`); + router.push(`/`); } }; @@ -52,6 +51,7 @@ export default function ServerDetailClient({ nezhaFetcher, ); const fallbackData = allFallbackData?.result?.find( + // @ts-ignore (item) => item.id === server_id, ); diff --git a/app/[locale]/(main)/ClientComponents/ServerDetailLoading.tsx b/app/(main)/ClientComponents/ServerDetailLoading.tsx similarity index 95% rename from app/[locale]/(main)/ClientComponents/ServerDetailLoading.tsx rename to app/(main)/ClientComponents/ServerDetailLoading.tsx index 1036e3e..1f26be8 100644 --- a/app/[locale]/(main)/ClientComponents/ServerDetailLoading.tsx +++ b/app/(main)/ClientComponents/ServerDetailLoading.tsx @@ -20,13 +20,12 @@ export function ServerDetailChartLoading() { export function ServerDetailLoading() { const router = useRouter(); - const locale = useLocale(); return ( <>
{ - router.push(`/${locale}/`); + router.push(`/`); }} className="flex flex-none cursor-pointer font-semibold leading-none items-center break-all tracking-tight gap-0.5 text-xl" > diff --git a/app/[locale]/(main)/ClientComponents/ServerListClient.tsx b/app/(main)/ClientComponents/ServerListClient.tsx similarity index 98% rename from app/[locale]/(main)/ClientComponents/ServerListClient.tsx rename to app/(main)/ClientComponents/ServerListClient.tsx index 707047f..6f71a69 100644 --- a/app/[locale]/(main)/ClientComponents/ServerListClient.tsx +++ b/app/(main)/ClientComponents/ServerListClient.tsx @@ -1,6 +1,6 @@ "use client"; -import { ServerApi } from "@/app/[locale]/types/nezha-api"; +import { ServerApi } from "@/app/types/nezha-api"; import ServerCard from "@/components/ServerCard"; import Switch from "@/components/Switch"; import getEnv from "@/lib/env-entry"; diff --git a/app/[locale]/(main)/ClientComponents/ServerOverviewClient.tsx b/app/(main)/ClientComponents/ServerOverviewClient.tsx similarity index 99% rename from app/[locale]/(main)/ClientComponents/ServerOverviewClient.tsx rename to app/(main)/ClientComponents/ServerOverviewClient.tsx index 764ca38..44407a3 100644 --- a/app/[locale]/(main)/ClientComponents/ServerOverviewClient.tsx +++ b/app/(main)/ClientComponents/ServerOverviewClient.tsx @@ -1,6 +1,6 @@ "use client"; -import { ServerApi } from "@/app/[locale]/types/nezha-api"; +import { ServerApi } from "@/app/types/nezha-api"; import { Loader } from "@/components/loading/Loader"; import { Card, CardContent } from "@/components/ui/card"; import getEnv from "@/lib/env-entry"; diff --git a/app/[locale]/(main)/[id]/page.tsx b/app/(main)/[id]/page.tsx similarity index 82% rename from app/[locale]/(main)/[id]/page.tsx rename to app/(main)/[id]/page.tsx index 9309b7b..3646322 100644 --- a/app/[locale]/(main)/[id]/page.tsx +++ b/app/(main)/[id]/page.tsx @@ -1,8 +1,8 @@ "use client"; -import { NetworkChartClient } from "@/app/[locale]/(main)/ClientComponents/NetworkChart"; -import ServerDetailChartClient from "@/app/[locale]/(main)/ClientComponents/ServerDetailChartClient"; -import ServerDetailClient from "@/app/[locale]/(main)/ClientComponents/ServerDetailClient"; +import { NetworkChartClient } from "@/app/(main)/ClientComponents/NetworkChart"; +import ServerDetailChartClient from "@/app/(main)/ClientComponents/ServerDetailChartClient"; +import ServerDetailClient from "@/app/(main)/ClientComponents/ServerDetailClient"; import TabSwitch from "@/components/TabSwitch"; import { Separator } from "@/components/ui/separator"; import { useTranslations } from "next-intl"; diff --git a/app/[locale]/(main)/footer.tsx b/app/(main)/footer.tsx similarity index 100% rename from app/[locale]/(main)/footer.tsx rename to app/(main)/footer.tsx diff --git a/app/[locale]/(main)/header.tsx b/app/(main)/header.tsx similarity index 98% rename from app/[locale]/(main)/header.tsx rename to app/(main)/header.tsx index f3a6e9e..2a1c1a7 100644 --- a/app/[locale]/(main)/header.tsx +++ b/app/(main)/header.tsx @@ -19,7 +19,6 @@ function Header() { const customDescription = getEnv("NEXT_PUBLIC_CustomDescription"); const router = useRouter(); - const locale = useLocale(); return (
@@ -27,7 +26,7 @@ function Header() {
{ sessionStorage.removeItem("selectedTag"); - router.push(`/${locale}/`); + router.push(`/`); }} className="flex cursor-pointer items-center text-base font-medium" > diff --git a/app/[locale]/(main)/layout.tsx b/app/(main)/layout.tsx similarity index 86% rename from app/[locale]/(main)/layout.tsx rename to app/(main)/layout.tsx index c237dc7..c8ba248 100644 --- a/app/[locale]/(main)/layout.tsx +++ b/app/(main)/layout.tsx @@ -1,5 +1,5 @@ -import Footer from "@/app/[locale]/(main)/footer"; -import Header from "@/app/[locale]/(main)/header"; +import Footer from "@/app/(main)/footer"; +import Header from "@/app/(main)/header"; import { auth } from "@/auth"; import { SignIn } from "@/components/SignIn"; import getEnv from "@/lib/env-entry"; diff --git a/app/[locale]/(main)/page.tsx b/app/(main)/page.tsx similarity index 100% rename from app/[locale]/(main)/page.tsx rename to app/(main)/page.tsx diff --git a/app/[locale]/android-chrome-192x192.png b/app/android-chrome-192x192.png similarity index 100% rename from app/[locale]/android-chrome-192x192.png rename to app/android-chrome-192x192.png diff --git a/app/[locale]/android-chrome-512x512.png b/app/android-chrome-512x512.png similarity index 100% rename from app/[locale]/android-chrome-512x512.png rename to app/android-chrome-512x512.png diff --git a/app/api/detail/route.ts b/app/api/detail/route.ts index eddf954..a500bce 100644 --- a/app/api/detail/route.ts +++ b/app/api/detail/route.ts @@ -1,4 +1,3 @@ -import { NezhaAPISafe } from "@/app/[locale]/types/nezha-api"; import { auth } from "@/auth"; import getEnv from "@/lib/env-entry"; import { GetServerDetail } from "@/lib/serverFetch"; diff --git a/app/[locale]/apple-touch-icon.png b/app/apple-touch-icon.png similarity index 100% rename from app/[locale]/apple-touch-icon.png rename to app/apple-touch-icon.png diff --git a/app/[locale]/favicon-16x16.png b/app/favicon-16x16.png similarity index 100% rename from app/[locale]/favicon-16x16.png rename to app/favicon-16x16.png diff --git a/app/[locale]/favicon-32x32.png b/app/favicon-32x32.png similarity index 100% rename from app/[locale]/favicon-32x32.png rename to app/favicon-32x32.png diff --git a/app/[locale]/layout.tsx b/app/layout.tsx similarity index 77% rename from app/[locale]/layout.tsx rename to app/layout.tsx index 089d03a..a4deb23 100644 --- a/app/[locale]/layout.tsx +++ b/app/layout.tsx @@ -1,12 +1,11 @@ // @auto-i18n-check. Please do not delete the line. -import { locales } from "@/i18n-metadata"; import getEnv from "@/lib/env-entry"; import { cn } from "@/lib/utils"; import "@/styles/globals.css"; import type { Metadata } from "next"; import { Viewport } from "next"; -import { NextIntlClientProvider, useMessages } from "next-intl"; -import { unstable_setRequestLocale } from "next-intl/server"; +import { NextIntlClientProvider } from "next-intl"; +import { getLocale, getMessages } from "next-intl/server"; import { PublicEnvScript } from "next-runtime-env"; import { ThemeProvider } from "next-themes"; import { Inter as FontSans } from "next/font/google"; @@ -38,20 +37,13 @@ export const viewport: Viewport = { userScalable: false, }; -export async function generateStaticParams() { - return locales.map((locale) => ({ locale })); -} - -export default function LocaleLayout({ +export default async function LocaleLayout({ children, - params: { locale }, }: { children: React.ReactNode; - params: { locale: string }; }) { - unstable_setRequestLocale(locale); - - const messages = useMessages(); + const locale = await getLocale(); + const messages = await getMessages(); return ( @@ -74,7 +66,7 @@ export default function LocaleLayout({ enableSystem disableTransitionOnChange > - + {children} diff --git a/app/[locale]/not-found.tsx b/app/not-found.tsx similarity index 100% rename from app/[locale]/not-found.tsx rename to app/not-found.tsx diff --git a/app/[locale]/types/nezha-api.ts b/app/types/nezha-api.ts similarity index 100% rename from app/[locale]/types/nezha-api.ts rename to app/types/nezha-api.ts diff --git a/app/[locale]/types/utils.ts b/app/types/utils.ts similarity index 100% rename from app/[locale]/types/utils.ts rename to app/types/utils.ts diff --git a/auto-i18n-config.json b/auto-i18n-config.json deleted file mode 100644 index bbf5176..0000000 --- a/auto-i18n-config.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "defaultLang": "en", - "translatorServerName": "azure", - "needLangs": ["en", "zh", "zh-t", "ja"], - "brandWords": [], - "unMoveToLocaleDirFiles": [], - "enableStaticRendering": false, - "enableSubPageRedirectToLocale": false, - "disableDefaultLangRedirect": true -} diff --git a/components/LanguageSwitcher.tsx b/components/LanguageSwitcher.tsx index 5f944a2..008b8ea 100644 --- a/components/LanguageSwitcher.tsx +++ b/components/LanguageSwitcher.tsx @@ -7,45 +7,18 @@ import { DropdownMenuItem, DropdownMenuTrigger, } from "@/components/ui/dropdown-menu"; +import { localeItems } from "@/i18n-metadata"; +import { setUserLocale } from "@/i18n/locale"; import { useLocale } from "next-intl"; -import { usePathname, useRouter } from "next/navigation"; import * as React from "react"; -import { localeItems } from "../i18n-metadata"; - export function LanguageSwitcher() { const locale = useLocale(); - const router = useRouter(); - const pathname = usePathname(); - const handleChange = (code: string) => { - const newLocale = code; - - const rootPath = "/"; - const currentLocalePath = `/${locale}`; - const newLocalePath = `/${newLocale}`; - - // Function to construct new path with locale prefix - const constructLocalePath = (path: string, newLocale: string) => { - if (path.startsWith(currentLocalePath)) { - return path.replace(currentLocalePath, `/${newLocale}`); - } else { - return `/${newLocale}${path}`; - } - }; - - if (pathname === rootPath || !pathname) { - router.push(newLocalePath); - } else if ( - pathname === currentLocalePath || - pathname === `${currentLocalePath}/` - ) { - router.push(newLocalePath); - } else { - const newPath = constructLocalePath(pathname, newLocale); - router.push(newPath); - } - }; + function onChange(value: string) { + const locale = value; + setUserLocale(locale); + } return ( @@ -57,10 +30,7 @@ export function LanguageSwitcher() { {localeItems.map((item) => ( - handleChange(item.code)} - > + onChange(item.code)}> {item.name} ))} diff --git a/components/ServerCard.tsx b/components/ServerCard.tsx index 19e850d..8772e22 100644 --- a/components/ServerCard.tsx +++ b/components/ServerCard.tsx @@ -1,5 +1,4 @@ -import { NezhaAPISafe } from "@/app/[locale]/types/nezha-api"; -import ServerCardPopover from "@/components/ServerCardPopover"; +import { NezhaAPISafe } from "@/app/types/nezha-api"; import ServerFlag from "@/components/ServerFlag"; import ServerUsageBar from "@/components/ServerUsageBar"; import { Badge } from "@/components/ui/badge"; @@ -29,10 +28,8 @@ export default function ServerCard({ const showNetTransfer = getEnv("NEXT_PUBLIC_ShowNetTransfer") === "true"; - const locale = useLocale(); - return online ? ( - + { - router.push(`/${locale}/network/${id}`); + router.push(`/${id}`); }} className={"flex items-center justify-between gap-1"} > diff --git a/components/ServerCardPopover.tsx b/components/ServerCardPopover.tsx index 9638802..ee62f0c 100644 --- a/components/ServerCardPopover.tsx +++ b/components/ServerCardPopover.tsx @@ -1,4 +1,4 @@ -import { NezhaAPISafe } from "@/app/[locale]/types/nezha-api"; +import { NezhaAPISafe } from "@/app/types/nezha-api"; import { cn, formatBytes } from "@/lib/utils"; import { useTranslations } from "next-intl"; diff --git a/components/ServerList.tsx b/components/ServerList.tsx index 2c6abb2..c57850a 100644 --- a/components/ServerList.tsx +++ b/components/ServerList.tsx @@ -1,4 +1,4 @@ -import ServerListClient from "@/app/[locale]/(main)/ClientComponents/ServerListClient"; +import ServerListClient from "@/app/(main)/ClientComponents/ServerListClient"; import React from "react"; export default async function ServerList() { diff --git a/components/ServerOverview.tsx b/components/ServerOverview.tsx index 900fd90..2e61c79 100644 --- a/components/ServerOverview.tsx +++ b/components/ServerOverview.tsx @@ -1,4 +1,4 @@ -import ServerOverviewClient from "@/app/[locale]/(main)/ClientComponents/ServerOverviewClient"; +import ServerOverviewClient from "@/app/(main)/ClientComponents/ServerOverviewClient"; export default async function ServerOverview() { return ; diff --git a/i18n.ts b/i18n.ts deleted file mode 100644 index f000d4e..0000000 --- a/i18n.ts +++ /dev/null @@ -1,14 +0,0 @@ -// @auto-i18n-check. Please do not delete the line. -import { getRequestConfig } from "next-intl/server"; -import { notFound } from "next/navigation"; - -import { locales } from "./i18n-metadata"; - -export default getRequestConfig(async ({ locale }) => { - // Validate that the incoming `locale` parameter is valid - if (!locales.includes(locale as any)) notFound(); - - return { - messages: (await import(`./messages/${locale}.json`)).default, - }; -}); diff --git a/i18n/locale.ts b/i18n/locale.ts new file mode 100644 index 0000000..04fbcce --- /dev/null +++ b/i18n/locale.ts @@ -0,0 +1,14 @@ +"use server"; + +import getEnv from "@/lib/env-entry"; +import { cookies } from "next/headers"; + +const COOKIE_NAME = "NEXT_LOCALE"; + +export async function getUserLocale() { + return cookies().get(COOKIE_NAME)?.value || (getEnv("DefaultLocale") ?? "en"); +} + +export async function setUserLocale(locale: string) { + cookies().set(COOKIE_NAME, locale); +} diff --git a/i18n/request.ts b/i18n/request.ts new file mode 100644 index 0000000..36d4458 --- /dev/null +++ b/i18n/request.ts @@ -0,0 +1,11 @@ +import { getUserLocale } from "@/i18n/locale"; +import { getRequestConfig } from "next-intl/server"; + +export default getRequestConfig(async () => { + const locale = await getUserLocale(); + + return { + locale, + messages: (await import(`../messages/${locale}.json`)).default, + }; +}); diff --git a/lib/serverFetch.tsx b/lib/serverFetch.tsx index 4cbf3bb..5663c63 100644 --- a/lib/serverFetch.tsx +++ b/lib/serverFetch.tsx @@ -1,7 +1,7 @@ "use server"; -import { NezhaAPI, ServerApi } from "@/app/[locale]/types/nezha-api"; -import { MakeOptional } from "@/app/[locale]/types/utils"; +import { NezhaAPI, ServerApi } from "@/app/types/nezha-api"; +import { MakeOptional } from "@/app/types/utils"; import getEnv from "@/lib/env-entry"; import { unstable_noStore as noStore } from "next/cache"; diff --git a/lib/utils.ts b/lib/utils.ts index cd40047..024faf3 100644 --- a/lib/utils.ts +++ b/lib/utils.ts @@ -1,4 +1,4 @@ -import { NezhaAPISafe } from "@/app/[locale]/types/nezha-api"; +import { NezhaAPISafe } from "@/app/types/nezha-api"; import { type ClassValue, clsx } from "clsx"; import { twMerge } from "tailwind-merge"; diff --git a/middleware.ts b/middleware.ts deleted file mode 100644 index fa0386d..0000000 --- a/middleware.ts +++ /dev/null @@ -1,23 +0,0 @@ -// @auto-i18n-check. Please do not delete the line. -import createMiddleware from "next-intl/middleware"; - -import { defaultLocale, locales } from "./i18n-metadata"; - -// export { auth as middleware } from "@/auth" - -export default createMiddleware({ - // A list of all locales that are supported - locales: locales, - - // Used when no locale matches - defaultLocale: defaultLocale, - - // 'always': This is the default, The home page will also be redirected to the default language, such as www.abc.com to www.abc.com/en - // 'as-needed': The default page is not redirected. For example, if you open www.abc.com, it is still www.abc.com - localePrefix: "always", -}); - -export const config = { - // Match only internationalized pathnames - matcher: ["/", "/(en|zh|zh-t|ja)/:path*"], -}; diff --git a/next.config.mjs b/next.config.mjs index 86bfbf5..1260f48 100644 --- a/next.config.mjs +++ b/next.config.mjs @@ -21,7 +21,7 @@ const withPWA = withPWAInit({ /** @type {import('next').NextConfig} */ const nextConfig = { - output: "standalone", + // output: "standalone", reactStrictMode: true, logging: { fetches: {