'use client'; import { FormEvent, useState } from 'react'; import { useRouter } from 'next/navigation'; import { Cloud, HardDrive, Loader2 } from 'lucide-react'; import { toast } from 'sonner'; import { Button } from '@/components/ui/button'; import { Input } from '@/components/ui/input'; import { loginAnonymousProfile } from '@/lib/anonymous-client'; export function HomeModeSelector() { const router = useRouter(); const [codeName, setCodeName] = useState(''); const [password, setPassword] = useState(''); const [loading, setLoading] = useState(false); const startLocal = () => { router.push('/questionnaire'); }; const startAnonymous = async (event: FormEvent) => { event.preventDefault(); setLoading(true); try { await loginAnonymousProfile({ codeName: codeName.trim(), password }); toast.success('已进入匿名加密档案'); router.push('/questionnaire'); } catch (error) { toast.error(error instanceof Error ? error.message : '匿名档案进入失败'); } finally { setLoading(false); } }; return (
本地加密模式

记录只保存在当前浏览器,写入前自动加密。适合单设备使用,最快开始。

匿名加密同步

输入代号和恢复口令后,测评记录会先在浏览器加密,再同步到服务器。

setCodeName(event.target.value)} placeholder="代号,不填真实姓名" autoComplete="username" /> setPassword(event.target.value)} placeholder="恢复口令" type="password" autoComplete="current-password" />
); }