feat: 🎸 更新了一部分接口请求信息
This commit is contained in:
@@ -3,14 +3,6 @@
|
|||||||
width: 100%;
|
width: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
.loading-indicator {
|
|
||||||
display: flex;
|
|
||||||
justify-content: center;
|
|
||||||
align-items: center;
|
|
||||||
padding: 16px;
|
|
||||||
color: #999;
|
|
||||||
}
|
|
||||||
|
|
||||||
.no-more-data {
|
.no-more-data {
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
|
|||||||
@@ -1,8 +1,5 @@
|
|||||||
import { useEffect, useRef, useState } from "react";
|
import { useEffect, useRef, useState } from "react";
|
||||||
import { Empty } from "@arco-design/web-react";
|
import { Empty } from "@arco-design/web-react";
|
||||||
import { useSelector } from "react-redux";
|
|
||||||
import { useDispatch } from "react-redux";
|
|
||||||
import { setLoadingFalse } from "@/store/slices/loadingSlice";
|
|
||||||
|
|
||||||
const InfiniteScroll = ({
|
const InfiniteScroll = ({
|
||||||
loadMore,
|
loadMore,
|
||||||
@@ -11,21 +8,18 @@ const InfiniteScroll = ({
|
|||||||
threshold = 50,
|
threshold = 50,
|
||||||
className = "",
|
className = "",
|
||||||
}) => {
|
}) => {
|
||||||
const dispatch = useDispatch();
|
|
||||||
const containerRef = useRef(null);
|
const containerRef = useRef(null);
|
||||||
const globalLoading = useSelector((state) => state.loading.value);
|
|
||||||
const [loading, setLoading] = useState(false);
|
const [loading, setLoading] = useState(false);
|
||||||
|
|
||||||
const handleScroll = () => {
|
const handleScroll = () => {
|
||||||
if (loading) return;
|
if (loading) return;
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
if (!containerRef.current || globalLoading || !hasMore) return;
|
if (!containerRef.current || !hasMore) return;
|
||||||
|
|
||||||
const { scrollTop, scrollHeight, clientHeight } = containerRef.current;
|
const { scrollTop, scrollHeight, clientHeight } = containerRef.current;
|
||||||
|
|
||||||
if (scrollTop + clientHeight >= scrollHeight - threshold) {
|
if (scrollTop + clientHeight >= scrollHeight - threshold) {
|
||||||
loadMore().finally(() => {
|
loadMore().finally(() => {
|
||||||
dispatch(setLoadingFalse());
|
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -44,7 +38,7 @@ const InfiniteScroll = ({
|
|||||||
container.removeEventListener("scroll", handleScroll);
|
container.removeEventListener("scroll", handleScroll);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}, [loadMore, hasMore, threshold, globalLoading]);
|
}, [loadMore, hasMore, threshold]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
@@ -52,7 +46,7 @@ const InfiniteScroll = ({
|
|||||||
className={`infinite-scroll-container ${className}`}
|
className={`infinite-scroll-container ${className}`}
|
||||||
>
|
>
|
||||||
{children}
|
{children}
|
||||||
{!hasMore && !globalLoading && <Empty description="没有更多了" />}
|
{!hasMore && !loading && <Empty description="没有更多了" />}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,12 +1,28 @@
|
|||||||
import { useState } from "react";
|
import { useState, useEffect } from "react";
|
||||||
import { Spin } from "@arco-design/web-react";
|
import { Spin } from "@arco-design/web-react";
|
||||||
import { useSelector } from "react-redux";
|
import { useSelector, useDispatch } from "react-redux";
|
||||||
|
import { getLoginStudentInfo } from "@/services";
|
||||||
|
import { setStudentInfo } from "@/store/slices/studentSlice";
|
||||||
import Sidebar from "../Sidebar";
|
import Sidebar from "../Sidebar";
|
||||||
import "./index.css";
|
import "./index.css";
|
||||||
|
|
||||||
const Layout = ({ children }) => {
|
const Layout = ({ children }) => {
|
||||||
const loading = useSelector((state) => state.loading.value);
|
const dispatch = useDispatch();
|
||||||
const [isCollapsed, setIsCollapsed] = useState(true);
|
const [isCollapsed, setIsCollapsed] = useState(true);
|
||||||
|
const loading = useSelector((state) => state.loading.value);
|
||||||
|
const studentInfo = useSelector((state) => state.student.studentInfo);
|
||||||
|
|
||||||
|
const queryLoginStudentInfo = async () => {
|
||||||
|
const res = await getLoginStudentInfo();
|
||||||
|
dispatch(setStudentInfo(res));
|
||||||
|
};
|
||||||
|
|
||||||
|
// 初始化项目统一获取登录用户信息
|
||||||
|
useEffect(() => {
|
||||||
|
if (!studentInfo) {
|
||||||
|
queryLoginStudentInfo();
|
||||||
|
}
|
||||||
|
}, [studentInfo]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="app-layout">
|
<div className="app-layout">
|
||||||
|
|||||||
@@ -1,14 +1,16 @@
|
|||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
|
import { useSelector } from "react-redux";
|
||||||
import { useNavigate } from "react-router-dom";
|
import { useNavigate } from "react-router-dom";
|
||||||
import { mapJobList, mapInterviewList } from "@/utils/dataMapper";
|
import { mapJobList, mapInterviewList } from "@/utils/dataMapper";
|
||||||
import JobList from "./components/JobList";
|
import JobList from "./components/JobList";
|
||||||
import { getJobsList, getInterviewsList, getCurrentStudent } from "@/services";
|
import { getJobsList, getInterviewsList } from "@/services";
|
||||||
import InfiniteScroll from "@/components/InfiniteScroll";
|
import InfiniteScroll from "@/components/InfiniteScroll";
|
||||||
|
|
||||||
import "./index.css";
|
import "./index.css";
|
||||||
const PAGE_SIZE = 10;
|
const PAGE_SIZE = 10;
|
||||||
|
|
||||||
const CompanyJobsPage = () => {
|
const CompanyJobsPage = () => {
|
||||||
|
const studentInfo = useSelector((state) => state.student.studentInfo);
|
||||||
const [isExpand, setIsExpand] = useState(false); // 是否展开
|
const [isExpand, setIsExpand] = useState(false); // 是否展开
|
||||||
const [jobs, setJobs] = useState([]);
|
const [jobs, setJobs] = useState([]);
|
||||||
const [jobsListPage, setJobsListPage] = useState(1);
|
const [jobsListPage, setJobsListPage] = useState(1);
|
||||||
@@ -21,14 +23,11 @@ const CompanyJobsPage = () => {
|
|||||||
// 获取面试信息
|
// 获取面试信息
|
||||||
const fetchInterviewsData = async () => {
|
const fetchInterviewsData = async () => {
|
||||||
try {
|
try {
|
||||||
let studentId = null;
|
if (studentInfo?.id) {
|
||||||
const currentStudent = await getCurrentStudent();
|
|
||||||
studentId = currentStudent?.id;
|
|
||||||
if (studentId) {
|
|
||||||
const res = await getInterviewsList({
|
const res = await getInterviewsList({
|
||||||
page: interviewsPage,
|
page: interviewsPage,
|
||||||
pageSize: PAGE_SIZE,
|
pageSize: PAGE_SIZE,
|
||||||
studentId: studentId,
|
studentId: studentInfo?.id,
|
||||||
status: "SCHEDULED",
|
status: "SCHEDULED",
|
||||||
});
|
});
|
||||||
if (res.success) {
|
if (res.success) {
|
||||||
|
|||||||
@@ -9,8 +9,6 @@ import TaskList from "./components/TaskList";
|
|||||||
import "./index.css";
|
import "./index.css";
|
||||||
|
|
||||||
const Dashboard = () => {
|
const Dashboard = () => {
|
||||||
const [data, setData] = useState({});
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="dashboard">
|
<div className="dashboard">
|
||||||
<StageProgress showBlockageAlert={true} />
|
<StageProgress showBlockageAlert={true} />
|
||||||
|
|||||||
@@ -1,60 +1,9 @@
|
|||||||
import { Avatar } from "@arco-design/web-react";
|
import { Avatar } from "@arco-design/web-react";
|
||||||
import { useState, useEffect } from "react";
|
import { useSelector } from "react-redux";
|
||||||
import { studentAPI } from "@/services/api";
|
|
||||||
import { mapProfile } from "@/utils/dataMapper";
|
|
||||||
import "./index.css";
|
import "./index.css";
|
||||||
|
|
||||||
const ProfileCard = () => {
|
const ProfileCard = () => {
|
||||||
const [profile, setProfile] = useState(null);
|
const studentInfo = useSelector((state) => state.student.studentInfo);
|
||||||
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>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="profile-card-wrapper">
|
<div className="profile-card-wrapper">
|
||||||
@@ -66,9 +15,11 @@ const ProfileCard = () => {
|
|||||||
/>
|
/>
|
||||||
</Avatar>
|
</Avatar>
|
||||||
<div className="profile-card-user-name">
|
<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">
|
<p className="profile-card-user-name-student-id">
|
||||||
学号: {profile?.studentId}
|
学号: {studentInfo?.studentNo || "-"}
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -76,7 +27,7 @@ const ProfileCard = () => {
|
|||||||
<li className="profile-card-achievement-info-item">
|
<li className="profile-card-achievement-info-item">
|
||||||
<span className="profile-card-achievement-info-item-title">学分</span>
|
<span className="profile-card-achievement-info-item-title">学分</span>
|
||||||
<span className="profile-card-achievement-info-item-text">
|
<span className="profile-card-achievement-info-item-text">
|
||||||
{profile?.badges?.credits || 0}
|
{studentInfo?.totalCredits || 0}
|
||||||
</span>
|
</span>
|
||||||
</li>
|
</li>
|
||||||
<li className="profile-card-achievement-info-item">
|
<li className="profile-card-achievement-info-item">
|
||||||
@@ -84,13 +35,13 @@ const ProfileCard = () => {
|
|||||||
班级排名
|
班级排名
|
||||||
</span>
|
</span>
|
||||||
<span className="profile-card-achievement-info-item-text">
|
<span className="profile-card-achievement-info-item-text">
|
||||||
{profile?.badges?.classRank || '-'}
|
{studentInfo?.badges?.classRank || "-"}
|
||||||
</span>
|
</span>
|
||||||
</li>
|
</li>
|
||||||
<li className="profile-card-achievement-info-item">
|
<li className="profile-card-achievement-info-item">
|
||||||
<span className="profile-card-achievement-info-item-title">MBTI</span>
|
<span className="profile-card-achievement-info-item-title">MBTI</span>
|
||||||
<span className="profile-card-achievement-info-item-text">
|
<span className="profile-card-achievement-info-item-text">
|
||||||
{profile?.badges?.mbti || '-'}
|
{studentInfo?.mbtiType || "-"}
|
||||||
</span>
|
</span>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
@@ -99,30 +50,28 @@ const ProfileCard = () => {
|
|||||||
<i className="profile-card-class-info-item-icon icon-school" />
|
<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-title">学校</span>
|
||||||
<span className="profile-card-class-info-item-text">
|
<span className="profile-card-class-info-item-text">
|
||||||
{profile?.school || '-'}
|
{studentInfo?.school || "-"}
|
||||||
</span>
|
</span>
|
||||||
</li>
|
</li>
|
||||||
<li className="profile-card-class-info-item">
|
<li className="profile-card-class-info-item">
|
||||||
<i className="profile-card-class-info-item-icon icon-major" />
|
<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-title">专业</span>
|
||||||
<span className="profile-card-class-info-item-text">
|
<span className="profile-card-class-info-item-text">
|
||||||
{profile?.major || '-'}
|
{studentInfo?.major || "-"}
|
||||||
</span>
|
</span>
|
||||||
</li>
|
</li>
|
||||||
<li className="profile-card-class-info-item">
|
<li className="profile-card-class-info-item">
|
||||||
<i className="profile-card-class-info-item-icon icon-location" />
|
<i className="profile-card-class-info-item-icon icon-location" />
|
||||||
<span className="profile-card-class-info-item-title">
|
<span className="profile-card-class-info-item-title">班级</span>
|
||||||
班级
|
|
||||||
</span>
|
|
||||||
<span className="profile-card-class-info-item-text">
|
<span className="profile-card-class-info-item-text">
|
||||||
{profile?.className || '-'}
|
{studentInfo?.className || "-"}
|
||||||
</span>
|
</span>
|
||||||
</li>
|
</li>
|
||||||
<li className="profile-card-class-info-item">
|
<li className="profile-card-class-info-item">
|
||||||
<i className="profile-card-class-info-item-icon icon-course" />
|
<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-title">学习阶段</span>
|
||||||
<span className="profile-card-class-info-item-text">
|
<span className="profile-card-class-info-item-text">
|
||||||
{profile?.stageName || '-'}
|
{studentInfo?.stageName || "-"}
|
||||||
</span>
|
</span>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|||||||
@@ -1,7 +1,10 @@
|
|||||||
import * as echarts from "echarts";
|
import * as echarts from "echarts";
|
||||||
|
import { useState, useEffect } from "react";
|
||||||
|
import { useSelector } from "react-redux";
|
||||||
import StudyProgress from "../StudyProgress";
|
import StudyProgress from "../StudyProgress";
|
||||||
import ScoreRingChart from "../ScoreRingChart";
|
import ScoreRingChart from "../ScoreRingChart";
|
||||||
import AttendanceRingChart from "../AttendanceRingChart";
|
import AttendanceRingChart from "../AttendanceRingChart";
|
||||||
|
import { getLoginStudentProgress } from "@/services";
|
||||||
import "./index.css";
|
import "./index.css";
|
||||||
|
|
||||||
const ringData = [
|
const ringData = [
|
||||||
@@ -49,6 +52,21 @@ const attendanceData = [
|
|||||||
];
|
];
|
||||||
|
|
||||||
const StudyStudes = () => {
|
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 (
|
return (
|
||||||
<div className="study-studes-card-wrapper">
|
<div className="study-studes-card-wrapper">
|
||||||
<p className="study-studes-card-title">学习情况</p>
|
<p className="study-studes-card-title">学习情况</p>
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import request from "@/utils/request";
|
import request from "@/utils/request";
|
||||||
|
|
||||||
// 获取学生信息
|
// 获取当前登录学生信息
|
||||||
export async function getCurrentStudent() {
|
export async function getLoginStudentInfo() {
|
||||||
return request.get("/api/students/me");
|
return request.get("/api/students/me");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,8 @@ import {
|
|||||||
} from "./dashboard";
|
} from "./dashboard";
|
||||||
import { getProjectsList } from "./projectLibrary";
|
import { getProjectsList } from "./projectLibrary";
|
||||||
import { getJobsList, getInterviewsList } from "./companyJobs";
|
import { getJobsList, getInterviewsList } from "./companyJobs";
|
||||||
import { getCurrentStudent } from "./global";
|
import { getLoginStudentInfo } from "./global";
|
||||||
|
import { getLoginStudentProgress } from "./personalProfile";
|
||||||
|
|
||||||
export {
|
export {
|
||||||
getDashboardStatistics,
|
getDashboardStatistics,
|
||||||
@@ -14,5 +15,6 @@ export {
|
|||||||
getProjectsList,
|
getProjectsList,
|
||||||
getJobsList,
|
getJobsList,
|
||||||
getInterviewsList,
|
getInterviewsList,
|
||||||
getCurrentStudent,
|
getLoginStudentInfo,
|
||||||
|
getLoginStudentProgress,
|
||||||
};
|
};
|
||||||
|
|||||||
6
src/services/personalProfile.js
Normal file
6
src/services/personalProfile.js
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
import request from "@/utils/request";
|
||||||
|
|
||||||
|
// 获取当前登录学生学习进度
|
||||||
|
export async function getLoginStudentProgress(id) {
|
||||||
|
return request.get(`/api/students/${id}/progress`);
|
||||||
|
}
|
||||||
@@ -1,10 +1,10 @@
|
|||||||
import { configureStore } from '@reduxjs/toolkit';
|
import { configureStore } from "@reduxjs/toolkit";
|
||||||
import loadingReducer from './slices/loadingSlice';
|
import loadingReducer from "./slices/loadingSlice";
|
||||||
import userReducer from './slices/userSlice'; // 导入新的用户reducer
|
import studentReducer from "./slices/studentSlice";
|
||||||
|
|
||||||
export default configureStore({
|
export default configureStore({
|
||||||
reducer: {
|
reducer: {
|
||||||
loading: loadingReducer,
|
loading: loadingReducer,
|
||||||
user: userReducer // 添加用户reducer到store
|
student: studentReducer,
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
|
|||||||
39
src/store/slices/studentSlice.js
Normal file
39
src/store/slices/studentSlice.js
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
import { createSlice } from "@reduxjs/toolkit";
|
||||||
|
|
||||||
|
// 定义初始状态
|
||||||
|
const initialState = {
|
||||||
|
studentInfo: null, // 用户信息初始为null
|
||||||
|
isLoggedIn: false, // 登录状态初始为false
|
||||||
|
};
|
||||||
|
|
||||||
|
const studentSlice = createSlice({
|
||||||
|
name: "student",
|
||||||
|
initialState,
|
||||||
|
reducers: {
|
||||||
|
// 设置用户信息
|
||||||
|
setStudentInfo: (state, action) => {
|
||||||
|
state.studentInfo = action.payload;
|
||||||
|
state.isLoggedIn = true;
|
||||||
|
},
|
||||||
|
// 清除用户信息
|
||||||
|
clearStudentInfo: (state) => {
|
||||||
|
state.studentInfo = null;
|
||||||
|
state.isLoggedIn = false;
|
||||||
|
},
|
||||||
|
// 更新用户信息的部分字段
|
||||||
|
updateStudentInfo: (state, action) => {
|
||||||
|
if (state.studentInfo) {
|
||||||
|
state.studentInfo = {
|
||||||
|
...state.studentInfo,
|
||||||
|
...action.payload,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
// 导出actions
|
||||||
|
export const { setStudentInfo, clearStudentInfo, updateStudentInfo } =
|
||||||
|
studentSlice.actions;
|
||||||
|
|
||||||
|
export default studentSlice.reducer;
|
||||||
@@ -1,38 +0,0 @@
|
|||||||
import { createSlice } from '@reduxjs/toolkit';
|
|
||||||
|
|
||||||
// 定义初始状态
|
|
||||||
const initialState = {
|
|
||||||
userInfo: null, // 用户信息初始为null
|
|
||||||
isLoggedIn: false // 登录状态初始为false
|
|
||||||
};
|
|
||||||
|
|
||||||
const userSlice = createSlice({
|
|
||||||
name: 'user',
|
|
||||||
initialState,
|
|
||||||
reducers: {
|
|
||||||
// 设置用户信息
|
|
||||||
setUserInfo: (state, action) => {
|
|
||||||
state.userInfo = action.payload;
|
|
||||||
state.isLoggedIn = true;
|
|
||||||
},
|
|
||||||
// 清除用户信息
|
|
||||||
clearUserInfo: (state) => {
|
|
||||||
state.userInfo = null;
|
|
||||||
state.isLoggedIn = false;
|
|
||||||
},
|
|
||||||
// 更新用户信息的部分字段
|
|
||||||
updateUserInfo: (state, action) => {
|
|
||||||
if (state.userInfo) {
|
|
||||||
state.userInfo = {
|
|
||||||
...state.userInfo,
|
|
||||||
...action.payload
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// 导出actions
|
|
||||||
export const { setUserInfo, clearUserInfo, updateUserInfo } = userSlice.actions;
|
|
||||||
|
|
||||||
export default userSlice.reducer;
|
|
||||||
Reference in New Issue
Block a user