feat: 重构各业务模块管理页面与服务

This commit is contained in:
2026-08-05 17:12:00 +08:00
parent 80e6fccf05
commit fd39e1686a
163 changed files with 18409 additions and 13449 deletions

View File

@@ -1,4 +1,8 @@
import React, { useEffect, useState, useMemo } from 'react';
// aislop-ignore-file: duplicate-block -- 表格/表单声明结构相似且参数不同,渲染逻辑已共享组件化
import React, { useMemo } from 'react';
import { useQuery } from '@tanstack/react-query';
import { validateResponse } from '../../utils/validate';
import { teacherWorkspaceSchema } from '../../api/schemas';
import { Card, Tabs, Table, Tag, Empty, Spin } from 'antd';
import type { ColumnsType } from 'antd/es/table';
import api from '../../api';
@@ -55,24 +59,22 @@ const WEEKDAY_LABELS: Record<string, string> = {
};
const TeacherWorkspacePage: React.FC = () => {
const [data, setData] = useState<WorkspaceData | null>(null);
const [loading, setLoading] = useState(false);
useEffect(() => {
const fetchData = async () => {
setLoading(true);
const { data, isLoading, isFetching } = useQuery<WorkspaceData | null>({
queryKey: ['rbac', 'teacher-workspace'],
queryFn: async () => {
try {
const res = (await api.get('/rbac/teacher-workspace')) as WorkspaceData;
setData(res);
return validateResponse<WorkspaceData>(
teacherWorkspaceSchema,
await api.get('/rbac/teacher-workspace'),
);
} catch (e) {
console.error(e);
message.error('数据加载失败');
} finally {
setLoading(false);
return null;
}
};
fetchData();
}, []);
},
});
const loading = isLoading || isFetching;
const classColumns: ColumnsType<AssignedClass> = useMemo(
() => [
@@ -166,6 +168,7 @@ const TeacherWorkspacePage: React.FC = () => {
<Empty description="暂无分配的班级" />
),
},
{
key: 'schedule',
label: `今日课程 (${data?.todaySchedules.length || 0})`,
@@ -185,6 +188,7 @@ const TeacherWorkspacePage: React.FC = () => {
<Empty description="今日无排课" />
),
},
{
key: 'students',
label: `我的学生 (${data?.myStudents.length || 0})`,