fix: VideoCompose 压制成片添加前置积分检查
This commit is contained in:
@@ -5,10 +5,13 @@ import { openPath } from '@tauri-apps/plugin-opener';
|
||||
import { homeDir } from '@tauri-apps/api/path';
|
||||
import { compositeApi } from '../../api/modules/videoComposite';
|
||||
import { useProjectStore, saveMetaToLocalFile } from '../../store';
|
||||
import { usePointStore } from '../../store';
|
||||
import { useProgressStore } from '../../store/progressStore';
|
||||
|
||||
import { useLocalVideo } from '../../hooks/useLocalVideo';
|
||||
import { toast } from '../../store/uiStore';
|
||||
import ConfirmModal from '../../components/Modal/ConfirmModal';
|
||||
import RechargeModal from '../../components/RechargeModal/RechargeModal';
|
||||
|
||||
import './VideoCreation.css';
|
||||
import './VideoGeneration.css';
|
||||
@@ -30,6 +33,12 @@ export default function VideoCompose() {
|
||||
const progress = useProgressStore(state => state.progress);
|
||||
const [resultPath, setResultPath] = useState(finalVideoPath || '');
|
||||
|
||||
// 积分不足弹窗
|
||||
const [showPointsModal, setShowPointsModal] = useState(false);
|
||||
const showRechargeModal = usePointStore((state) => state.showRechargeModal);
|
||||
const setShowRechargeModal = usePointStore((state) => state.setShowRechargeModal);
|
||||
const fetchBalance = usePointStore((state) => state.fetchBalance);
|
||||
|
||||
// 同步 Store 中的 finalVideoPath 变化(如切换项目时)
|
||||
useEffect(() => {
|
||||
setDone(!!finalVideoPath);
|
||||
@@ -99,6 +108,16 @@ export default function VideoCompose() {
|
||||
return;
|
||||
}
|
||||
|
||||
// 前置积分检查:压制成片固定消耗 5 积分
|
||||
const COMPOSE_POINTS = 5;
|
||||
await fetchBalance();
|
||||
const currentBalance = usePointStore.getState().balance;
|
||||
if (currentBalance < COMPOSE_POINTS) {
|
||||
setShowPointsModal(true);
|
||||
return;
|
||||
}
|
||||
setShowPointsModal(false);
|
||||
|
||||
setCompositing(true);
|
||||
setDone(false);
|
||||
setResultPath('');
|
||||
@@ -397,6 +416,24 @@ export default function VideoCompose() {
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* 积分不足弹窗 */}
|
||||
<ConfirmModal
|
||||
open={showPointsModal}
|
||||
type="warning"
|
||||
title="积分不足"
|
||||
description="请先充值积分后再进行尝试"
|
||||
confirmText="立即充值"
|
||||
cancelText="稍后再说"
|
||||
confirmButtonType="danger"
|
||||
onConfirm={() => { setShowPointsModal(false); setShowRechargeModal(true); }}
|
||||
onCancel={() => setShowPointsModal(false)}
|
||||
onClose={() => setShowPointsModal(false)}
|
||||
/>
|
||||
<RechargeModal
|
||||
open={showRechargeModal}
|
||||
onClose={() => setShowRechargeModal(false)}
|
||||
onRechargeSuccess={() => { fetchBalance(); setShowPointsModal(false); }}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user