From ddb35dd85794dc19a915f16490328c55c1a6d1c6 Mon Sep 17 00:00:00 2001 From: Shu Guang <61069967+shuguangnet@users.noreply.github.com> Date: Sat, 19 Apr 2025 02:53:29 +0800 Subject: [PATCH] chore: Format Code --- src/components/RightContent/AvatarDropdown.tsx | 3 +-- src/pages/Code/index.tsx | 6 ++---- src/pages/Forecast/index.tsx | 16 +++------------- src/pages/Forum/List/index.tsx | 9 ++++----- src/pages/Forum/Publish/index.tsx | 2 +- src/pages/HomePage/index.tsx | 6 +++--- src/pages/Report/index.tsx | 3 +-- src/pages/User/Info/index.tsx | 2 +- 8 files changed, 16 insertions(+), 31 deletions(-) diff --git a/src/components/RightContent/AvatarDropdown.tsx b/src/components/RightContent/AvatarDropdown.tsx index 144155c..32d5fdd 100644 --- a/src/components/RightContent/AvatarDropdown.tsx +++ b/src/components/RightContent/AvatarDropdown.tsx @@ -46,9 +46,8 @@ export const AvatarDropdown: React.FC = ({ menu, childre await userLogoutUsingPost(); const { search, pathname } = window.location; const urlParams = new URL(window.location.href).searchParams; - /** 此方法会跳转到 redirect 参数所在的位置 */ + /** redirect */ const redirect = urlParams.get('redirect'); - // Note: There may be security issues, please note if (window.location.pathname !== '/user/login' && !redirect) { history.replace({ pathname: '/user/login', diff --git a/src/pages/Code/index.tsx b/src/pages/Code/index.tsx index 984234c..a6134a4 100644 --- a/src/pages/Code/index.tsx +++ b/src/pages/Code/index.tsx @@ -1,15 +1,13 @@ import React, { useState } from 'react'; import { PageContainer } from '@ant-design/pro-components'; -import { InboxOutlined, CopyOutlined, DownloadOutlined } from '@ant-design/icons'; -import { Upload, Card, Button, Tabs, message, Input, Spin, Radio, Space, Tooltip } from 'antd'; +import { CopyOutlined, DownloadOutlined } from '@ant-design/icons'; +import { Upload, Card, Button, Tabs, message, Radio, Space, Tooltip } from 'antd'; import type { UploadFile } from 'antd/es/upload/interface'; -import ReactECharts from 'echarts-for-react'; import Mermaid from '@/components/Mermaid'; import MonacoEditor from '@/components/MonacoEditor'; const { Dragger } = Upload; const { TabPane } = Tabs; -const { TextArea } = Input; interface AnalysisResponse { id: string; diff --git a/src/pages/Forecast/index.tsx b/src/pages/Forecast/index.tsx index 1a5d0ac..487c81d 100644 --- a/src/pages/Forecast/index.tsx +++ b/src/pages/Forecast/index.tsx @@ -7,13 +7,11 @@ import { Button, List, Avatar, - Spin, Upload, message, Tooltip, Space, Tag, - Divider, } from 'antd'; import { SendOutlined, @@ -31,7 +29,6 @@ import styles from './index.less'; import * as XLSX from 'xlsx'; import { marked } from 'marked'; -const { Option } = Select; const { Dragger } = Upload; const { TextArea } = Input; @@ -262,7 +259,8 @@ const AnalysisCenter: React.FC = () => { const assistantMessage: Message = { type: 'assistant', content: marked(result.choices[0].message.content - .replace(/```json\n[\s\S]*?\n```/g, '') // 先移除 JSON 代码块 + // 移除 JSON 代码块 + .replace(/```json\n[\s\S]*?\n```/g, '') .trim() ), timestamp: Date.now(), @@ -286,15 +284,7 @@ const AnalysisCenter: React.FC = () => { } }; - const generateMockResponse = (type: string) => { - const responses: { [key: string]: string } = { - predictive: '根据历史数据分析,预计未来三个月的销售增长率将达到15%,主要增长点来自新市场的开拓。', - descriptive: '数据集中包含1000条记录,平均值为45.6,标准差为12.3,分布呈现正态分布特征。', - anomaly: '检测到3个异常值点,主要出现在数据的边缘区域,建议进行进一步核实。', - quality: '数据完整性为98.5%,存在少量缺失值,建议对缺失数据进行适当的填充处理。', - }; - return responses[type] || '分析完成'; - }; + return ( { key={item.id} className={styles.postItem} actions={[ - - + + {item.views} - + {item.comments} - + {item.likes} , diff --git a/src/pages/Forum/Publish/index.tsx b/src/pages/Forum/Publish/index.tsx index 4898230..be608d1 100644 --- a/src/pages/Forum/Publish/index.tsx +++ b/src/pages/Forum/Publish/index.tsx @@ -21,7 +21,7 @@ const ForumPublish: React.FC = () => { const handleSubmit = async (values: any) => { setSubmitting(true); try { - // 这里处理表单提交 + // 处理表单提交 console.log('提交数据:', values); message.success('发布成功'); history.push('/forum/list'); diff --git a/src/pages/HomePage/index.tsx b/src/pages/HomePage/index.tsx index da99b7a..2ad0db7 100644 --- a/src/pages/HomePage/index.tsx +++ b/src/pages/HomePage/index.tsx @@ -26,7 +26,7 @@ const HomePage: React.FC = () => { avgGenerationTime: 2.5, }); - // 图表类型分布 - 用于显示图标的数据 + // 图表类型分布 const chartTypes = [ { value: 35, name: '折线图', icon: }, { value: 30, name: '柱状图', icon: }, @@ -34,7 +34,7 @@ const HomePage: React.FC = () => { { value: 15, name: '散点图', icon: }, ]; - // 为ECharts准备的数据,不包含React组件 + // ECharts准备的数据 const chartTypesForEcharts = chartTypes.map(({ value, name }) => ({ value, name })); const chartOptions = { @@ -130,7 +130,7 @@ const HomePage: React.FC = () => { labelLine: { show: false, }, - // 这里使用过滤后的数据,不包含React组件 + // 使用过滤后的数据 data: chartTypesForEcharts, }, ], diff --git a/src/pages/Report/index.tsx b/src/pages/Report/index.tsx index a4b40cf..1771235 100644 --- a/src/pages/Report/index.tsx +++ b/src/pages/Report/index.tsx @@ -1,9 +1,8 @@ import React, { useState } from 'react'; import { PageContainer } from '@ant-design/pro-components'; import { InboxOutlined, FileExcelOutlined, BarChartOutlined, FileWordOutlined } from '@ant-design/icons'; -import { Upload, Card, Button, Steps, message, Input, Spin, Result, Space, Progress, Alert, Typography } from 'antd'; +import { Upload, Card, Button, Steps, message, Input, Spin, Result, Progress, Alert, Typography } from 'antd'; import type { UploadFile } from 'antd/es/upload/interface'; -import ReactECharts from 'echarts-for-react'; import { marked } from 'marked'; import styles from './index.less'; import { Document, Packer, Paragraph as DocxParagraph, TextRun } from 'docx'; diff --git a/src/pages/User/Info/index.tsx b/src/pages/User/Info/index.tsx index c8870aa..ccaa7b3 100644 --- a/src/pages/User/Info/index.tsx +++ b/src/pages/User/Info/index.tsx @@ -22,7 +22,7 @@ import { UploadOutlined, } from '@ant-design/icons'; import { useModel } from '@umijs/max'; -import type { RcFile, UploadProps } from 'antd/es/upload'; +import type { UploadProps } from 'antd/es/upload'; const { TabPane } = Tabs;