feat: 添加分析进度提示
- 显示当前分析步骤:调用服务/调用AI/生成结果 - 提升用户体验,便于定位问题 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -13,6 +13,7 @@ export function FormPage({ onSubmit, onBack }: FormPageProps) {
|
||||
const [gender, setGender] = useState<'male' | 'female'>('male');
|
||||
const [birthPlace, setBirthPlace] = useState('');
|
||||
const [isAnalyzing, setIsAnalyzing] = useState(false);
|
||||
const [analyzeStep, setAnalyzeStep] = useState('');
|
||||
const [errorMessage, setErrorMessage] = useState('');
|
||||
|
||||
const handleSubmit = async (e: React.FormEvent) => {
|
||||
@@ -21,6 +22,7 @@ export function FormPage({ onSubmit, onBack }: FormPageProps) {
|
||||
|
||||
setIsAnalyzing(true);
|
||||
setErrorMessage('');
|
||||
setAnalyzeStep('正在调用分析服务...');
|
||||
|
||||
const input: UserInput = {
|
||||
birthDate,
|
||||
@@ -30,7 +32,9 @@ export function FormPage({ onSubmit, onBack }: FormPageProps) {
|
||||
};
|
||||
|
||||
try {
|
||||
setAnalyzeStep('正在调用 AI 模型分析...');
|
||||
const result = await requestFortuneAnalysis(input);
|
||||
setAnalyzeStep('正在生成分析结果...');
|
||||
onSubmit(input, result);
|
||||
} catch (error) {
|
||||
setErrorMessage(
|
||||
@@ -38,6 +42,7 @@ export function FormPage({ onSubmit, onBack }: FormPageProps) {
|
||||
);
|
||||
} finally {
|
||||
setIsAnalyzing(false);
|
||||
setAnalyzeStep('');
|
||||
}
|
||||
};
|
||||
|
||||
@@ -161,7 +166,7 @@ export function FormPage({ onSubmit, onBack }: FormPageProps) {
|
||||
{isAnalyzing ? (
|
||||
<span className="loading-state">
|
||||
<span className="loading-dot"></span>
|
||||
分析中...
|
||||
{analyzeStep || '分析中...'}
|
||||
</span>
|
||||
) : (
|
||||
'开始分析'
|
||||
|
||||
Reference in New Issue
Block a user