feat: 🎸 对接了一些接口
This commit is contained in:
@@ -16,7 +16,9 @@ const Layout = ({ children }) => {
|
||||
|
||||
const queryLoginStudentInfo = async () => {
|
||||
const res = await getLoginStudentInfo();
|
||||
dispatch(setStudentInfo(res));
|
||||
if (res.success) {
|
||||
dispatch(setStudentInfo(res.data));
|
||||
}
|
||||
};
|
||||
|
||||
// 初始化项目统一获取登录用户信息
|
||||
|
||||
@@ -1,41 +1,23 @@
|
||||
import { Avatar } from "@arco-design/web-react";
|
||||
import "./index.css";
|
||||
|
||||
const Rank = ({ className }) => {
|
||||
const Rank = ({ className, data }) => {
|
||||
return (
|
||||
<div className={`module-class-rank ${className}`}>
|
||||
<p className="module-class-rank-title">班级排名</p>
|
||||
|
||||
<ul className="module-class-rank-podium">
|
||||
<li className="module-class-rank-podium-item2">
|
||||
<Avatar className="module-class-rank-podium-avatar">
|
||||
<img
|
||||
alt="avatar"
|
||||
src="//p1-arco.byteimg.com/tos-cn-i-uwbnlip3yd/3ee5f13fb09879ecb5185e440cef6eb9.png~tplv-uwbnlip3yd-webp.webp"
|
||||
/>
|
||||
</Avatar>
|
||||
<span className="module-class-rank-podium-name">你好呀</span>
|
||||
<i className="module-class-rank-podium-icon2"></i>
|
||||
</li>
|
||||
<li className="module-class-rank-podium-item1">
|
||||
<Avatar className="module-class-rank-podium-avatar">
|
||||
<img
|
||||
alt="avatar"
|
||||
src="//p1-arco.byteimg.com/tos-cn-i-uwbnlip3yd/3ee5f13fb09879ecb5185e440cef6eb9.png~tplv-uwbnlip3yd-webp.webp"
|
||||
/>
|
||||
</Avatar>
|
||||
<span className="module-class-rank-podium-name">你好呀</span>
|
||||
<i className="module-class-rank-podium-icon1"></i>
|
||||
</li>
|
||||
<li className="module-class-rank-podium-item3">
|
||||
<Avatar className="module-class-rank-podium-avatar">
|
||||
<img
|
||||
alt="avatar"
|
||||
src="//p1-arco.byteimg.com/tos-cn-i-uwbnlip3yd/3ee5f13fb09879ecb5185e440cef6eb9.png~tplv-uwbnlip3yd-webp.webp"
|
||||
/>
|
||||
</Avatar>
|
||||
<span className="module-class-rank-podium-name">你好呀</span>
|
||||
<i className="module-class-rank-podium-icon3"></i>
|
||||
</li>
|
||||
{data?.rankings?.slice(0, 3)?.map((item) => (
|
||||
<li className="module-class-rank-podium-item2" key={item.rank}>
|
||||
<Avatar className="module-class-rank-podium-avatar">
|
||||
<img alt="avatar" src={item?.avatar} />
|
||||
</Avatar>
|
||||
<span className="module-class-rank-podium-name">
|
||||
{item.studentName}
|
||||
</span>
|
||||
<i className="module-class-rank-podium-icon2"></i>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
<ul className="module-class-rank-list">
|
||||
<li className="module-class-rank-list-item">
|
||||
|
||||
@@ -1,14 +1,23 @@
|
||||
import "./index.css";
|
||||
import { useNavigate } from "react-router-dom";
|
||||
import icon1 from "@/assets/images/Dashboard/QuickAccess/icon1.png";
|
||||
import icon2 from "@/assets/images/Dashboard/QuickAccess/icon2.png";
|
||||
import icon3 from "@/assets/images/Dashboard/QuickAccess/icon3.png";
|
||||
import "./index.css";
|
||||
|
||||
const QuickAccess = () => {
|
||||
const navigate = useNavigate();
|
||||
|
||||
const handleClick = (path) => {
|
||||
navigate(path);
|
||||
};
|
||||
return (
|
||||
<div className="module-quick-access-wrapper">
|
||||
<p className="module-quick-access-title">快捷入口</p>
|
||||
<ul className="module-quick-access-list">
|
||||
<li className="module-quick-access-item">
|
||||
<li
|
||||
className="module-quick-access-item"
|
||||
onClick={() => handleClick("/expert-support")}
|
||||
>
|
||||
<img
|
||||
src={icon1}
|
||||
alt="icon1"
|
||||
@@ -16,7 +25,10 @@ const QuickAccess = () => {
|
||||
/>
|
||||
<p className="module-quick-access-item-text">专家支持中心</p>
|
||||
</li>
|
||||
<li className="module-quick-access-item">
|
||||
<li
|
||||
className="module-quick-access-item"
|
||||
onClick={() => handleClick("/live")}
|
||||
>
|
||||
<img
|
||||
src={icon2}
|
||||
alt="icon1"
|
||||
@@ -24,7 +36,10 @@ const QuickAccess = () => {
|
||||
/>
|
||||
<p className="module-quick-access-item-text">课程直播间</p>
|
||||
</li>
|
||||
<li className="module-quick-access-item">
|
||||
<li
|
||||
className="module-quick-access-item"
|
||||
onClick={() => handleClick("/career-tree")}
|
||||
>
|
||||
<img
|
||||
src={icon3}
|
||||
alt="icon1"
|
||||
|
||||
@@ -6,9 +6,31 @@ import StudyStatus from "./components/StudyStatus";
|
||||
import Rank from "@/components/Rank";
|
||||
import StageProgress from "@/components/StageProgress";
|
||||
import TaskList from "./components/TaskList";
|
||||
import { getClassRanking, getLearningProgressSummary } from "@/services";
|
||||
import "./index.css";
|
||||
|
||||
const Dashboard = () => {
|
||||
const [rankData, setRankData] = useState([]); // 班级排名数据
|
||||
|
||||
// 获取整体学习进度
|
||||
const queryLearningProgressSummary = async () => {
|
||||
const res = await getLearningProgressSummary({ period: "semester" });
|
||||
console.log("learningProgressSummary", res);
|
||||
};
|
||||
|
||||
// 获取班级排名
|
||||
const queryRankData = async () => {
|
||||
const res = await getClassRanking();
|
||||
if (res.success) {
|
||||
setRankData(res.data);
|
||||
}
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
queryRankData();
|
||||
queryLearningProgressSummary();
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<div className="dashboard">
|
||||
<StageProgress showBlockageAlert={true} />
|
||||
@@ -18,7 +40,7 @@ const Dashboard = () => {
|
||||
<QuickAccess />
|
||||
<CalendarTaskModule />
|
||||
<StudyStatus />
|
||||
<Rank />
|
||||
<Rank data={rankData} />
|
||||
<TaskList />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -27,7 +27,7 @@ const ProfileCard = () => {
|
||||
<li className="profile-card-achievement-info-item">
|
||||
<span className="profile-card-achievement-info-item-title">学分</span>
|
||||
<span className="profile-card-achievement-info-item-text">
|
||||
{studentInfo?.totalCredits || 0}
|
||||
{studentInfo?.myRank?.score || "-"}
|
||||
</span>
|
||||
</li>
|
||||
<li className="profile-card-achievement-info-item">
|
||||
@@ -35,7 +35,7 @@ const ProfileCard = () => {
|
||||
班级排名
|
||||
</span>
|
||||
<span className="profile-card-achievement-info-item-text">
|
||||
{studentInfo?.badges?.classRank || "-"}
|
||||
{studentInfo?.myRank?.rank || "-"}
|
||||
</span>
|
||||
</li>
|
||||
<li className="profile-card-achievement-info-item">
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import * as echarts from "echarts";
|
||||
import { useState, useEffect } from "react";
|
||||
import { useSelector } from "react-redux";
|
||||
import StudyProgress from "../StudyProgress";
|
||||
import ScoreRingChart from "../ScoreRingChart";
|
||||
import AttendanceRingChart from "../AttendanceRingChart";
|
||||
import { getLoginStudentProgress } from "@/services";
|
||||
import { getDashboardStatistics } from "@/services";
|
||||
import "./index.css";
|
||||
import { useEffect } from "react";
|
||||
|
||||
const ringData = [
|
||||
{
|
||||
@@ -54,17 +54,14 @@ const attendanceData = [
|
||||
const StudyStudes = () => {
|
||||
const studentInfo = useSelector((state) => state.student.studentInfo);
|
||||
|
||||
const [progressData, setProgressData] = useState({});
|
||||
|
||||
const queryLoginStudentProgress = async () => {
|
||||
const res = await getLoginStudentProgress();
|
||||
if (res.success) {
|
||||
setProgressData(res.data);
|
||||
}
|
||||
// 获取仪表盘数据
|
||||
const queryDashboardStatistics = async () => {
|
||||
const res = await getDashboardStatistics();
|
||||
console.log(res);
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
queryLoginStudentProgress();
|
||||
queryDashboardStatistics();
|
||||
}, []);
|
||||
|
||||
return (
|
||||
|
||||
@@ -1,10 +1,40 @@
|
||||
import { useState, useEffect } from "react";
|
||||
import { useDispatch } from "react-redux";
|
||||
import ProfileCard from "./components/ProfileCard";
|
||||
import Rank from "@/components/Rank";
|
||||
import StageProgress from "@/components/StageProgress";
|
||||
import StudyStudes from "./components/StudyStudes";
|
||||
import { updateStudentInfo } from "@/store/slices/studentSlice";
|
||||
import { getClassRanking, getLearningProgressSummary } from "@/services";
|
||||
import "./index.css";
|
||||
|
||||
const PersonalProfile = () => {
|
||||
const dispatch = useDispatch();
|
||||
const [rankData, setRankData] = useState([]); // 班级排名数据
|
||||
|
||||
const queryLearningProgressSummary = async () => {
|
||||
const res = await getLearningProgressSummary({ period: "semester" });
|
||||
console.log("learningProgressSummary", res);
|
||||
};
|
||||
|
||||
// 获取班级排名
|
||||
const queryRankData = async () => {
|
||||
const res = await getClassRanking();
|
||||
if (res.success) {
|
||||
const studentInfo = {
|
||||
myRank: res.data.myRank,
|
||||
classInfo: res.data.classInfo,
|
||||
};
|
||||
setRankData(res.data);
|
||||
dispatch(updateStudentInfo(studentInfo));
|
||||
}
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
queryRankData();
|
||||
queryLearningProgressSummary();
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<div className="personal-profile">
|
||||
<StageProgress />
|
||||
@@ -13,7 +43,7 @@ const PersonalProfile = () => {
|
||||
<div className="unified-profile-layout">
|
||||
<div className="unified-profile-left">
|
||||
<ProfileCard />
|
||||
<Rank className="unified-profile-rank" />
|
||||
<Rank className="unified-profile-rank" data={rankData} />
|
||||
</div>
|
||||
<div className="unified-profile-right">
|
||||
<StudyStudes />
|
||||
|
||||
@@ -1,30 +1,31 @@
|
||||
import request from "@/utils/request";
|
||||
|
||||
// 获取当前学生的仪表板统计信息
|
||||
export async function getDashboardStatistics() {
|
||||
// 获取当前学生的学习进度汇总
|
||||
export async function getLearningProgressSummary(queryParams = {}) {
|
||||
return request({
|
||||
url: `/api/dashboard/stats`,
|
||||
url: `/api/dashboard/learning-summary`,
|
||||
method: "GET",
|
||||
params: queryParams,
|
||||
namespace: "dashboardLoading",
|
||||
});
|
||||
}
|
||||
|
||||
// 获取当前学生的学习进度汇总
|
||||
export async function getLearningProgressSummary(params = {}) {
|
||||
// 获取我的任务
|
||||
export async function getMyTasks(queryParams = {}) {
|
||||
return request({
|
||||
url: `/api/dashboard/learning-summary`,
|
||||
url: `/api/tasks/my-tasks`,
|
||||
method: "GET",
|
||||
params,
|
||||
params: queryParams,
|
||||
namespace: "dashboardLoading",
|
||||
});
|
||||
}
|
||||
|
||||
// 获取当前学生班级排名
|
||||
export async function getClassRanking(params = {}) {
|
||||
export async function getClassRanking(queryParams = {}) {
|
||||
return request({
|
||||
url: `/api/rankings/class`,
|
||||
method: "GET",
|
||||
params,
|
||||
params: queryParams,
|
||||
namespace: "dashboardLoading",
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,35 +1,41 @@
|
||||
// 统一的API服务接口 - 基于当前认证用户
|
||||
import {
|
||||
getDashboardStatistics,
|
||||
getLearningProgressSummary,
|
||||
getMyTasks,
|
||||
getClassRanking,
|
||||
} from "./dashboard";
|
||||
import { getProjectsList } from "./projectLibrary";
|
||||
import { getJobsList, getInterviewsList } from "./companyJobs";
|
||||
import { getLoginStudentInfo } from "./global";
|
||||
import { getLoginStudentProgress, getClassRank, getMyRanking } from "./personalProfile";
|
||||
import {
|
||||
getDashboardStatistics,
|
||||
getLoginStudentProgress,
|
||||
getClassRank,
|
||||
getMyRanking,
|
||||
} from "./personalProfile";
|
||||
import { getResumesList, getResumesDetail } from "./resumeInterview";
|
||||
|
||||
export {
|
||||
// 仪表盘相关
|
||||
getDashboardStatistics, // 获取当前学生仪表盘统计
|
||||
getLearningProgressSummary, // 获取当前学生学习进度汇总
|
||||
|
||||
getMyTasks, // 获取我的任务
|
||||
getDashboardStatistics, // 获取当前学生仪表盘统计
|
||||
getLearningProgressSummary, // 获取当前学生学习进度汇总
|
||||
|
||||
// 排名相关
|
||||
getClassRanking, // 获取当前学生班级排名
|
||||
getMyRanking, // 获取当前学生详细排名信息
|
||||
|
||||
getClassRanking, // 获取当前学生班级排名
|
||||
getMyRanking, // 获取当前学生详细排名信息
|
||||
|
||||
// 学生信息相关
|
||||
getLoginStudentInfo, // 获取当前登录学生基本信息
|
||||
getLoginStudentProgress, // 获取当前学生学习进度
|
||||
getClassRank, // 获取班级排名(别名)
|
||||
|
||||
getLoginStudentInfo, // 获取当前登录学生基本信息
|
||||
getLoginStudentProgress, // 获取当前学生学习进度
|
||||
getClassRank, // 获取班级排名(别名)
|
||||
|
||||
// 项目和作品相关
|
||||
getProjectsList, // 获取项目列表
|
||||
|
||||
getProjectsList, // 获取项目列表
|
||||
|
||||
// 求职相关
|
||||
getJobsList, // 获取岗位列表
|
||||
getInterviewsList, // 获取面试列表
|
||||
getResumesList, // 获取简历列表
|
||||
getResumesDetail, // 获取简历详情
|
||||
getJobsList, // 获取岗位列表
|
||||
getInterviewsList, // 获取面试列表
|
||||
getResumesList, // 获取简历列表
|
||||
getResumesDetail, // 获取简历详情
|
||||
};
|
||||
|
||||
@@ -9,6 +9,15 @@ export async function getLoginStudentProgress() {
|
||||
});
|
||||
}
|
||||
|
||||
// 获取仪表板统计信息
|
||||
export async function getDashboardStatistics() {
|
||||
return request({
|
||||
url: `/api/dashboard/stats`,
|
||||
method: "GET",
|
||||
namespace: "dashboardLoading",
|
||||
});
|
||||
}
|
||||
|
||||
// 获取当前学生班级排名
|
||||
export async function getClassRank(queryParams = {}) {
|
||||
return request({
|
||||
|
||||
@@ -49,24 +49,6 @@ axiosInstance.interceptors.response.use(
|
||||
(response) => {
|
||||
// 处理响应数据
|
||||
const res = response.data;
|
||||
|
||||
// 后端统一返回格式 {success, data, message}
|
||||
if (res.success !== undefined) {
|
||||
if (res.success) {
|
||||
// 如果有分页信息,保留完整结构
|
||||
if (res.total !== undefined) {
|
||||
return res;
|
||||
}
|
||||
// 否则只返回data
|
||||
return res.data || res;
|
||||
} else {
|
||||
// 处理业务错误
|
||||
console.error("业务错误:", res.message);
|
||||
return Promise.reject(new Error(res.message || "请求失败"));
|
||||
}
|
||||
}
|
||||
|
||||
// 兼容直接返回数据的情况
|
||||
return res;
|
||||
},
|
||||
(error) => {
|
||||
|
||||
Reference in New Issue
Block a user