From 392f29c7b6fa9efe7fab3c5c025922ef17d97bf3 Mon Sep 17 00:00:00 2001 From: moux1024 <403053463@qq.com> Date: Sun, 12 Oct 2025 00:14:32 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=20=E6=B0=B4=E5=8D=B0?= =?UTF-8?q?=E4=BC=A0=E5=8F=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/pages/create-to-video2.tsx | 2 +- components/pages/work-flow/H5MediaViewer.tsx | 4 +-- .../work-flow/download-options-modal.tsx | 31 +++++-------------- components/pages/work-flow/media-viewer.tsx | 16 +++++----- 4 files changed, 19 insertions(+), 34 deletions(-) diff --git a/components/pages/create-to-video2.tsx b/components/pages/create-to-video2.tsx index e4274a2..ff03a77 100644 --- a/components/pages/create-to-video2.tsx +++ b/components/pages/create-to-video2.tsx @@ -281,7 +281,7 @@ export default function CreateToVideo2() { try { const json: any = await post('/movie/download_video', { project_id: project.project_id, - watermark: !withWatermark + watermark: withWatermark }); const url = json?.data?.download_url as string | undefined; if (url) { diff --git a/components/pages/work-flow/H5MediaViewer.tsx b/components/pages/work-flow/H5MediaViewer.tsx index a2f6206..ec2cc51 100644 --- a/components/pages/work-flow/H5MediaViewer.tsx +++ b/components/pages/work-flow/H5MediaViewer.tsx @@ -484,7 +484,7 @@ export function H5MediaViewer({ const json: any = await post('/movie/download_video', { project_id: episodeId, video_id: current.video_id, - watermark: !withWatermark + watermark: withWatermark }); const url = json?.data?.download_url as string | undefined; if (url) await downloadVideo(url); @@ -531,7 +531,7 @@ export function H5MediaViewer({ onDownloadCurrent: async (withWatermark: boolean) => { const json: any = await post('/movie/download_video', { project_id: episodeId, - watermark: !withWatermark + watermark: withWatermark }); const url = json?.data?.download_url as string | undefined; if (url) await downloadVideo(url); diff --git a/components/pages/work-flow/download-options-modal.tsx b/components/pages/work-flow/download-options-modal.tsx index adf630f..eafa603 100644 --- a/components/pages/work-flow/download-options-modal.tsx +++ b/components/pages/work-flow/download-options-modal.tsx @@ -4,7 +4,7 @@ import React, { useEffect, useRef, useState } from 'react'; import { Checkbox } from 'antd'; import { createRoot, Root } from 'react-dom/client'; import { X, Download, ArrowDownWideNarrow } from 'lucide-react'; -import { baseUrl } from '@/lib/env'; +import { post } from '@/api/request'; interface DownloadOptionsModalProps { onDownloadCurrent: (withWatermark: boolean) => void; @@ -45,29 +45,12 @@ function DownloadOptionsModal(props: DownloadOptionsModalProps) { let aborted = false; const checkBalance = async () => { try { - if (!projectId) { - setBaseAmount(0); - return; - } - const token = typeof window !== 'undefined' ? (localStorage?.getItem('token') || '') : ''; - const res = await fetch(`${baseUrl}/movie/download_video`, { - method: 'POST', - headers: { - 'Content-Type': 'application/json', - ...(token ? { 'Authorization': `Bearer ${token}` } : {}) - }, - body: JSON.stringify({ - project_id: projectId, - video_id: videoId, - watermark: !withWatermark, - check_balance: true - }) + const json: any = await post('/movie/download_video', { + project_id: projectId, + video_id: videoId, + watermark: withWatermark, + check_balance: true }); - if (!res.ok) { - if (!aborted) setBaseAmount(0); - return; - } - const json = await res.json().catch(() => null); const amount = json?.data?.base_amount; if (!aborted) setBaseAmount(Number.isFinite(amount) ? Number(amount) : 0); } catch { @@ -116,7 +99,7 @@ function DownloadOptionsModal(props: DownloadOptionsModalProps) { Choose your download preference

- {baseAmount && baseAmount !== 0 ? ( + {!withWatermark && baseAmount && baseAmount !== 0 ? ( -{baseAmount} credits ) : ( free diff --git a/components/pages/work-flow/media-viewer.tsx b/components/pages/work-flow/media-viewer.tsx index 7e821da..d6ef89a 100644 --- a/components/pages/work-flow/media-viewer.tsx +++ b/components/pages/work-flow/media-viewer.tsx @@ -17,6 +17,7 @@ import { post } from '@/api/request'; import { VideoEditOverlay } from './video-edit/VideoEditOverlay'; import { EditPoint as EditPointType } from './video-edit/types'; import { isVideoModificationEnabled } from '@/lib/server-config'; +import { useSearchParams } from 'next/navigation'; import error_image from '@/public/assets/error.webp'; import { AspectRatioValue } from '@/components/ChatInputBox/AspectRatioSelector'; @@ -91,7 +92,8 @@ export const MediaViewer = React.memo(function MediaViewer({ const [isVideoEditMode, setIsVideoEditMode] = useState(false); // 控制钢笔图标显示的状态 - 参考谷歌登录按钮的实现 const [showVideoModification, setShowVideoModification] = useState(false); - + const searchParams = useSearchParams(); + const episodeId = searchParams.get('episodeId') || ''; useEffect(() => { if (isSmartChatBoxOpen) { const videoContentWidth = videoContentRef.current?.clientWidth ?? 0; @@ -519,13 +521,13 @@ export const MediaViewer = React.memo(function MediaViewer({ totalVideos: totalVideos + 1, isCurrentVideoFailed: false, isFinalStage: true, - projectId: projectId || '', + projectId: episodeId || '', onDownloadCurrent: async (withWatermark: boolean) => { setIsLoadingDownloadBtn(true); try { const json: any = await post('/movie/download_video', { - project_id: projectId || '', - watermark: !withWatermark + project_id: episodeId, + watermark: withWatermark }); const url = json?.data?.download_url as string | undefined; if (url) await downloadVideo(url); @@ -679,16 +681,16 @@ export const MediaViewer = React.memo(function MediaViewer({ totalVideos: taskObject.final.url ? totalVideos + 1 : totalVideos, isCurrentVideoFailed: isCurrentVideoFailed, isFinalStage: false, - projectId: projectId || '', + projectId: episodeId, videoId: currentVideo?.video_id, onDownloadCurrent: async (withWatermark: boolean) => { if (!currentVideo?.video_id) return; setIsLoadingDownloadBtn(true); try { const json: any = await post('/movie/download_video', { - project_id: projectId || '', + project_id: episodeId, video_id: currentVideo.video_id, - watermark: !withWatermark + watermark: withWatermark }); const url = json?.data?.download_url as string | undefined; if (url) await downloadVideo(url);