feat: 🎸 更新了一部分接口请求信息

This commit is contained in:
2025-08-20 22:39:05 +08:00
parent d4b4bc82f3
commit 9895101fde
13 changed files with 116 additions and 141 deletions

View File

@@ -1,14 +1,16 @@
import { useState } from "react";
import { useSelector } from "react-redux";
import { useNavigate } from "react-router-dom";
import { mapJobList, mapInterviewList } from "@/utils/dataMapper";
import JobList from "./components/JobList";
import { getJobsList, getInterviewsList, getCurrentStudent } from "@/services";
import { getJobsList, getInterviewsList } from "@/services";
import InfiniteScroll from "@/components/InfiniteScroll";
import "./index.css";
const PAGE_SIZE = 10;
const CompanyJobsPage = () => {
const studentInfo = useSelector((state) => state.student.studentInfo);
const [isExpand, setIsExpand] = useState(false); // 是否展开
const [jobs, setJobs] = useState([]);
const [jobsListPage, setJobsListPage] = useState(1);
@@ -21,14 +23,11 @@ const CompanyJobsPage = () => {
// 获取面试信息
const fetchInterviewsData = async () => {
try {
let studentId = null;
const currentStudent = await getCurrentStudent();
studentId = currentStudent?.id;
if (studentId) {
if (studentInfo?.id) {
const res = await getInterviewsList({
page: interviewsPage,
pageSize: PAGE_SIZE,
studentId: studentId,
studentId: studentInfo?.id,
status: "SCHEDULED",
});
if (res.success) {

View File

@@ -9,8 +9,6 @@ import TaskList from "./components/TaskList";
import "./index.css";
const Dashboard = () => {
const [data, setData] = useState({});
return (
<div className="dashboard">
<StageProgress showBlockageAlert={true} />

View File

@@ -1,60 +1,9 @@
import { Avatar } from "@arco-design/web-react";
import { useState, useEffect } from "react";
import { studentAPI } from "@/services/api";
import { mapProfile } from "@/utils/dataMapper";
import { useSelector } from "react-redux";
import "./index.css";
const ProfileCard = () => {
const [profile, setProfile] = useState(null);
const [loading, setLoading] = useState(true);
useEffect(() => {
fetchProfile();
}, []);
const fetchProfile = async () => {
try {
setLoading(true);
// Get current logged-in student information
const studentData = await studentAPI.getCurrentStudent();
if (studentData) {
const mappedProfile = mapProfile(studentData);
setProfile(mappedProfile);
} else {
throw new Error("Failed to get current student data");
}
} catch (error) {
console.error("Failed to fetch profile:", error);
// Show error message instead of fake data
setProfile({
name: "数据加载失败",
studentId: "请检查后端服务",
school: error.message || "后端未运行",
major: "请确保数据库已初始化",
badges: {
credits: 0,
classRank: 0,
mbti: "-"
},
courses: []
});
} finally {
setLoading(false);
}
};
if (loading) {
return (
<div className="profile-card-wrapper" style={{
display: 'flex',
justifyContent: 'center',
alignItems: 'center'
}}>
<p>加载中...</p>
</div>
);
}
const studentInfo = useSelector((state) => state.student.studentInfo);
return (
<div className="profile-card-wrapper">
@@ -66,9 +15,11 @@ const ProfileCard = () => {
/>
</Avatar>
<div className="profile-card-user-name">
<span className="profile-card-user-name-text">{profile?.name}</span>
<span className="profile-card-user-name-text">
{studentInfo?.realName || "-"}
</span>
<p className="profile-card-user-name-student-id">
学号 {profile?.studentId}
学号 {studentInfo?.studentNo || "-"}
</p>
</div>
</div>
@@ -76,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">
{profile?.badges?.credits || 0}
{studentInfo?.totalCredits || 0}
</span>
</li>
<li className="profile-card-achievement-info-item">
@@ -84,13 +35,13 @@ const ProfileCard = () => {
班级排名
</span>
<span className="profile-card-achievement-info-item-text">
{profile?.badges?.classRank || '-'}
{studentInfo?.badges?.classRank || "-"}
</span>
</li>
<li className="profile-card-achievement-info-item">
<span className="profile-card-achievement-info-item-title">MBTI</span>
<span className="profile-card-achievement-info-item-text">
{profile?.badges?.mbti || '-'}
{studentInfo?.mbtiType || "-"}
</span>
</li>
</ul>
@@ -99,30 +50,28 @@ const ProfileCard = () => {
<i className="profile-card-class-info-item-icon icon-school" />
<span className="profile-card-class-info-item-title">学校</span>
<span className="profile-card-class-info-item-text">
{profile?.school || '-'}
{studentInfo?.school || "-"}
</span>
</li>
<li className="profile-card-class-info-item">
<i className="profile-card-class-info-item-icon icon-major" />
<span className="profile-card-class-info-item-title">专业</span>
<span className="profile-card-class-info-item-text">
{profile?.major || '-'}
{studentInfo?.major || "-"}
</span>
</li>
<li className="profile-card-class-info-item">
<i className="profile-card-class-info-item-icon icon-location" />
<span className="profile-card-class-info-item-title">
班级
</span>
<span className="profile-card-class-info-item-title">班级</span>
<span className="profile-card-class-info-item-text">
{profile?.className || '-'}
{studentInfo?.className || "-"}
</span>
</li>
<li className="profile-card-class-info-item">
<i className="profile-card-class-info-item-icon icon-course" />
<span className="profile-card-class-info-item-title">学习阶段</span>
<span className="profile-card-class-info-item-text">
{profile?.stageName || '-'}
{studentInfo?.stageName || "-"}
</span>
</li>
</ul>

View File

@@ -1,7 +1,10 @@
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 "./index.css";
const ringData = [
@@ -49,6 +52,21 @@ 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);
}
};
useEffect(() => {
queryLoginStudentProgress();
}, []);
return (
<div className="study-studes-card-wrapper">
<p className="study-studes-card-title">学习情况</p>