forked from 77media/video-flow
更新 添加check的loading
This commit is contained in:
parent
392f29c7b6
commit
0fb504e63e
@ -31,6 +31,7 @@ function DownloadOptionsModal(props: DownloadOptionsModalProps) {
|
|||||||
const containerRef = useRef<HTMLDivElement | null>(null);
|
const containerRef = useRef<HTMLDivElement | null>(null);
|
||||||
const [withWatermark, setWithWatermark] = useState<boolean>(true);
|
const [withWatermark, setWithWatermark] = useState<boolean>(true);
|
||||||
const [baseAmount, setBaseAmount] = useState<number>(0);
|
const [baseAmount, setBaseAmount] = useState<number>(0);
|
||||||
|
const [isCheckingBalance, setIsCheckingBalance] = useState<boolean>(false);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const originalOverflow = document.body.style.overflow;
|
const originalOverflow = document.body.style.overflow;
|
||||||
@ -45,6 +46,7 @@ function DownloadOptionsModal(props: DownloadOptionsModalProps) {
|
|||||||
let aborted = false;
|
let aborted = false;
|
||||||
const checkBalance = async () => {
|
const checkBalance = async () => {
|
||||||
try {
|
try {
|
||||||
|
if (!aborted) setIsCheckingBalance(true);
|
||||||
const json: any = await post('/movie/download_video', {
|
const json: any = await post('/movie/download_video', {
|
||||||
project_id: projectId,
|
project_id: projectId,
|
||||||
video_id: videoId,
|
video_id: videoId,
|
||||||
@ -55,6 +57,8 @@ function DownloadOptionsModal(props: DownloadOptionsModalProps) {
|
|||||||
if (!aborted) setBaseAmount(Number.isFinite(amount) ? Number(amount) : 0);
|
if (!aborted) setBaseAmount(Number.isFinite(amount) ? Number(amount) : 0);
|
||||||
} catch {
|
} catch {
|
||||||
if (!aborted) setBaseAmount(0);
|
if (!aborted) setBaseAmount(0);
|
||||||
|
} finally {
|
||||||
|
if (!aborted) setIsCheckingBalance(false);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
void checkBalance();
|
void checkBalance();
|
||||||
@ -122,7 +126,8 @@ function DownloadOptionsModal(props: DownloadOptionsModalProps) {
|
|||||||
<div data-alt="modal-actions" className="mt-6 space-y-3">
|
<div data-alt="modal-actions" className="mt-6 space-y-3">
|
||||||
<button
|
<button
|
||||||
data-alt="download-single-button"
|
data-alt="download-single-button"
|
||||||
className="w-full px-4 py-2.5 rounded-lg bg-gradient-to-br from-purple-600/80 to-purple-700/80 hover:from-purple-500/80 hover:to-purple-600/80 text-white font-medium transition-all flex items-center justify-center gap-2"
|
className="w-full px-4 py-2.5 rounded-lg bg-gradient-to-br from-purple-600/80 to-purple-700/80 hover:from-purple-500/80 hover:to-purple-600/80 text-white font-medium transition-all flex items-center justify-center gap-2 disabled:opacity-60 disabled:cursor-not-allowed"
|
||||||
|
disabled={isCheckingBalance}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
onDownloadCurrent(withWatermark);
|
onDownloadCurrent(withWatermark);
|
||||||
onClose();
|
onClose();
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user