From 42cd6a599a1ee34e0048e853ae9fb488d84704e7 Mon Sep 17 00:00:00 2001 From: eleliauk <2831336720@qq.com> Date: Wed, 18 Sep 2024 16:31:54 +0800 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20feat=EF=BC=9A=E6=96=B0=E5=A2=9E?= =?UTF-8?q?=E8=8E=B7=E5=8F=96=E9=97=AE=E9=A2=98=E6=95=B0=E9=87=8F=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/classInfo/index.tsx | 31 +++++++++++++++++++++++++------ 1 file changed, 25 insertions(+), 6 deletions(-) diff --git a/src/pages/classInfo/index.tsx b/src/pages/classInfo/index.tsx index bb16042..2e27822 100644 --- a/src/pages/classInfo/index.tsx +++ b/src/pages/classInfo/index.tsx @@ -42,6 +42,7 @@ export default function Index() { const [courseId, setCourseId] = useState(null); const [comments, setComments] = useState([]); const [grade, setGrade] = useState(); + const [questionNum, setQuestionNum] = useState(0); //const [Question, setQuestion] = useState(); useEffect(() => { const getParams = () => { @@ -53,7 +54,7 @@ export default function Index() { getParams(); }, []); - + //获取问题个数 useEffect(() => { // eslint-disable-next-line @typescript-eslint/require-await const getCourseData = async () => { @@ -117,9 +118,23 @@ export default function Index() { }; if (courseId) void fetchGrades(); }, [courseId]); - + useEffect(() => { + const getNumData = () => { + try { + console.log('test', courseId); + void get(`/questions/count?biz=Course&biz_id=${courseId}`, true).then((res) => { + console.log(res); + // eslint-disable-next-line @typescript-eslint/no-unsafe-argument + setQuestionNum(res.data); + }); + } catch (e) { + console.error(e); + } + }; + void getNumData(); + }, [courseId]); if (!course || !grade) { - return Loading...; // 数据加载中 + return 请先确定已签约成绩共享计划; // 数据加载中 } const xLabels = ['0-40', '40-50', '50-60', '60-70', '70-80', '80-90', '90-100']; @@ -155,7 +170,6 @@ export default function Index() { ))} - {/* 将 grade 数据传递给 LineChart */} - 问问同学 + + 问问同学({questionNum}) + <> + { @@ -182,7 +199,9 @@ export default function Index() { 全部> - + + 最新评论 + {comments && comments.map((comment) => (