diff --git a/src/api/modules/resource.ts b/src/api/modules/resource.ts new file mode 100644 index 0000000..c3bafef --- /dev/null +++ b/src/api/modules/resource.ts @@ -0,0 +1,88 @@ +// 精选资源相关API +import { ApiRequest } from '../request' +import type { ApiResponseWithResult } from '../types' + +// 精选资源数据类型 +export interface FeaturedResource { + id: string + name: string + description: string + type: number // 0: 视频, 1: 图片 + fileUrl: string + thumbnailUrl: string + duration: number | null + fileSize: number + metadata: string | null + izFeatured: number + status: number + createdBy: string | null + createdTime: string | null + updatedBy: string | null + updatedTime: string | null +} + +// 精选资源API类 +export class ResourceApi { + /** + * 获取精选资源列表 + */ + static async getFeaturedResources(): Promise> { + try { + console.log('🚀 获取精选资源列表') + + const response = await ApiRequest.get('/aiol/aiolResource/feature') + + console.log('✅ 精选资源响应:', response) + console.log('✅ 响应数据结构:', response.data) + + // 适配实际的响应格式 + if (response.data && response.data.success && response.data.code === 200) { + return { + code: response.data.code, + message: response.data.message, + data: { + result: response.data.result + } + } + } else { + throw new Error(response.data?.message || '获取精选资源失败') + } + } catch (error) { + console.error('❌ 获取精选资源失败:', error) + throw error + } + } + + /** + * 根据类型筛选精选资源 + * @param type 资源类型 0: 视频, 1: 图片 + */ + static async getFeaturedResourcesByType(type?: number): Promise> { + try { + console.log('🚀 根据类型获取精选资源:', { type }) + + const params = type !== undefined ? { type } : {} + const response = await ApiRequest.get('/aiol/aiolResource/feature', params) + + console.log('✅ 按类型筛选精选资源响应:', response) + + // 适配实际的响应格式 + if (response.data && response.data.success && response.data.code === 200) { + return { + code: response.data.code, + message: response.data.message, + data: { + result: response.data.result + } + } + } else { + throw new Error(response.data?.message || '按类型获取精选资源失败') + } + } catch (error) { + console.error('❌ 按类型获取精选资源失败:', error) + throw error + } + } +} + +export default ResourceApi diff --git a/src/views/ResourceTest.vue b/src/views/ResourceTest.vue new file mode 100644 index 0000000..505b35d --- /dev/null +++ b/src/views/ResourceTest.vue @@ -0,0 +1,190 @@ + + + + +