feat: support user appearance preferences with persisted theme and language #85

This commit is contained in:
rustmailer
2025-12-30 15:09:41 +08:00
parent 75cae51be9
commit 455e6b1a75
39 changed files with 1080 additions and 83 deletions
@@ -43,6 +43,7 @@ import { useTranslation } from 'react-i18next'
import i18n from '@/i18n'
import { Loader2, LogIn } from 'lucide-react'
import { login } from '@/api/users/api'
import { useTheme } from '@/context/theme-context'
type UserAuthFormProps = HTMLAttributes<HTMLDivElement>
@@ -59,6 +60,7 @@ const getFormSchema = (t: (key: string, options?: Record<string, any>) => string
export function UserAuthForm({ className, ...props }: UserAuthFormProps) {
const [isLoading, setIsLoading] = useState(false)
const { setTheme } = useTheme();
const navigate = useNavigate()
const { t } = useTranslation()
@@ -86,6 +88,15 @@ export function UserAuthForm({ className, ...props }: UserAuthFormProps) {
onSuccess: (result) => {
if (result.success) {
setToken(result);
if (result.theme) {
setTheme(result.theme);
}
if (result.language) {
i18n.changeLanguage(result.language);
}
navigate({ to: redirect });
} else {
toast({