mirror of
https://github.com/shumaiOne/shumai.git
synced 2026-12-04 15:14:10 +00:00
feat(auth): allow setting user locale on signup
This commit is contained in:
@@ -424,8 +424,8 @@
|
||||
"avatar_source": "头像来源",
|
||||
"saving": "保存中",
|
||||
|
||||
"auth_tagline": "一个工作区,管理所有创意资产。",
|
||||
"auth_description": "上传并索引您的文件,使用自定义元数据模式丰富它们,直接在媒体上绘制标注,并收集即时反馈——这一切都在一个为创作者打造的现代工作区中完成。",
|
||||
"auth_tagline": "一站式创意资产管理协作平台。",
|
||||
"auth_description": "上传您的创意资产,添加各种类型的自定义元数据,直接在图片或视频上绘制标注和添加评论,——这一切都在Shumai,一个为创作者打造的一站式平台上完成。",
|
||||
"auth_feature_uploads": "即时资产上传 & 高保真媒体播放器",
|
||||
"auth_feature_metadata": "自定义元数据模式 & 画布标注审阅",
|
||||
"auth_feature_teams": "无缝团队工作区 & 安全分享",
|
||||
|
||||
+1
-1
@@ -10,7 +10,7 @@ const en_auth_description = /** @type {(inputs: Auth_DescriptionInputs) => Local
|
||||
};
|
||||
|
||||
const zh_auth_description = /** @type {(inputs: Auth_DescriptionInputs) => LocalizedString} */ () => {
|
||||
return /** @type {LocalizedString} */ (`上传并索引您的文件,使用自定义元数据模式丰富它们,直接在媒体上绘制标注,并收集即时反馈——这一切都在一个为创作者打造的现代工作区中完成。`)
|
||||
return /** @type {LocalizedString} */ (`上传您的创意资产,添加各种类型的自定义元数据,直接在图片或视频上绘制标注和添加评论,——这一切都在Shumai,一个为创作者打造的一站式平台上完成。`)
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
+1
-1
@@ -10,7 +10,7 @@ const en_auth_tagline = /** @type {(inputs: Auth_TaglineInputs) => LocalizedStri
|
||||
};
|
||||
|
||||
const zh_auth_tagline = /** @type {(inputs: Auth_TaglineInputs) => LocalizedString} */ () => {
|
||||
return /** @type {LocalizedString} */ (`一个工作区,管理所有创意资产。`)
|
||||
return /** @type {LocalizedString} */ (`一站式创意资产管理协作平台。`)
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,20 +1,21 @@
|
||||
import { client } from '@/ui/api/client'
|
||||
import { useQuery } from '@tanstack/react-query'
|
||||
import { AuthLayout } from '@/ui/components/auth-layout'
|
||||
import { Button } from '@/ui/components/ui/button'
|
||||
import { Card, CardDescription, CardFooter, CardHeader, CardTitle } from '@/ui/components/ui/card'
|
||||
import { ShumaiLogo } from '@/ui/components/ui/icons'
|
||||
import { Input } from '@/ui/components/ui/input'
|
||||
import { Label } from '@/ui/components/ui/label'
|
||||
import { Loader2, Mail, Lock, ArrowRight, UserPlus } from 'lucide-react'
|
||||
import { signUp } from '@/ui/lib/auth-client'
|
||||
import { m } from '@/ui/paraglide/messages.js'
|
||||
import { getLocale, setLocale } from '@/ui/paraglide/runtime.js'
|
||||
import { useAuthStore } from '@/ui/stores/auth'
|
||||
import { zodResolver } from '@hookform/resolvers/zod'
|
||||
import { useQuery } from '@tanstack/react-query'
|
||||
import { createFileRoute, redirect, useNavigate } from '@tanstack/react-router'
|
||||
import { ArrowRight, Loader2, Lock, Mail, UserPlus } from 'lucide-react'
|
||||
import { useState } from 'react'
|
||||
import { useForm } from 'react-hook-form'
|
||||
import { z } from 'zod'
|
||||
import { signUp } from '@/ui/lib/auth-client'
|
||||
import { useState } from 'react'
|
||||
import { ShumaiLogo } from '@/ui/components/ui/icons'
|
||||
import { AuthLayout } from '@/ui/components/auth-layout'
|
||||
import { m } from '@/ui/paraglide/messages.js'
|
||||
|
||||
const signupSchema = z.object({
|
||||
email: z.string().email(m.invalid_email_address()),
|
||||
@@ -30,6 +31,15 @@ function SignupPage() {
|
||||
const inviteCode = (search as { inviteCode?: string }).inviteCode
|
||||
const [error, setError] = useState<string | null>(null)
|
||||
const [loading, setLoading] = useState(false)
|
||||
const [locale, setLocaleState] = useState<'en' | 'zh'>(() => {
|
||||
const activeLocale = getLocale()
|
||||
return activeLocale === 'zh' ? 'zh' : 'en'
|
||||
})
|
||||
|
||||
const handleLocaleChange = (newLocale: 'en' | 'zh') => {
|
||||
setLocaleState(newLocale)
|
||||
setLocale(newLocale)
|
||||
}
|
||||
|
||||
const { data: inviteInfo } = useQuery({
|
||||
queryKey: ['invite', inviteCode],
|
||||
@@ -71,6 +81,7 @@ function SignupPage() {
|
||||
password: data.password,
|
||||
name: data.email, // Use email as the username
|
||||
inviteCode: data.inviteCode,
|
||||
locale,
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
} as any)
|
||||
|
||||
@@ -238,14 +249,38 @@ function SignupPage() {
|
||||
</Button>
|
||||
</form>
|
||||
|
||||
<div className="mt-8 pt-6 border-t border-zinc-200/30 dark:border-zinc-800/30 text-center text-sm">
|
||||
<span className="text-zinc-500 dark:text-zinc-400">{m.already_have_account()}</span>
|
||||
<a
|
||||
href="/login"
|
||||
className="font-semibold text-rose-500 hover:text-rose-600 dark:text-rose-400 dark:hover:text-rose-300 transition-colors hover:underline inline-flex items-center gap-0.5"
|
||||
>
|
||||
{m.login()} <ArrowRight className="w-3.5 h-3.5" />
|
||||
</a>
|
||||
<div className="mt-12 pt-10 border-t border-zinc-200/30 dark:border-zinc-800/30 text-center text-sm flex flex justify-between gap-4">
|
||||
<div>
|
||||
<span className="text-zinc-500 dark:text-zinc-400">{m.already_have_account()} </span>
|
||||
<a
|
||||
href="/login"
|
||||
className="font-semibold text-rose-500 hover:text-rose-600 dark:text-rose-400 dark:hover:text-rose-300 transition-colors hover:underline inline-flex items-center gap-0.5"
|
||||
>
|
||||
{m.login()} <ArrowRight className="w-3.5 h-3.5" />
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<div className="flex items-center gap-2 text-xs text-zinc-400 dark:text-zinc-500">
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => handleLocaleChange('en')}
|
||||
className={`cursor-pointer hover:text-zinc-800 dark:hover:text-zinc-200 transition-colors ${
|
||||
locale === 'en' ? 'font-bold text-rose-500 dark:text-rose-400' : ''
|
||||
}`}
|
||||
>
|
||||
English
|
||||
</button>
|
||||
<span className="text-zinc-300 dark:text-zinc-850">/</span>
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => handleLocaleChange('zh')}
|
||||
className={`cursor-pointer hover:text-zinc-800 dark:hover:text-zinc-200 transition-colors ${
|
||||
locale === 'zh' ? 'font-bold text-rose-500 dark:text-rose-400' : ''
|
||||
}`}
|
||||
>
|
||||
中文
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</AuthLayout>
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user