forked from 77media/video-flow
是对接
This commit is contained in:
parent
2ee662dc18
commit
f6018e7f46
23
api/resources.ts
Normal file
23
api/resources.ts
Normal 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);
|
||||
};
|
||||
@ -1,6 +1,6 @@
|
||||
"use client";
|
||||
|
||||
import { useState, useRef } from "react";
|
||||
import { useState, useRef, useEffect } from "react";
|
||||
import { Plus, Table, AlignHorizontalSpaceAround, Loader2 } from "lucide-react";
|
||||
import "./style/home-page2.css";
|
||||
import { useRouter } from "next/navigation";
|
||||
@ -16,16 +16,48 @@ import {
|
||||
ModeEnum,
|
||||
ResolutionEnum
|
||||
} from '@/api/enums';
|
||||
import {
|
||||
getResourcesList,
|
||||
Resource
|
||||
} from '@/api/resources';
|
||||
|
||||
export function HomePage2() {
|
||||
const router = useRouter();
|
||||
const [activeTool, setActiveTool] = useState("stretch");
|
||||
const [isCreating, setIsCreating] = useState(false);
|
||||
const [createdProjectId, setCreatedProjectId] = useState<number | null>(null);
|
||||
const [resources, setResources] = useState<Resource[]>([]);
|
||||
const [isLoadingResources, setIsLoadingResources] = useState(false);
|
||||
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) => {
|
||||
|
||||
@ -10,6 +10,10 @@ const nextConfig = {
|
||||
source: '/api/proxy/:path*',
|
||||
destination: 'https://77.smartvideo.py.qikongjian.com/:path*',
|
||||
},
|
||||
{
|
||||
source: '/api/resources/:path*',
|
||||
destination: 'https://movieflow.api.huiying.video/:path*',
|
||||
},
|
||||
];
|
||||
},
|
||||
};
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user