@@ -4,6 +4,7 @@ import { useNavigate, useSearchParams } from "react-router-dom";
44import { useTheme } from "next-themes" ;
55import { useIsSSR } from "@react-aria/ssr" ;
66import { motion } from "framer-motion" ;
7+ import { useTranslation } from "react-i18next" ;
78import { FontAwesomeIcon } from "@fortawesome/react-fontawesome" ;
89import {
910 faShieldAlt ,
@@ -14,6 +15,7 @@ import {
1415
1516export default function OAuthErrorPage ( ) {
1617 const navigate = useNavigate ( ) ;
18+ const { t } = useTranslation ( "oauth" ) ;
1719 const [ searchParams ] = useSearchParams ( ) ;
1820 const [ errorMessage , setErrorMessage ] = useState ( "" ) ;
1921 const [ provider , setProvider ] = useState ( "" ) ;
@@ -25,12 +27,12 @@ export default function OAuthErrorPage() {
2527
2628 useEffect ( ( ) => {
2729 // 从 URL 参数获取错误信息
28- const error = searchParams . get ( "error" ) || "OAuth2 登录失败" ;
30+ const error = searchParams . get ( "error" ) || t ( "error.defaultError" ) ;
2931 const providerParam = searchParams . get ( "provider" ) || "" ;
3032
3133 setErrorMessage ( decodeURIComponent ( error ) ) ;
3234 setProvider ( providerParam ) ;
33- } , [ searchParams ] ) ;
35+ } , [ searchParams , t ] ) ;
3436
3537 const handleRetryLogin = ( ) => {
3638 navigate ( "/login" ) ;
@@ -66,7 +68,7 @@ export default function OAuthErrorPage() {
6668 < h1 className = "text-2xl font-bold text-foreground" >
6769 NodePassDash
6870 </ h1 >
69- < p className = "text-small text-default-500" > OAuth2 登录遇到问题 </ p >
71+ < p className = "text-small text-default-500" > { t ( "error.title" ) } </ p >
7072 </ CardHeader >
7173
7274 < CardBody className = "px-8 pb-8" >
@@ -89,32 +91,32 @@ export default function OAuthErrorPage() {
8991 { /* 错误信息 */ }
9092 < div className = "text-center space-y-3" >
9193 < h2 className = "text-xl font-semibold text-danger" >
92- 登录失败
94+ { t ( "error.loginFailed" ) }
9395 </ h2 >
9496
9597 < div className = "p-4 bg-danger-50 border border-danger-200 rounded-lg" >
9698 < p className = "text-danger text-sm font-medium mb-2" >
97- 错误详情
99+ { t ( "error.errorDetails" ) }
98100 </ p >
99101 < p className = "text-danger-600 text-xs break-words" >
100102 { errorMessage }
101103 </ p >
102104 { provider && (
103105 < p className = "text-danger-500 text-xs mt-2" >
104- 提供者 :{ " " }
106+ { t ( "error.provider" ) } :{ " " }
105107 { provider === "github"
106- ? "GitHub"
108+ ? t ( "error.providers.github" )
107109 : provider === "cloudflare"
108- ? "Cloudflare"
110+ ? t ( "error.providers.cloudflare" )
109111 : provider }
110112 </ p >
111113 ) }
112114 </ div >
113115
114116 < div className = "text-small text-default-500 space-y-1" >
115- < p > • 可能的原因:系统已绑定其他 OAuth2 账户 </ p >
116- < p > • 每个系统只能绑定一个 OAuth2 用户 </ p >
117- < p > • 请联系管理员或使用已绑定的账户登录 </ p >
117+ < p > { t ( "error.reasons.reason1" ) } </ p >
118+ < p > { t ( "error.reasons.reason2" ) } </ p >
119+ < p > { t ( "error.reasons.reason3" ) } </ p >
118120 </ div >
119121 </ div >
120122
@@ -127,7 +129,7 @@ export default function OAuthErrorPage() {
127129 startContent = { < FontAwesomeIcon icon = { faRedo } /> }
128130 onPress = { handleRetryLogin }
129131 >
130- 重新登录
132+ { t ( "error.actions.retryLogin" ) }
131133 </ Button >
132134
133135 < Button
@@ -138,15 +140,15 @@ export default function OAuthErrorPage() {
138140 variant = "bordered"
139141 onPress = { handleGoHome }
140142 >
141- 返回首页
143+ { t ( "error.actions.goHome" ) }
142144 </ Button >
143145 </ div >
144146
145147 { /* 帮助信息 */ }
146148 < div className = "text-center" >
147149 < div className = "inline-flex items-center gap-2 text-xs text-default-400" >
148150 < FontAwesomeIcon icon = { faInfoCircle } />
149- < span > 如需帮助,请联系系统管理员 </ span >
151+ < span > { t ( "error.help" ) } </ span >
150152 </ div >
151153 </ div >
152154 </ motion . div >
0 commit comments