This commit is contained in:
ct
2025-07-16 15:49:30 +08:00
parent d4c5fb5589
commit 6c8a69173e
24 changed files with 594 additions and 64 deletions

View File

@@ -3,6 +3,7 @@ import { Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle } f
import { Progress } from '@/components/ui/progress';
import { Spinner } from '@/components/ui/spinner.js';
import { Textarea } from '@/components/ui/textarea';
import useMediaStore from '@/stores/MediaStore';
import useUserStore from '@/stores/UserStore';
import { Clock10Icon, Download } from 'lucide-react';
import { useEffect, useRef, useState } from 'react';
@@ -18,6 +19,9 @@ const VideoDownloadModal = ({
exportStatus,
videoBlob,
videoBlobFilename,
selectedMeme,
selectedBackground,
currentCaption,
}) => {
const [showDebug, setShowDebug] = useState(false);
const [isPremiumExport, setIsPremiumExport] = useState(false);
@@ -31,6 +35,7 @@ const VideoDownloadModal = ({
const lastProgress = useRef(0);
const { premiumExportRequest, premiumExportComplete, basicExportRequest, basicExportComplete } = useUserStore();
const { saveMeme } = useMediaStore();
const handleShareOrDownload = async () => {
if (!videoBlob || !videoBlobFilename) {
@@ -40,6 +45,10 @@ const VideoDownloadModal = ({
setDownloadState('downloading');
// Track the save action before actual download/share
const captionTexts = currentCaption ? [currentCaption] : ['Default caption'];
await saveMeme(captionTexts, isPremiumExport);
try {
// Check if mobile and supports navigator.share
const isMobile = /iPhone|iPad|iPod|Android/i.test(navigator.userAgent);
@@ -96,8 +105,13 @@ const VideoDownloadModal = ({
setIsPremiumExport(true);
setEstimatedTimeRemaining(null);
// Prepare export data
const memeMediaIds = selectedMeme?.ids || null;
const backgroundMediaIds = selectedBackground?.ids || null;
const captionTexts = currentCaption ? [currentCaption] : ['Default caption'];
// Call premiumExportRequest and check response
const response = await premiumExportRequest();
const response = await premiumExportRequest(memeMediaIds, backgroundMediaIds, captionTexts);
if (response?.error) {
// Halt the process if there's an error
@@ -120,8 +134,23 @@ const VideoDownloadModal = ({
setIsPremiumExport(false);
setEstimatedTimeRemaining(null);
// Prepare export data
const memeMediaIds = selectedMeme?.ids || null;
const backgroundMediaIds = selectedBackground?.ids || null;
const captionTexts = currentCaption ? [currentCaption] : ['Default caption'];
// Debug logging
console.log('Export data:', {
selectedMeme,
selectedBackground,
currentCaption,
memeMediaIds,
backgroundMediaIds,
captionTexts
});
// Call basicExportRequest and check response
const response = await basicExportRequest();
const response = await basicExportRequest(memeMediaIds, backgroundMediaIds, captionTexts);
if (response?.error) {
// Halt the process if there's an error

View File

@@ -622,6 +622,9 @@ const VideoEditor = ({ width, height, onOpenTextSidebar }) => {
exportStatus={exportStatus}
videoBlob={videoBlob}
videoBlobFilename={videoBlobFilename}
selectedMeme={selectedMeme}
selectedBackground={selectedBackground}
currentCaption={currentCaption}
/>
</>
);