This commit is contained in:
parent
1df7f447cd
commit
b05084f939
|
|
@ -23,6 +23,8 @@ import {
|
||||||
} from "../../../components/setup/step-container"
|
} from "../../../components/setup/step-container"
|
||||||
import { useTranslation } from 'react-i18next'
|
import { useTranslation } from 'react-i18next'
|
||||||
|
|
||||||
|
import { usePathname } from "next/navigation"
|
||||||
|
|
||||||
export default function SetupPage() {
|
export default function SetupPage() {
|
||||||
const {
|
const {
|
||||||
profile,
|
profile,
|
||||||
|
|
@ -35,6 +37,7 @@ export default function SetupPage() {
|
||||||
} = useContext(ChatbotUIContext)
|
} = useContext(ChatbotUIContext)
|
||||||
|
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
|
const pathname = usePathname() // 获取当前路径
|
||||||
|
|
||||||
const { t } = useTranslation()
|
const { t } = useTranslation()
|
||||||
|
|
||||||
|
|
@ -69,7 +72,12 @@ export default function SetupPage() {
|
||||||
const session = (await supabase.auth.getSession()).data.session
|
const session = (await supabase.auth.getSession()).data.session
|
||||||
|
|
||||||
if (!session) {
|
if (!session) {
|
||||||
return router.push("/login")
|
|
||||||
|
// 提取当前路径中的 locale 部分
|
||||||
|
const locale = pathname.split("/")[1] || "en" // 获取路径中的 locale 部分,如果没有则默认为 "en"
|
||||||
|
|
||||||
|
// 强制跳转到带有 locale 的 login 页面
|
||||||
|
return router.push("/${locale}/login")
|
||||||
} else {
|
} else {
|
||||||
const user = session.user
|
const user = session.user
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
import { useTranslation } from "react-i18next" // 导入 useTranslation
|
||||||
|
|
||||||
import { Input } from "@/components/ui/input"
|
import { Input } from "@/components/ui/input"
|
||||||
import { Label } from "@/components/ui/label"
|
import { Label } from "@/components/ui/label"
|
||||||
import {
|
import {
|
||||||
|
|
@ -31,6 +33,8 @@ export const ProfileStep: FC<ProfileStepProps> = ({
|
||||||
onUsernameChange,
|
onUsernameChange,
|
||||||
onDisplayNameChange
|
onDisplayNameChange
|
||||||
}) => {
|
}) => {
|
||||||
|
const { t } = useTranslation() // 使用 t 函数来获取翻译内容
|
||||||
|
|
||||||
const [loading, setLoading] = useState(false)
|
const [loading, setLoading] = useState(false)
|
||||||
|
|
||||||
const debounce = (func: (...args: any[]) => void, wait: number) => {
|
const debounce = (func: (...args: any[]) => void, wait: number) => {
|
||||||
|
|
@ -65,7 +69,8 @@ export const ProfileStep: FC<ProfileStepProps> = ({
|
||||||
if (!usernameRegex.test(username)) {
|
if (!usernameRegex.test(username)) {
|
||||||
onUsernameAvailableChange(false)
|
onUsernameAvailableChange(false)
|
||||||
toast.error(
|
toast.error(
|
||||||
"Username must be letters, numbers, or underscores only - no other characters or spacing allowed."
|
t("login.usernameError")
|
||||||
|
//"Username must be letters, numbers, or underscores only - no other characters or spacing allowed."
|
||||||
)
|
)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
@ -91,13 +96,13 @@ export const ProfileStep: FC<ProfileStepProps> = ({
|
||||||
<>
|
<>
|
||||||
<div className="space-y-1">
|
<div className="space-y-1">
|
||||||
<div className="flex items-center space-x-2">
|
<div className="flex items-center space-x-2">
|
||||||
<Label>Username</Label>
|
<Label>{t("login.username")}</Label>
|
||||||
|
|
||||||
<div className="text-xs">
|
<div className="text-xs">
|
||||||
{usernameAvailable ? (
|
{usernameAvailable ? (
|
||||||
<div className="text-green-500">AVAILABLE</div>
|
<div className="text-green-500">{t("login.available")}</div>
|
||||||
) : (
|
) : (
|
||||||
<div className="text-red-500">UNAVAILABLE</div>
|
<div className="text-red-500">{t("login.unavailable")}</div>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -105,7 +110,7 @@ export const ProfileStep: FC<ProfileStepProps> = ({
|
||||||
<div className="relative">
|
<div className="relative">
|
||||||
<Input
|
<Input
|
||||||
className="pr-10"
|
className="pr-10"
|
||||||
placeholder="username"
|
placeholder={t("login.usernamePlaceholder")}
|
||||||
value={username}
|
value={username}
|
||||||
onChange={e => {
|
onChange={e => {
|
||||||
onUsernameChange(e.target.value)
|
onUsernameChange(e.target.value)
|
||||||
|
|
@ -130,10 +135,10 @@ export const ProfileStep: FC<ProfileStepProps> = ({
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="space-y-1">
|
<div className="space-y-1">
|
||||||
<Label>Chat Display Name</Label>
|
<Label>{t("login.chatDisplayName")}</Label>
|
||||||
|
|
||||||
<Input
|
<Input
|
||||||
placeholder="Your Name"
|
placeholder={t("login.displayNamePlaceholder")}
|
||||||
value={displayName}
|
value={displayName}
|
||||||
onChange={e => onDisplayNameChange(e.target.value)}
|
onChange={e => onDisplayNameChange(e.target.value)}
|
||||||
maxLength={PROFILE_DISPLAY_NAME_MAX}
|
maxLength={PROFILE_DISPLAY_NAME_MAX}
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,13 @@
|
||||||
"reset": "Reset",
|
"reset": "Reset",
|
||||||
"emailNotAllowed": "Email {{email}} is not allowed to sign up.",
|
"emailNotAllowed": "Email {{email}} is not allowed to sign up.",
|
||||||
"passwordResetMessage": "Check email to reset password",
|
"passwordResetMessage": "Check email to reset password",
|
||||||
"errorUnexpected": "An unexpected error occurred"
|
"errorUnexpected": "An unexpected error occurred",
|
||||||
|
"username": "Username",
|
||||||
|
"usernamePlaceholder": "Enter username",
|
||||||
|
"available": "AVAILABLE",
|
||||||
|
"unavailable": "UNAVAILABLE",
|
||||||
|
"usernameError": "Username must be letters, numbers, or underscores only - no other characters or spacing allowed.",
|
||||||
|
"chatDisplayName": "Chat Display Name",
|
||||||
|
"displayNamePlaceholder": "Your Name"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,27 @@
|
||||||
"SetAPIKeysOptional": "APIキーの設定(オプション)",
|
"SetAPIKeysOptional": "APIキーの設定(オプション)",
|
||||||
"YouAreAllSetUp": "設定が完了しました!",
|
"YouAreAllSetUp": "設定が完了しました!",
|
||||||
"SetupComplete": "セットアップ完了"
|
"SetupComplete": "セットアップ完了"
|
||||||
|
},
|
||||||
|
|
||||||
|
"login": {
|
||||||
|
"email": "メールアドレス",
|
||||||
|
"emailPlaceholder": "you@example.com",
|
||||||
|
"password": "パスワード",
|
||||||
|
"passwordPlaceholder": "••••••••",
|
||||||
|
"loginButton": "ログイン",
|
||||||
|
"signUpButton": "サインアップ",
|
||||||
|
"forgotPassword": "パスワードを忘れましたか?",
|
||||||
|
"reset": "リセット",
|
||||||
|
"emailNotAllowed": "メールアドレス {{email}} は登録できません。",
|
||||||
|
"passwordResetMessage": "パスワードリセットのためにメールを確認してください。",
|
||||||
|
"errorUnexpected": "予期しないエラーが発生しました",
|
||||||
|
"username": "ユーザー名",
|
||||||
|
"usernamePlaceholder": "ユーザー名を入力してください",
|
||||||
|
"available": "利用可能",
|
||||||
|
"unavailable": "利用不可",
|
||||||
|
"usernameError": "ユーザー名は文字、数字、またはアンダースコアのみで、その他の文字やスペースは使用できません。",
|
||||||
|
"chatDisplayName": "チャット表示名",
|
||||||
|
"displayNamePlaceholder": "あなたの名前"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -22,6 +22,13 @@
|
||||||
"reset": "重置",
|
"reset": "重置",
|
||||||
"emailNotAllowed": "邮箱 {{email}} 不允许注册。",
|
"emailNotAllowed": "邮箱 {{email}} 不允许注册。",
|
||||||
"passwordResetMessage": "请检查邮箱以重置密码",
|
"passwordResetMessage": "请检查邮箱以重置密码",
|
||||||
"errorUnexpected": "发生了意外错误"
|
"errorUnexpected": "发生了意外错误",
|
||||||
|
"username": "用户名",
|
||||||
|
"usernamePlaceholder": "请输入用户名",
|
||||||
|
"available": "可用",
|
||||||
|
"unavailable": "不可用",
|
||||||
|
"usernameError": "用户名只能包含字母、数字或下划线,不能包含其他字符或空格。",
|
||||||
|
"chatDisplayName": "聊天显示名称",
|
||||||
|
"displayNamePlaceholder": "您的名称"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue