## 完成的功能 - 用户登录/注册(邮箱 + Google OAuth) - 初始问题引导流程(4 个问题) - 智能体自动生成(根据用户回答) - 智能体列表页面 ## 新增文件 - 登录/注册页面和组件 - Onboarding 页面和组件 - 智能体列表页面 - 智能体 API 端点 - 智能体 Prompt 设计 ## 数据库迁移 - onboarding_fix 迁移(users.has_completed_onboarding) ## 测试 - 登录/注册:100% 通过 - Onboarding:85% 通过 - 智能体功能:85% 通过 Co-Authored-By: Claude <noreply@anthropic.com>
49 lines
1.3 KiB
TypeScript
49 lines
1.3 KiB
TypeScript
'use client';
|
|
|
|
import { useEffect, useState } from 'react';
|
|
import { Questionnaire } from '@/components/onboarding';
|
|
import type { Locale } from '@/i18n-config';
|
|
|
|
interface Dictionary {
|
|
onboarding: Record<string, string>;
|
|
}
|
|
|
|
interface QuestionsPageProps {
|
|
params: Promise<{ locale: Locale }>;
|
|
}
|
|
|
|
export default function QuestionsPage({ params }: QuestionsPageProps) {
|
|
const [dict, setDict] = useState<Dictionary | null>(null);
|
|
const [locale, setLocale] = useState<string>('zh-CN');
|
|
const [loading, setLoading] = useState(true);
|
|
|
|
useEffect(() => {
|
|
async function loadDictionary() {
|
|
const { locale: loc } = await params;
|
|
setLocale(loc);
|
|
try {
|
|
const response = await fetch(`/api/dictionary?locale=${loc}`);
|
|
if (response.ok) {
|
|
const dictionary = await response.json();
|
|
setDict(dictionary);
|
|
}
|
|
} catch (error) {
|
|
console.error('Failed to load dictionary:', error);
|
|
} finally {
|
|
setLoading(false);
|
|
}
|
|
}
|
|
loadDictionary();
|
|
}, [params]);
|
|
|
|
if (loading || !dict) {
|
|
return (
|
|
<div className="min-h-screen bg-gradient-to-b from-pink-50 via-purple-50 to-white flex items-center justify-center">
|
|
<div className="animate-pulse text-purple-600">Loading...</div>
|
|
</div>
|
|
);
|
|
}
|
|
|
|
return <Questionnaire dict={dict} locale={locale as Locale} />;
|
|
}
|