forked from wangziqi/gongxue-base
feat: scaffold taro h5 frontends
This commit is contained in:
32
apps/taro/src/services/catalog.ts
Normal file
32
apps/taro/src/services/catalog.ts
Normal file
@@ -0,0 +1,32 @@
|
||||
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,
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user