forked from 77media/video-flow
更新 水印传参
This commit is contained in:
parent
928c666305
commit
392f29c7b6
@ -281,7 +281,7 @@ export default function CreateToVideo2() {
|
|||||||
try {
|
try {
|
||||||
const json: any = await post('/movie/download_video', {
|
const json: any = await post('/movie/download_video', {
|
||||||
project_id: project.project_id,
|
project_id: project.project_id,
|
||||||
watermark: !withWatermark
|
watermark: withWatermark
|
||||||
});
|
});
|
||||||
const url = json?.data?.download_url as string | undefined;
|
const url = json?.data?.download_url as string | undefined;
|
||||||
if (url) {
|
if (url) {
|
||||||
|
|||||||
@ -484,7 +484,7 @@ export function H5MediaViewer({
|
|||||||
const json: any = await post('/movie/download_video', {
|
const json: any = await post('/movie/download_video', {
|
||||||
project_id: episodeId,
|
project_id: episodeId,
|
||||||
video_id: current.video_id,
|
video_id: current.video_id,
|
||||||
watermark: !withWatermark
|
watermark: withWatermark
|
||||||
});
|
});
|
||||||
const url = json?.data?.download_url as string | undefined;
|
const url = json?.data?.download_url as string | undefined;
|
||||||
if (url) await downloadVideo(url);
|
if (url) await downloadVideo(url);
|
||||||
@ -531,7 +531,7 @@ export function H5MediaViewer({
|
|||||||
onDownloadCurrent: async (withWatermark: boolean) => {
|
onDownloadCurrent: async (withWatermark: boolean) => {
|
||||||
const json: any = await post('/movie/download_video', {
|
const json: any = await post('/movie/download_video', {
|
||||||
project_id: episodeId,
|
project_id: episodeId,
|
||||||
watermark: !withWatermark
|
watermark: withWatermark
|
||||||
});
|
});
|
||||||
const url = json?.data?.download_url as string | undefined;
|
const url = json?.data?.download_url as string | undefined;
|
||||||
if (url) await downloadVideo(url);
|
if (url) await downloadVideo(url);
|
||||||
|
|||||||
@ -4,7 +4,7 @@ import React, { useEffect, useRef, useState } from 'react';
|
|||||||
import { Checkbox } from 'antd';
|
import { Checkbox } from 'antd';
|
||||||
import { createRoot, Root } from 'react-dom/client';
|
import { createRoot, Root } from 'react-dom/client';
|
||||||
import { X, Download, ArrowDownWideNarrow } from 'lucide-react';
|
import { X, Download, ArrowDownWideNarrow } from 'lucide-react';
|
||||||
import { baseUrl } from '@/lib/env';
|
import { post } from '@/api/request';
|
||||||
|
|
||||||
interface DownloadOptionsModalProps {
|
interface DownloadOptionsModalProps {
|
||||||
onDownloadCurrent: (withWatermark: boolean) => void;
|
onDownloadCurrent: (withWatermark: boolean) => void;
|
||||||
@ -45,29 +45,12 @@ function DownloadOptionsModal(props: DownloadOptionsModalProps) {
|
|||||||
let aborted = false;
|
let aborted = false;
|
||||||
const checkBalance = async () => {
|
const checkBalance = async () => {
|
||||||
try {
|
try {
|
||||||
if (!projectId) {
|
const json: any = await post('/movie/download_video', {
|
||||||
setBaseAmount(0);
|
project_id: projectId,
|
||||||
return;
|
video_id: videoId,
|
||||||
}
|
watermark: withWatermark,
|
||||||
const token = typeof window !== 'undefined' ? (localStorage?.getItem('token') || '') : '';
|
check_balance: true
|
||||||
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
|
|
||||||
})
|
|
||||||
});
|
});
|
||||||
if (!res.ok) {
|
|
||||||
if (!aborted) setBaseAmount(0);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
const json = await res.json().catch(() => null);
|
|
||||||
const amount = json?.data?.base_amount;
|
const amount = json?.data?.base_amount;
|
||||||
if (!aborted) setBaseAmount(Number.isFinite(amount) ? Number(amount) : 0);
|
if (!aborted) setBaseAmount(Number.isFinite(amount) ? Number(amount) : 0);
|
||||||
} catch {
|
} catch {
|
||||||
@ -116,7 +99,7 @@ function DownloadOptionsModal(props: DownloadOptionsModalProps) {
|
|||||||
Choose your download preference
|
Choose your download preference
|
||||||
</p>
|
</p>
|
||||||
<div data-alt="price-indicator" className="mt-2 text-center text-sm font-medium">
|
<div data-alt="price-indicator" className="mt-2 text-center text-sm font-medium">
|
||||||
{baseAmount && baseAmount !== 0 ? (
|
{!withWatermark && baseAmount && baseAmount !== 0 ? (
|
||||||
<span className="text-red-400">-{baseAmount} credits</span>
|
<span className="text-red-400">-{baseAmount} credits</span>
|
||||||
) : (
|
) : (
|
||||||
<span className="text-green-400">free</span>
|
<span className="text-green-400">free</span>
|
||||||
|
|||||||
@ -17,6 +17,7 @@ import { post } from '@/api/request';
|
|||||||
import { VideoEditOverlay } from './video-edit/VideoEditOverlay';
|
import { VideoEditOverlay } from './video-edit/VideoEditOverlay';
|
||||||
import { EditPoint as EditPointType } from './video-edit/types';
|
import { EditPoint as EditPointType } from './video-edit/types';
|
||||||
import { isVideoModificationEnabled } from '@/lib/server-config';
|
import { isVideoModificationEnabled } from '@/lib/server-config';
|
||||||
|
import { useSearchParams } from 'next/navigation';
|
||||||
import error_image from '@/public/assets/error.webp';
|
import error_image from '@/public/assets/error.webp';
|
||||||
import { AspectRatioValue } from '@/components/ChatInputBox/AspectRatioSelector';
|
import { AspectRatioValue } from '@/components/ChatInputBox/AspectRatioSelector';
|
||||||
|
|
||||||
@ -91,7 +92,8 @@ export const MediaViewer = React.memo(function MediaViewer({
|
|||||||
const [isVideoEditMode, setIsVideoEditMode] = useState(false);
|
const [isVideoEditMode, setIsVideoEditMode] = useState(false);
|
||||||
// 控制钢笔图标显示的状态 - 参考谷歌登录按钮的实现
|
// 控制钢笔图标显示的状态 - 参考谷歌登录按钮的实现
|
||||||
const [showVideoModification, setShowVideoModification] = useState(false);
|
const [showVideoModification, setShowVideoModification] = useState(false);
|
||||||
|
const searchParams = useSearchParams();
|
||||||
|
const episodeId = searchParams.get('episodeId') || '';
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (isSmartChatBoxOpen) {
|
if (isSmartChatBoxOpen) {
|
||||||
const videoContentWidth = videoContentRef.current?.clientWidth ?? 0;
|
const videoContentWidth = videoContentRef.current?.clientWidth ?? 0;
|
||||||
@ -519,13 +521,13 @@ export const MediaViewer = React.memo(function MediaViewer({
|
|||||||
totalVideos: totalVideos + 1,
|
totalVideos: totalVideos + 1,
|
||||||
isCurrentVideoFailed: false,
|
isCurrentVideoFailed: false,
|
||||||
isFinalStage: true,
|
isFinalStage: true,
|
||||||
projectId: projectId || '',
|
projectId: episodeId || '',
|
||||||
onDownloadCurrent: async (withWatermark: boolean) => {
|
onDownloadCurrent: async (withWatermark: boolean) => {
|
||||||
setIsLoadingDownloadBtn(true);
|
setIsLoadingDownloadBtn(true);
|
||||||
try {
|
try {
|
||||||
const json: any = await post('/movie/download_video', {
|
const json: any = await post('/movie/download_video', {
|
||||||
project_id: projectId || '',
|
project_id: episodeId,
|
||||||
watermark: !withWatermark
|
watermark: withWatermark
|
||||||
});
|
});
|
||||||
const url = json?.data?.download_url as string | undefined;
|
const url = json?.data?.download_url as string | undefined;
|
||||||
if (url) await downloadVideo(url);
|
if (url) await downloadVideo(url);
|
||||||
@ -679,16 +681,16 @@ export const MediaViewer = React.memo(function MediaViewer({
|
|||||||
totalVideos: taskObject.final.url ? totalVideos + 1 : totalVideos,
|
totalVideos: taskObject.final.url ? totalVideos + 1 : totalVideos,
|
||||||
isCurrentVideoFailed: isCurrentVideoFailed,
|
isCurrentVideoFailed: isCurrentVideoFailed,
|
||||||
isFinalStage: false,
|
isFinalStage: false,
|
||||||
projectId: projectId || '',
|
projectId: episodeId,
|
||||||
videoId: currentVideo?.video_id,
|
videoId: currentVideo?.video_id,
|
||||||
onDownloadCurrent: async (withWatermark: boolean) => {
|
onDownloadCurrent: async (withWatermark: boolean) => {
|
||||||
if (!currentVideo?.video_id) return;
|
if (!currentVideo?.video_id) return;
|
||||||
setIsLoadingDownloadBtn(true);
|
setIsLoadingDownloadBtn(true);
|
||||||
try {
|
try {
|
||||||
const json: any = await post('/movie/download_video', {
|
const json: any = await post('/movie/download_video', {
|
||||||
project_id: projectId || '',
|
project_id: episodeId,
|
||||||
video_id: currentVideo.video_id,
|
video_id: currentVideo.video_id,
|
||||||
watermark: !withWatermark
|
watermark: withWatermark
|
||||||
});
|
});
|
||||||
const url = json?.data?.download_url as string | undefined;
|
const url = json?.data?.download_url as string | undefined;
|
||||||
if (url) await downloadVideo(url);
|
if (url) await downloadVideo(url);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user