diff --git a/frontend/src/pages/Inspiration.tsx b/frontend/src/pages/Inspiration.tsx index 624e1e7..70cb7de 100644 --- a/frontend/src/pages/Inspiration.tsx +++ b/frontend/src/pages/Inspiration.tsx @@ -178,7 +178,7 @@ const Inspiration: React.FC = () => { setCurrentStep('title'); setLastFailedRequest(null); } else { - handleCustomInput(userInput); + await handleCustomInput(userInput); } } catch (error: any) { console.error('发送消息失败:', error); @@ -292,22 +292,30 @@ const Inspiration: React.FC = () => { }; const handleCustomInput = async (input: string) => { - const updatedData = { ...wizardData }; - - if (currentStep === 'title') { - updatedData.title = input; - } else if (currentStep === 'description') { - updatedData.description = input; - } else if (currentStep === 'theme') { - updatedData.theme = input; - } else if (currentStep === 'genre') { - updatedData.genre = [input]; - } else if (currentStep === 'perspective') { - updatedData.narrative_perspective = input; + setLoading(true); + try { + const updatedData = { ...wizardData }; + + if (currentStep === 'title') { + updatedData.title = input; + } else if (currentStep === 'description') { + updatedData.description = input; + } else if (currentStep === 'theme') { + updatedData.theme = input; + } else if (currentStep === 'genre') { + updatedData.genre = [input]; + } else if (currentStep === 'perspective') { + updatedData.narrative_perspective = input; + } + + setWizardData(updatedData); + await generateNextStep(updatedData); + } catch (error: any) { + console.error('处理自定义输入失败:', error); + message.error(error.response?.data?.detail || '处理失败,请重试'); + } finally { + setLoading(false); } - - setWizardData(updatedData); - await generateNextStep(updatedData); }; // 自动化生成项目流程 @@ -703,8 +711,7 @@ const Inspiration: React.FC = () => { { {/* 输入区域 */} - +