forked from wangziqi/gongxue-base
33 lines
981 B
TypeScript
33 lines
981 B
TypeScript
import { apiRequest } from './api';
|
|
|
|
export interface ContentEntry {
|
|
id: string;
|
|
name: string;
|
|
entryType?: string;
|
|
route?: string;
|
|
icon?: string;
|
|
sortOrder?: number;
|
|
}
|
|
|
|
export interface DashboardSnapshot {
|
|
entries: ContentEntry[];
|
|
banners: unknown[];
|
|
announcements: unknown[];
|
|
profile: unknown | null;
|
|
}
|
|
|
|
export async function loadStudentDashboard(regionId?: string): Promise<DashboardSnapshot> {
|
|
const [entries, banners, announcements, profile] = await Promise.all([
|
|
apiRequest<{ items?: ContentEntry[] }>('/api/catalog/content-entries', { query: { regionId } }),
|
|
apiRequest<{ items?: unknown[] }>('/api/catalog/banners'),
|
|
apiRequest<{ items?: unknown[] }>('/api/catalog/announcements'),
|
|
apiRequest<{ item?: unknown }>('/api/profile/me').catch(() => ({ item: null })),
|
|
]);
|
|
return {
|
|
entries: entries.items || [],
|
|
banners: banners.items || [],
|
|
announcements: announcements.items || [],
|
|
profile: profile.item || null,
|
|
};
|
|
}
|