From cac43841840982c81954607597902edab527fb93 Mon Sep 17 00:00:00 2001 From: sunhe <1279224279@qq.com> Date: Thu, 8 May 2025 20:15:53 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E6=94=B9=E9=A1=B5=E9=9D=A2?= =?UTF-8?q?=E5=B8=83=E5=B1=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/routes.ts | 6 ++-- src/app.tsx | 2 ++ .../RightContent/AvatarDropdown.tsx | 1 + src/pages/Code/index.tsx | 32 ++++++++++++++++++- src/pages/Forecast/index.tsx | 3 +- 5 files changed, 38 insertions(+), 6 deletions(-) diff --git a/config/routes.ts b/config/routes.ts index 30d6a21..3e99f63 100644 --- a/config/routes.ts +++ b/config/routes.ts @@ -8,10 +8,10 @@ export default [ { path: '/home', name :"首页", icon: "PieChartOutlined", component: './HomePage' }, { path: '/add_chart', name :"智能分析", icon: "barChart", component: './AddChart' }, { path: '/add_async', name: "异步分析", icon: "DotChartOutlined", component: './AddChartAsync' }, - { path: '/report', name: "报告中心", icon: "commentOutlined", component: './Report' }, - { path: '/code', name: "代码分析", icon: "GithubOutlined", component: './Code' }, - { path: '/Forecast', name :"分析中心", icon: "ApiOutlined", component: './Forecast' }, { path: '/my_chart', name: "我的图表", icon: "PictureOutlined", component: './MyChart' }, + { path: '/code', name: "代码分析", icon: "GithubOutlined", component: './Code' }, + { path: '/report', name: "数据报告", icon: "commentOutlined", component: './Report' }, + { path: '/Forecast', name :"数据分析", icon: "ApiOutlined", component: './Forecast' }, { path: '/open_platform', name :"开放中心", icon: "ApiOutlined", component: './OpenPlatform' }, { path: '/forum', name: "交流论坛", icon: "CrownOutlined", component: './Forum' }, { path: '/user/center', name: "个人中心", icon: "UserOutlined", component: './User/Info' }, diff --git a/src/app.tsx b/src/app.tsx index 525ef76..a61c427 100644 --- a/src/app.tsx +++ b/src/app.tsx @@ -103,6 +103,8 @@ export const layout: RunTimeLayoutConfig = ({ initialState, setInitialState }) = }; }; + + /** * @name request 配置,可以配置错误处理 * 它基于 axios 和 ahooks 的 useRequest 提供了一套统一的网络请求和错误处理方案。 diff --git a/src/components/RightContent/AvatarDropdown.tsx b/src/components/RightContent/AvatarDropdown.tsx index 32d5fdd..b0e9bc8 100644 --- a/src/components/RightContent/AvatarDropdown.tsx +++ b/src/components/RightContent/AvatarDropdown.tsx @@ -76,6 +76,7 @@ export const AvatarDropdown: React.FC = ({ menu, childre [setInitialState], ); + const loading = ( { message.warning('请输入或上传代码'); return; } + setLoading(true); + try { + const response = await fetch('http://8.218.106.190:3000/v1/chat/completions', { + method: 'POST', + headers: { + 'Content-Type': 'application/json', + 'Authorization': 'Bearer sk-mw9ekhJlSj3GeGiw0hLRSHlwdkDFst8q6oBfQrW0L15QilbY' + }, + body: JSON.stringify({ + model: 'gpt-4o-mini', + messages: [ + { + role: 'user', + content: [ + { + type: 'text', + text: analysisType === 'er' + ? '请分析这段代码并生成对应的ER图,使用mermaid语法,用于计算机科学与技术毕业论文。分析要点:1. 实体关系 2. 属性定义 3. 关系类型' + : '请分析这段代码并生成数据流图,使用mermaid语法,用于计算机科学与技术毕业论文。。分析要点:1. 模块划分 2. 依赖关系 3. 调用流程' + }, + { + type: 'text', + text: codeContent + } + ] + } + ], + max_tokens: 2000 + }) + }); try { const content = await sendRequest([ @@ -128,7 +158,7 @@ const CodeAnalysisPage: React.FC = () => { }} > ER图生成 - 功能模块图 + 数据流图 diff --git a/src/pages/Forecast/index.tsx b/src/pages/Forecast/index.tsx index c4ab780..a74d339 100644 --- a/src/pages/Forecast/index.tsx +++ b/src/pages/Forecast/index.tsx @@ -48,8 +48,7 @@ const AnalysisCenter: React.FC = () => { const [fileList, setFileList] = useState([]); const messagesEndRef = useRef(null); - const analysisOptions = [ - { value: 'predictive', label: '预测性分析', icon: , color: '#1890ff' }, + const analysisOptions = [ { value: 'descriptive', label: '描述性统计', icon: , color: '#52c41a' }, { value: 'anomaly', label: '异常检测', icon: , color: '#faad14' }, { value: 'quality', label: '数据质量分析', icon: , color: '#722ed1' },