2026-02-28 16:41:39 +08:00
|
|
|
import { http } from './index';
|
|
|
|
|
|
|
|
|
|
export interface Theme {
|
|
|
|
|
id: number;
|
|
|
|
|
name: string;
|
|
|
|
|
description?: string;
|
|
|
|
|
sortOrder: number;
|
|
|
|
|
status: string;
|
|
|
|
|
createdAt: string;
|
|
|
|
|
courses?: {
|
|
|
|
|
id: number;
|
|
|
|
|
name: string;
|
|
|
|
|
coverImagePath?: string;
|
|
|
|
|
}[];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export interface CreateThemeData {
|
|
|
|
|
name: string;
|
|
|
|
|
description?: string;
|
|
|
|
|
sortOrder?: number;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export interface UpdateThemeData {
|
|
|
|
|
name?: string;
|
|
|
|
|
description?: string;
|
|
|
|
|
sortOrder?: number;
|
|
|
|
|
status?: string;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 获取主题列表
|
|
|
|
|
export function getThemeList() {
|
2026-03-13 14:13:46 +08:00
|
|
|
return http.get('/v1/admin/themes');
|
2026-02-28 16:41:39 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 获取主题详情
|
|
|
|
|
export function getThemeDetail(id: number) {
|
2026-03-13 14:13:46 +08:00
|
|
|
return http.get(`/v1/admin/themes/${id}`);
|
2026-02-28 16:41:39 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 创建主题
|
|
|
|
|
export function createTheme(data: CreateThemeData) {
|
2026-03-13 14:13:46 +08:00
|
|
|
return http.post('/v1/admin/themes', data);
|
2026-02-28 16:41:39 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 更新主题
|
|
|
|
|
export function updateTheme(id: number, data: UpdateThemeData) {
|
2026-03-13 14:13:46 +08:00
|
|
|
return http.put(`/v1/admin/themes/${id}`, data);
|
2026-02-28 16:41:39 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 删除主题
|
|
|
|
|
export function deleteTheme(id: number) {
|
2026-03-13 14:13:46 +08:00
|
|
|
return http.delete(`/v1/admin/themes/${id}`);
|
2026-02-28 16:41:39 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 重新排序主题
|
|
|
|
|
export function reorderThemes(ids: number[]) {
|
2026-03-13 14:13:46 +08:00
|
|
|
return http.put('/v1/admin/themes/reorder', { ids });
|
2026-02-28 16:41:39 +08:00
|
|
|
}
|