2025-08-20 16:29:11 +08:00
|
|
|
import { useState, useEffect } from "react";
|
2025-08-15 16:16:41 +08:00
|
|
|
import StartClass from "./components/StartClass";
|
|
|
|
|
import QuickAccess from "./components/QuickAccess";
|
|
|
|
|
import CalendarTaskModule from "./components/CalendarTaskModule";
|
|
|
|
|
import StudyStatus from "./components/StudyStatus";
|
|
|
|
|
import Rank from "@/components/Rank";
|
|
|
|
|
import StageProgress from "@/components/StageProgress";
|
|
|
|
|
import TaskList from "./components/TaskList";
|
2025-08-22 11:41:15 +08:00
|
|
|
import { getClassRanking, getStudyRecordsProgress } from "@/services";
|
2025-08-15 16:16:41 +08:00
|
|
|
import "./index.css";
|
|
|
|
|
|
|
|
|
|
const Dashboard = () => {
|
2025-08-25 14:26:42 +08:00
|
|
|
const [rankingData, setRankingData] = useState(null);
|
|
|
|
|
const [rankingLoading, setRankingLoading] = useState(true);
|
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
fetchRankingData();
|
2025-08-25 14:32:11 +08:00
|
|
|
fetchLearningProgressSummary();
|
2025-08-25 14:26:42 +08:00
|
|
|
}, []);
|
|
|
|
|
|
2025-08-25 14:32:11 +08:00
|
|
|
// 获取班级排名数据
|
2025-08-25 14:26:42 +08:00
|
|
|
const fetchRankingData = async () => {
|
|
|
|
|
try {
|
|
|
|
|
setRankingLoading(true);
|
|
|
|
|
const response = await getClassRanking();
|
2025-08-25 14:32:11 +08:00
|
|
|
if (response && response.success) {
|
|
|
|
|
setRankingData(response.data);
|
|
|
|
|
} else if (response) {
|
|
|
|
|
// 兼容直接返回数据的情况
|
2025-08-25 14:26:42 +08:00
|
|
|
setRankingData(response);
|
|
|
|
|
}
|
|
|
|
|
} catch (error) {
|
|
|
|
|
console.error('Failed to fetch ranking data:', error);
|
|
|
|
|
} finally {
|
|
|
|
|
setRankingLoading(false);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
2025-08-25 14:32:11 +08:00
|
|
|
// 获取整体学习进度
|
|
|
|
|
const fetchLearningProgressSummary = async () => {
|
|
|
|
|
try {
|
|
|
|
|
const res = await getStudyRecordsProgress();
|
|
|
|
|
console.log("learningProgressSummary", res);
|
|
|
|
|
} catch (error) {
|
|
|
|
|
console.error('Failed to fetch learning progress:', error);
|
|
|
|
|
}
|
|
|
|
|
};
|
2025-08-22 10:32:57 +08:00
|
|
|
|
2025-08-15 16:16:41 +08:00
|
|
|
return (
|
|
|
|
|
<div className="dashboard">
|
|
|
|
|
<StageProgress showBlockageAlert={true} />
|
|
|
|
|
|
|
|
|
|
<div className="dashboard-grid">
|
|
|
|
|
<StartClass />
|
|
|
|
|
<QuickAccess />
|
|
|
|
|
<CalendarTaskModule />
|
|
|
|
|
<StudyStatus />
|
2025-08-25 14:26:42 +08:00
|
|
|
<Rank data={rankingData} loading={rankingLoading} />
|
2025-08-15 16:16:41 +08:00
|
|
|
<TaskList />
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export default Dashboard;
|