是对接

This commit is contained in:
Xin Wang 2025-07-02 21:12:28 +08:00
parent 2ee662dc18
commit f6018e7f46
3 changed files with 62 additions and 3 deletions

23
api/resources.ts Normal file
View File

@ -0,0 +1,23 @@
import { post } from './request';
import { ApiResponse } from './common';
// 资源列表请求参数
export interface ResourcesListRequest {
published: number;
}
// 资源项数据结构
export interface Resource {
id: number;
title: string;
creator_name: string;
media_type: number;
url: string;
script_id: number;
created_at: string;
}
// 获取资源列表
export const getResourcesList = async (data: ResourcesListRequest): Promise<ApiResponse<Resource[]>> => {
return post<ApiResponse<Resource[]>>('/api/resources/resources/list', data);
};

View File

@ -1,6 +1,6 @@
"use client"; "use client";
import { useState, useRef } from "react"; import { useState, useRef, useEffect } from "react";
import { Plus, Table, AlignHorizontalSpaceAround, Loader2 } from "lucide-react"; import { Plus, Table, AlignHorizontalSpaceAround, Loader2 } from "lucide-react";
import "./style/home-page2.css"; import "./style/home-page2.css";
import { useRouter } from "next/navigation"; import { useRouter } from "next/navigation";
@ -16,16 +16,48 @@ import {
ModeEnum, ModeEnum,
ResolutionEnum ResolutionEnum
} from '@/api/enums'; } from '@/api/enums';
import {
getResourcesList,
Resource
} from '@/api/resources';
export function HomePage2() { export function HomePage2() {
const router = useRouter(); const router = useRouter();
const [activeTool, setActiveTool] = useState("stretch"); const [activeTool, setActiveTool] = useState("stretch");
const [isCreating, setIsCreating] = useState(false); const [isCreating, setIsCreating] = useState(false);
const [createdProjectId, setCreatedProjectId] = useState<number | null>(null); const [createdProjectId, setCreatedProjectId] = useState<number | null>(null);
const [resources, setResources] = useState<Resource[]>([]);
const [isLoadingResources, setIsLoadingResources] = useState(false);
const containerRef = useRef<HTMLDivElement>(null); const containerRef = useRef<HTMLDivElement>(null);
// 视频数据 // 将资源数据转换为视频格式
const videos: Array<{id: string; url: string; title: string}> = []; const videos = resources.map(resource => ({
id: resource.id.toString(),
url: resource.url,
title: resource.title
}));
// 获取资源列表
const fetchResources = async () => {
try {
setIsLoadingResources(true);
const response = await getResourcesList({ published: 1 });
if (response.code === 0 && response.successful) {
setResources(response.data);
} else {
console.error('获取资源列表失败:', response.message);
}
} catch (error) {
console.error('获取资源列表出错:', error);
} finally {
setIsLoadingResources(false);
}
};
// 组件挂载时获取资源
useEffect(() => {
fetchResources();
}, []);
// 处理编辑视频 // 处理编辑视频
const handleEdit = (id: string) => { const handleEdit = (id: string) => {

View File

@ -10,6 +10,10 @@ const nextConfig = {
source: '/api/proxy/:path*', source: '/api/proxy/:path*',
destination: 'https://77.smartvideo.py.qikongjian.com/:path*', destination: 'https://77.smartvideo.py.qikongjian.com/:path*',
}, },
{
source: '/api/resources/:path*',
destination: 'https://movieflow.api.huiying.video/:path*',
},
]; ];
}, },
}; };