From 6048dd7610199e50cb9bd7256d2c1c08bca843e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8C=97=E6=9E=B3?= <7854742+wang_rumeng@user.noreply.gitee.com> Date: Mon, 22 Sep 2025 21:18:04 +0800 Subject: [PATCH] =?UTF-8?q?=E5=85=BC=E5=AE=B9=20=E7=AB=96=E5=B1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .env.development | 2 +- api/script_episode.ts | 2 + components/ChatInputBox/ChatInputBox.tsx | 8 +- .../ChatInputBox/H5PhotoStoryDrawer.tsx | 6 +- components/ChatInputBox/H5TemplateDrawer.tsx | 6 +- components/ChatInputBox/PcPhotoStoryModal.tsx | 6 +- components/ChatInputBox/PcTemplateModal.tsx | 6 +- components/pages/create-to-video2.tsx | 116 +++++++----------- components/pages/work-flow.tsx | 4 +- components/pages/work-flow/thumbnail-grid.tsx | 4 +- 10 files changed, 70 insertions(+), 90 deletions(-) diff --git a/.env.development b/.env.development index e1bc4f8..e37d8cc 100644 --- a/.env.development +++ b/.env.development @@ -4,7 +4,7 @@ NEXT_PUBLIC_BASE_URL = https://77.smartvideo.py.qikongjian.com NEXT_PUBLIC_CUT_URL = https://77.smartcut.py.qikongjian.com # 失败率 -NEXT_PUBLIC_ERROR_CONFIG = 0.1 +NEXT_PUBLIC_ERROR_CONFIG = 0.5 # Google OAuth配置 NEXT_PUBLIC_GOOGLE_CLIENT_ID=847079918888-o1nne8d3ij80dn20qurivo987pv07225.apps.googleusercontent.com NEXT_PUBLIC_GOOGLE_REDIRECT_URI=https://www.movieflow.net/api/auth/google/callback diff --git a/api/script_episode.ts b/api/script_episode.ts index e450b27..cc074fc 100644 --- a/api/script_episode.ts +++ b/api/script_episode.ts @@ -1,6 +1,7 @@ import { post } from './request'; import { ApiResponse } from './common'; import { Character } from './video_flow'; +import { AspectRatioValue } from '@/components/ChatInputBox/AspectRatioSelector'; // 创建剧集的数据类型 export interface CreateScriptEpisodeRequest { @@ -78,6 +79,7 @@ interface MovieProject { last_message: string; updated_at: string; created_at: string; + aspect_ratio: AspectRatioValue; } interface ListMovieProjectsResponse { diff --git a/components/ChatInputBox/ChatInputBox.tsx b/components/ChatInputBox/ChatInputBox.tsx index b072bd2..04e9b39 100644 --- a/components/ChatInputBox/ChatInputBox.tsx +++ b/components/ChatInputBox/ChatInputBox.tsx @@ -469,15 +469,15 @@ export function ChatInputBox({ noData }: { noData: boolean }) { {/* 分隔线(移动端隐藏,避免拥挤) */} - {/*
*/} +
- {/* 横/竖屏选择 上线暂时不开放 */} - {/* onConfigChange('aspect_ratio', v)} placement="top" className={`${isMobile ? '!px-1' : ''}`} - /> */} + /> {/* 右侧Action按钮 */} diff --git a/components/ChatInputBox/H5PhotoStoryDrawer.tsx b/components/ChatInputBox/H5PhotoStoryDrawer.tsx index 481f1f3..b13e0d4 100644 --- a/components/ChatInputBox/H5PhotoStoryDrawer.tsx +++ b/components/ChatInputBox/H5PhotoStoryDrawer.tsx @@ -359,12 +359,12 @@ export const H5PhotoStoryDrawer = ({
- {/* 横/竖屏选择 上线暂时不开放 */} - {/* */} + /> {!hasAnalyzed ? (
diff --git a/components/ChatInputBox/H5TemplateDrawer.tsx b/components/ChatInputBox/H5TemplateDrawer.tsx index 394951e..562b406 100644 --- a/components/ChatInputBox/H5TemplateDrawer.tsx +++ b/components/ChatInputBox/H5TemplateDrawer.tsx @@ -556,12 +556,12 @@ export const H5TemplateDrawer = ({ />
)} - {/* 横/竖屏选择 上线暂时不开放 */} - {/* */} + /> 0} handleCreateVideo={handleConfirm} diff --git a/components/ChatInputBox/PcPhotoStoryModal.tsx b/components/ChatInputBox/PcPhotoStoryModal.tsx index 0f139a1..989fd08 100644 --- a/components/ChatInputBox/PcPhotoStoryModal.tsx +++ b/components/ChatInputBox/PcPhotoStoryModal.tsx @@ -321,12 +321,12 @@ export const PcPhotoStoryModal = ({ placeholder="Share your creative ideas about the image and let AI create a movie story for you..." />
- {/* 横/竖屏选择 上线暂时不开放 */} - {/* */} + /> {!hasAnalyzed ? (
)} - {/* 横/竖屏选择 上线暂时不开放 */} - {/* */} + /> 0} handleCreateVideo={handleConfirm} diff --git a/components/pages/create-to-video2.tsx b/components/pages/create-to-video2.tsx index 3248416..9635982 100644 --- a/components/pages/create-to-video2.tsx +++ b/components/pages/create-to-video2.tsx @@ -29,8 +29,6 @@ export default function CreateToVideo2() { const scrollContainerRef = useRef(null); const [userId, setUserId] = useState(0); const [isLoadingDownloadBtn, setIsLoadingDownloadBtn] = useState(false); - /** 保存每个项目的视频朝向 */ - const [orientationMap, setOrientationMap] = useState>({}); // 添加一个 ref 来跟踪当前正在加载的页码 const loadingPageRef = useRef(null); @@ -38,14 +36,46 @@ export default function CreateToVideo2() { // 在客户端挂载后读取localStorage // 监听滚动事件,实现无限加载 // 修改滚动处理函数,添加节流 - // 修改获取剧集列表函数(提前定义,供滚动与初始化调用) - const getEpisodeList = useCallback(async (userId: number, page: number = 1, loadMore: boolean = false) => { + const handleScroll = useCallback(() => { + if (!scrollContainerRef.current || !hasMore || isLoadingMore || isLoading) return; + + const { scrollTop, scrollHeight, clientHeight } = scrollContainerRef.current; + if (scrollHeight - scrollTop - clientHeight < 100) { + // 直接使用 currentPage,不再使用 setCurrentPage 的回调 + const nextPage = currentPage + 1; + if (nextPage <= totalPages) { + getEpisodeList(userId, nextPage, true); + } + } + }, [hasMore, isLoadingMore, isLoading, totalPages, userId, currentPage]); + + useEffect(() => { + if (typeof window !== 'undefined') { + const currentUser = JSON.parse(localStorage.getItem('currentUser') || '{}'); + console.log('currentUser', currentUser); + setUserId(currentUser.id); + getEpisodeList(currentUser.id, 1, false); + } + }, []); + + // 添加滚动监听 + useEffect(() => { + const scrollContainer = scrollContainerRef.current; + if (scrollContainer) { + scrollContainer.addEventListener('scroll', handleScroll); + return () => scrollContainer.removeEventListener('scroll', handleScroll); + } + }, [handleScroll]); + + // 修改获取剧集列表函数 + const getEpisodeList = async (userId: number, page: number = 1, loadMore: boolean = false) => { // 检查是否正在加载该页 if (loadingPageRef.current === page) return; - + if (isLoading || (isLoadingMore && !loadMore)) return; + // 设置当前正在加载的页码 loadingPageRef.current = page; - + if (loadMore) { setIsLoadingMore(true); } else { @@ -63,7 +93,7 @@ export default function CreateToVideo2() { if (episodeListResponse.code === 0) { const { movie_projects, total_pages } = episodeListResponse.data; - + // 确保数据不重复 if (loadMore) { setEpisodeList(prev => { @@ -75,7 +105,7 @@ export default function CreateToVideo2() { } else { setEpisodeList(movie_projects); } - + setTotalPages(total_pages); setHasMore(page < total_pages); setCurrentPage(page); @@ -89,39 +119,7 @@ export default function CreateToVideo2() { // 清除当前加载页码 loadingPageRef.current = null; } - }, [perPage]); - const handleScroll = useCallback(() => { - if (!scrollContainerRef.current || !hasMore || isLoadingMore || isLoading) return; - - const { scrollTop, scrollHeight, clientHeight } = scrollContainerRef.current; - if (scrollHeight - scrollTop - clientHeight < 100) { - // 直接使用 currentPage,不再使用 setCurrentPage 的回调 - const nextPage = currentPage + 1; - if (nextPage <= totalPages) { - getEpisodeList(userId, nextPage, true); - } - } - }, [hasMore, isLoadingMore, isLoading, totalPages, userId, currentPage, getEpisodeList]); - - useEffect(() => { - if (typeof window !== 'undefined') { - const currentUser = JSON.parse(localStorage.getItem('currentUser') || '{}'); - console.log('currentUser', currentUser); - setUserId(currentUser.id); - getEpisodeList(currentUser.id, 1, false); - } - }, [getEpisodeList]); - - // 添加滚动监听 - useEffect(() => { - const scrollContainer = scrollContainerRef.current; - if (scrollContainer) { - scrollContainer.addEventListener('scroll', handleScroll); - return () => scrollContainer.removeEventListener('scroll', handleScroll); - } - }, [handleScroll]); - - // 原函数位置已上移 + }; // 视频上传和创建功能已迁移到ChatInputBox组件中 @@ -190,55 +188,35 @@ export default function CreateToVideo2() { } }; - /** - * 根据元数据记录视频朝向(横/竖) - * @param {string} projectId - 项目唯一标识 - * @param {HTMLVideoElement} videoEl - 视频元素 - */ - const handleVideoMetadata = (projectId: string, videoEl: HTMLVideoElement) => { - const { videoWidth, videoHeight } = videoEl; - if (!videoWidth || !videoHeight) return; - setOrientationMap((prev) => { - if (prev[projectId]) return prev; - const next = videoWidth >= videoHeight ? 'landscape' : 'portrait'; - return { ...prev, [projectId]: next }; - }); - }; - const renderProjectCard = (project: any) => { return (
handleMouseEnter(project.project_id)} onMouseLeave={() => handleMouseLeave(project.project_id)} data-alt="project-card" > - {/* 视频/图片区域 */} -
router.push(`/movies/work-flow?episodeId=${project.project_id}`)} - data-alt="media-container" - > + {/* 视频/图片区域 */} +
router.push(`/movies/work-flow?episodeId=${project.project_id}`)}> {(project.final_video_url || project.final_simple_video_url || project.video_urls) ? (
@@ -304,7 +282,7 @@ export default function CreateToVideo2() { {episodeList.length > 0 && ( /* 优化的剧集网格 */
-
+
{episodeList.map(renderProjectCard)}
diff --git a/components/pages/work-flow.tsx b/components/pages/work-flow.tsx index 298c99e..6c2ecb9 100644 --- a/components/pages/work-flow.tsx +++ b/components/pages/work-flow.tsx @@ -624,7 +624,7 @@ Please process this video editing request.`;
{/* 智能对话弹窗 */} - {/* - */} + !isDragging && !disabled && onSketchSelect(index)} > @@ -276,7 +276,7 @@ export function ThumbnailGrid({ key={sketch.uniqueId || `sketch-${sketch.url}-${index}`} className={`relative aspect-auto rounded-lg overflow-hidden ${currentSketchIndex === index ? 'ring-2 ring-blue-500 z-10' : 'hover:ring-2 hover:ring-blue-500/50'} - ${aspectRatio === 'VIDEO_ASPECT_RATIO_LANDSCAPE' ? 'min-w-[200px]' : 'min-w-[70px]'} + ${aspectRatio === 'VIDEO_ASPECT_RATIO_LANDSCAPE' ? 'min-w-[210px]' : 'min-w-[70px]'} `} onClick={() => !isDragging && onSketchSelect(index)} >