实现快传,完善快传和网盘的功能,实现文件的互传等一系列功能

This commit is contained in:
yoyuzh
2026-03-20 14:16:18 +08:00
parent 944ab6dbf8
commit 43358e29d7
109 changed files with 5237 additions and 2465 deletions

View File

@@ -1,6 +1,5 @@
import FolderOutlined from '@mui/icons-material/FolderOutlined';
import GroupsOutlined from '@mui/icons-material/GroupsOutlined';
import SchoolOutlined from '@mui/icons-material/SchoolOutlined';
import { Admin, Resource } from 'react-admin';
import { portalAdminAuthProvider } from './auth-provider';
@@ -8,7 +7,6 @@ import { portalAdminDataProvider } from './data-provider';
import { PortalAdminDashboard } from './dashboard';
import { PortalAdminFilesList } from './files-list';
import { PortalAdminUsersList } from './users-list';
import { PortalAdminSchoolSnapshotsList } from './school-snapshots-list';
export default function PortalAdminApp() {
return (
@@ -35,13 +33,6 @@ export default function PortalAdminApp() {
options={{ label: '文件资源' }}
recordRepresentation="filename"
/>
<Resource
name="schoolSnapshots"
icon={SchoolOutlined}
list={PortalAdminSchoolSnapshotsList}
options={{ label: '教务缓存' }}
recordRepresentation="username"
/>
</Admin>
);
}

View File

@@ -17,12 +17,12 @@ const DASHBOARD_ITEMS = [
},
{
title: '用户管理',
description: '已接入 /api/admin/users可查看用户、邮箱与最近教务缓存标记。',
description: '已接入 /api/admin/users可查看账号、邮箱、手机号与权限状态。',
status: 'connected',
},
{
title: '教务快照',
description: '已接入 /api/admin/school-snapshots可查看最近学号、学期和缓存条数。',
title: '门户运营',
description: '当前后台专注于统一账号和文件资源,保持管理视图聚焦在核心门户能力上。',
status: 'connected',
},
];
@@ -147,9 +147,6 @@ export function PortalAdminDashboard() {
<Typography color="text.secondary">
{state.summary?.totalFiles ?? 0}
</Typography>
<Typography color="text.secondary">
{state.summary?.usersWithSchoolCache ?? 0}
</Typography>
</Stack>
</CardContent>
</Card>

View File

@@ -76,17 +76,6 @@ test('buildAdminListPath maps generic admin resources to backend paging queries'
}),
'/admin/users?page=1&size=20',
);
assert.equal(
buildAdminListPath('schoolSnapshots', {
pagination: {
page: 1,
perPage: 50,
},
filter: {},
}),
'/admin/school-snapshots?page=0&size=50',
);
});
test('buildAdminListPath includes the user search query when present', () => {
@@ -103,3 +92,17 @@ test('buildAdminListPath includes the user search query when present', () => {
'/admin/users?page=0&size=25&query=alice',
);
});
test('buildAdminListPath rejects the removed school snapshots resource', () => {
assert.throws(
() =>
buildAdminListPath('schoolSnapshots', {
pagination: {
page: 1,
perPage: 50,
},
filter: {},
}),
/schoolSnapshots/,
);
});

View File

@@ -3,21 +3,19 @@ import type { DataProvider, GetListParams, GetListResult, Identifier } from 'rea
import { apiRequest } from '@/src/lib/api';
import type {
AdminFile,
AdminSchoolSnapshot,
AdminUser,
PageResponse,
} from '@/src/lib/types';
const FILES_RESOURCE = 'files';
const USERS_RESOURCE = 'users';
const SCHOOL_SNAPSHOTS_RESOURCE = 'schoolSnapshots';
function createUnsupportedError(resource: string, action: string) {
return new Error(`当前管理台暂未为资源 "${resource}" 实现 ${action} 操作`);
}
function ensureSupportedResource(resource: string, action: string) {
if (![FILES_RESOURCE, USERS_RESOURCE, SCHOOL_SNAPSHOTS_RESOURCE].includes(resource)) {
if (![FILES_RESOURCE, USERS_RESOURCE].includes(resource)) {
throw createUnsupportedError(resource, action);
}
}
@@ -35,10 +33,6 @@ export function buildAdminListPath(resource: string, params: Pick<GetListParams,
return `/admin/users?page=${page}&size=${size}${query ? `&query=${encodeURIComponent(query)}` : ''}`;
}
if (resource === SCHOOL_SNAPSHOTS_RESOURCE) {
return `/admin/school-snapshots?page=${page}&size=${size}`;
}
throw createUnsupportedError(resource, 'list');
}
@@ -92,11 +86,7 @@ export const portalAdminDataProvider: DataProvider = {
} as GetListResult;
}
const payload = await apiRequest<PageResponse<AdminSchoolSnapshot>>(buildAdminListPath(resource, params));
return {
data: payload.items,
total: payload.total,
} as GetListResult;
throw createUnsupportedError(resource, 'list');
},
getOne: async (resource) => {
ensureSupportedResource(resource, 'getOne');

View File

@@ -1,22 +0,0 @@
import { Datagrid, List, NumberField, TextField } from 'react-admin';
export function PortalAdminSchoolSnapshotsList() {
return (
<List
perPage={25}
resource="schoolSnapshots"
title="教务缓存"
sort={{ field: 'id', order: 'DESC' }}
>
<Datagrid bulkActionButtons={false} rowClick={false}>
<TextField source="userId" label="用户 ID" />
<TextField source="username" label="用户名" />
<TextField source="email" label="邮箱" />
<TextField source="studentId" label="学号" emptyText="-" />
<TextField source="semester" label="学期" emptyText="-" />
<NumberField source="scheduleCount" label="课表数" />
<NumberField source="gradeCount" label="成绩数" />
</Datagrid>
</List>
);
}

View File

@@ -177,8 +177,6 @@ export function PortalAdminUsersList() {
/>
)}
/>
<TextField source="lastSchoolStudentId" label="最近学号" emptyText="-" />
<TextField source="lastSchoolSemester" label="最近学期" emptyText="-" />
<DateField source="createdAt" label="创建时间" showTime />
<FunctionField<AdminUser> label="操作" render={(record) => <AdminUserActions record={record} />} />
</Datagrid>