refactor: support i18n

This commit is contained in:
mlogclub
2026-05-25 12:06:15 +08:00
parent 309ac1fe9e
commit 988f55c80d
179 changed files with 10968 additions and 3763 deletions
@@ -5,6 +5,7 @@ import { Suspense, useEffect, useRef } from "react"
import { toast } from "sonner"
import { exchangeWxWorkTicket } from "@/lib/api/auth"
import { useI18n } from "@/i18n/provider"
export default function WxWorkLoginCallbackPage() {
return (
@@ -15,6 +16,7 @@ export default function WxWorkLoginCallbackPage() {
}
function WxWorkLoginCallbackContent() {
const t = useI18n()
const router = useRouter()
const searchParams = useSearchParams()
const ranRef = useRef(false)
@@ -30,21 +32,21 @@ function WxWorkLoginCallbackContent() {
const nextPath = next && next.startsWith("/") ? next : "/dashboard"
if (!ticket) {
toast.error("企业微信登录票据不存在")
toast.error(t("auth.wxworkMissingTicket"))
router.replace("/dashboard/login")
return
}
void exchangeWxWorkTicket(ticket)
.then(() => {
toast.success("登录成功,正在进入系统")
toast.success(t("auth.loginSuccess"))
router.replace(nextPath)
})
.catch((error) => {
toast.error(error instanceof Error ? error.message : "企业微信登录失败")
toast.error(error instanceof Error ? error.message : t("auth.wxworkFailed"))
router.replace("/dashboard/login")
})
}, [router, searchParams])
}, [router, searchParams, t])
return (
<WxWorkLoginCallbackFallback />
@@ -52,12 +54,14 @@ function WxWorkLoginCallbackContent() {
}
function WxWorkLoginCallbackFallback() {
const t = useI18n()
return (
<div className="flex min-h-svh items-center justify-center bg-[linear-gradient(145deg,#fff7ed_0%,#ffffff_32%,#ecfeff_100%)] px-6">
<div className="w-full max-w-md rounded-[28px] border border-white/70 bg-white/90 p-8 text-center shadow-[0_24px_80px_rgba(15,23,42,0.08)] backdrop-blur">
<h1 className="text-2xl font-semibold tracking-tight"></h1>
<h1 className="text-2xl font-semibold tracking-tight">{t("auth.wxworkSigningIn")}</h1>
<p className="mt-3 text-sm text-muted-foreground">
{t("auth.checkingTicket")}
</p>
</div>
</div>