{content.split('\n').map((line, i) => {
- if (line.trim() === '') return
;
}
diff --git a/tauri-app/src/components/RechargeModal/RechargeModal.tsx b/tauri-app/src/components/RechargeModal/RechargeModal.tsx
index 92be6cc..abfe327 100644
--- a/tauri-app/src/components/RechargeModal/RechargeModal.tsx
+++ b/tauri-app/src/components/RechargeModal/RechargeModal.tsx
@@ -177,7 +177,7 @@ export default function RechargeModal({
// 用户点击【我已支付】手动查询
const handleQueryPayment = async () => {
const orderId = orderIdRef.current;
- if (!orderId) return;
+ if (!orderId) {return;}
// 二维码已过期,直接提示
if (Date.now() >= expireAtRef.current) {
@@ -193,7 +193,7 @@ export default function RechargeModal({
// 刷新二维码(过期后重新下单)
const handleRefreshQrcode = async () => {
- if (!selectedOption) return;
+ if (!selectedOption) {return;}
setIsExpired(false);
setQrcodeDataUrl('');
setCountdown('');
diff --git a/tauri-app/src/hooks/useCoverFabric.ts b/tauri-app/src/hooks/useCoverFabric.ts
index 10ac31c..2cfba3e 100644
--- a/tauri-app/src/hooks/useCoverFabric.ts
+++ b/tauri-app/src/hooks/useCoverFabric.ts
@@ -209,8 +209,8 @@ export function useCoverFabric() {
canvas.add(fabricImg);
canvas.sendObjectToBack(fabricImg);
canvas.renderAll();
- } catch (err) {
- console.warn('[useCoverFabric] 背景图加载失败:', err);
+ } catch {
+ // no-op: 背景图加载失败已在内部处理
}
},
[]
@@ -224,7 +224,6 @@ export function useCoverFabric() {
// 确保自定义字体已加载(有缓存检查,不会重复加载)
await loadCustomFont().catch(() => {
- console.warn('[useCoverFabric] 字体加载失败,使用 fallback 字体');
});
canvas.clear();
@@ -234,8 +233,8 @@ export function useCoverFabric() {
if (config.backgroundImage) {
try {
await loadBackground(canvas, config.backgroundImage);
- } catch (err) {
- console.warn('[useCoverFabric] 背景图加载失败:', err);
+ } catch {
+ // no-op: 背景图加载失败已在内部处理
}
}
diff --git a/tauri-app/src/pages/Profile/Profile.tsx b/tauri-app/src/pages/Profile/Profile.tsx
index e598317..b9f7e62 100644
--- a/tauri-app/src/pages/Profile/Profile.tsx
+++ b/tauri-app/src/pages/Profile/Profile.tsx
@@ -32,7 +32,7 @@ const TYPE_LABELS: Record
= {
};
function maskMobile(mobile: string): string {
- if (!mobile || mobile.length !== 11) return mobile;
+ if (!mobile || mobile.length !== 11) {return mobile;}
return `${mobile.slice(0, 3)}****${mobile.slice(7)}`;
}
@@ -64,12 +64,12 @@ export default function Profile() {
setUser(profileData);
setNickname(profileData.nickname || '');
}
- if (balanceData) setBalance(balanceData);
+ if (balanceData) {setBalance(balanceData);}
const txData = await pointsApi
.getTransactions({ page: 1, pageSize: 10 })
.catch(() => null);
- if (txData) setRecentTx(txData.items);
+ if (txData) {setRecentTx(txData.items);}
} catch (e) {
console.error('[Profile] 加载数据失败:', e);
} finally {
@@ -107,7 +107,7 @@ export default function Profile() {
};
const handleLogout = async () => {
- if (!window.confirm('确定要退出登录吗?')) return;
+ if (!window.confirm('确定要退出登录吗?')) {return;}
await logout();
window.location.reload();
};
@@ -149,7 +149,7 @@ export default function Profile() {
fontFamily: 'inherit',
}}
onKeyDown={(e) => {
- if (e.key === 'Enter') handleSaveNickname();
+ if (e.key === 'Enter') {handleSaveNickname();}
if (e.key === 'Escape') {
setEditing(false);
setNickname(displayName);
diff --git a/tauri-app/src/pages/Profile/UsageDetail.tsx b/tauri-app/src/pages/Profile/UsageDetail.tsx
index 56c671d..3f3066c 100644
--- a/tauri-app/src/pages/Profile/UsageDetail.tsx
+++ b/tauri-app/src/pages/Profile/UsageDetail.tsx
@@ -250,7 +250,7 @@ export default function UsageDetail() {
// 加载数据
const load = useCallback(async () => {
- if (!startDate || !endDate) return;
+ if (!startDate || !endDate) {return;}
setLoading(true);
setDateError('');
try {
@@ -483,7 +483,7 @@ export default function UsageDetail() {
)}
{activeTab === 'consume' && (
- {tx.duration != null ? `${tx.duration.toFixed(1)}s` : '-'} |
+ {typeof tx.duration === 'number' ? `${tx.duration.toFixed(1)}s` : '-'} |
)}
{tx.description || '-'}
diff --git a/tauri-app/src/pages/VideoCreation/CoverDesign.tsx b/tauri-app/src/pages/VideoCreation/CoverDesign.tsx
index deeb01c..34d89ea 100644
--- a/tauri-app/src/pages/VideoCreation/CoverDesign.tsx
+++ b/tauri-app/src/pages/VideoCreation/CoverDesign.tsx
@@ -102,7 +102,7 @@ export default function CoverDesign() {
// 前置积分检查
const titlePoints = usePointStore.getState().getRule('title')?.points || 1;
const canProceed = await checkBalance(titlePoints, '标题生成', true);
- if (!canProceed) return;
+ if (!canProceed) {return;}
const scriptContent = utterances.map(u => u.text).join('\n');
const maxLength = titleType === 'main' ? 6 : 26;
@@ -144,7 +144,6 @@ export default function CoverDesign() {
useEffect(() => {
const loadBackgrounds = async () => {
if (!categoryCode) {
- console.warn('[CoverDesign] 未选择脚本大类,无法加载背景图');
return;
}
try {
@@ -231,8 +230,8 @@ export default function CoverDesign() {
projectId,
filePath: oldCoverPath,
});
- } catch (e) {
- console.warn('[CoverDesign] 删除旧封面失败:', e);
+ } catch {
+ // no-op: 删除旧封面失败不影响主流程
}
}
diff --git a/tauri-app/src/pages/VideoCreation/ScriptCreation.tsx b/tauri-app/src/pages/VideoCreation/ScriptCreation.tsx
index 981c9f7..e65aeec 100644
--- a/tauri-app/src/pages/VideoCreation/ScriptCreation.tsx
+++ b/tauri-app/src/pages/VideoCreation/ScriptCreation.tsx
@@ -130,7 +130,7 @@ export default function ScriptCreation() {
// 前置积分检查:脚本生成
const scriptPoints = usePointStore.getState().getRule('script')?.points || 5;
const ok = await checkBalance(scriptPoints, '脚本生成');
- if (!ok) return;
+ if (!ok) {return;}
// 请求去重锁:防止网络延迟期间快速点击发起多个请求
if (requestLock.current) {
@@ -286,7 +286,7 @@ export default function ScriptCreation() {
// 前置积分检查:润色
const polishPoints = usePointStore.getState().getRule('polish')?.points || 1;
const ok = await checkBalance(polishPoints, type === 'voiceover' ? '文案润色' : '画面润色');
- if (!ok) return;
+ if (!ok) {return;}
setPolishingState({ id, type });
try {
@@ -298,7 +298,7 @@ export default function ScriptCreation() {
const result = await scriptApi.polish(id, content, polishType, shotType);
handleFieldChange(id, type, result);
} catch (error) {
- if (handleError(error, type === 'voiceover' ? '文案润色' : '画面润色', 1)) return;
+ if (handleError(error, type === 'voiceover' ? '文案润色' : '画面润色', 1)) {return;}
console.error('润色失败:', error);
toast.error('润色失败,请重试');
} finally {
diff --git a/tauri-app/src/pages/VideoCreation/SubtitleBurning.tsx b/tauri-app/src/pages/VideoCreation/SubtitleBurning.tsx
index ea50292..484db3a 100644
--- a/tauri-app/src/pages/VideoCreation/SubtitleBurning.tsx
+++ b/tauri-app/src/pages/VideoCreation/SubtitleBurning.tsx
@@ -126,7 +126,7 @@ export default function SubtitleBurning() {
// 前置积分检查
const titlePoints = usePointStore.getState().getRule('title')?.points || 1;
const canProceed = await checkBalance(titlePoints, '标题生成', true);
- if (!canProceed) return;
+ if (!canProceed) {return;}
const scriptContent = utterances.map(u => u.text).join('\n');
const maxLength = titleType === 'main' ? 8 : 10;
diff --git a/tauri-app/src/pages/VideoCreation/VideoCompose.tsx b/tauri-app/src/pages/VideoCreation/VideoCompose.tsx
index 5a69a28..bc26fa9 100644
--- a/tauri-app/src/pages/VideoCreation/VideoCompose.tsx
+++ b/tauri-app/src/pages/VideoCreation/VideoCompose.tsx
@@ -367,14 +367,14 @@ export default function VideoCompose() {
className="btn btn-primary"
style={{ flex: 1 }}
onClick={async () => {
- if (!resultPath) return;
+ if (!resultPath) {return;}
try {
const filename = resultPath.split(/[\\/]/).pop() || 'video.mp4';
const targetPath = await save({
defaultPath: filename,
filters: [{ name: '视频', extensions: ['mp4'] }],
});
- if (!targetPath) return;
+ if (!targetPath) {return;}
const res = await invoke<{ code: number; data?: string; message: string }>('export_product', {
sourcePath: resultPath,
targetPath,
diff --git a/tauri-app/src/pages/VideoCreation/VoiceSynthesis.tsx b/tauri-app/src/pages/VideoCreation/VoiceSynthesis.tsx
index aa6de40..c1fa398 100644
--- a/tauri-app/src/pages/VideoCreation/VoiceSynthesis.tsx
+++ b/tauri-app/src/pages/VideoCreation/VoiceSynthesis.tsx
@@ -79,7 +79,7 @@ export default function VoiceSynthesis() {
// 加上镜头切换停顿(segment↔empty_shot: 0.5s,同类型: 0.3s),每 5 秒 1 积分,最低 1 积分
const estimatedTtsPoints = useMemo(() => {
const validSegments = segments.filter(s => s.voiceover?.trim());
- if (validSegments.length === 0) return { min: 0, max: 0 };
+ if (validSegments.length === 0) {return { min: 0, max: 0 };}
// 纯朗读时间(与后端配置 seconds_per_char: 0.25 保持一致)
const totalChars = validSegments.reduce((sum, s) => sum + s.voiceover!.trim().length, 0);
@@ -188,7 +188,6 @@ export default function VoiceSynthesis() {
return;
}
if (!alignResult.utterances?.length) {
- console.warn('[VoiceSynthesis] 打轴返回空结果');
progress.error('字幕处理异常');
return;
}
@@ -199,7 +198,6 @@ export default function VoiceSynthesis() {
.map(s => ({ id: s.id, voiceover: s.voiceover || '' }));
const matched = matchSegmentsToUtterances(matchSegments, alignResult.utterances);
if (!matched.length) {
- console.warn('[VoiceSynthesis] 文本匹配无结果');
progress.error('音频对齐失败');
return;
}
@@ -304,7 +302,7 @@ export default function VoiceSynthesis() {
// 前置积分检查(宽松模式:余额为正即可执行,TTS 实际消耗不确定,允许欠费)
const ok = await checkBalance(estimatedTtsPoints, '配音合成', false);
- if (!ok) return;
+ if (!ok) {return;}
const progress = useProgressStore.getState();
setIsGenerating(true);
diff --git a/tauri-app/src/pages/VideoGeneration/hooks/useVideoGeneration.ts b/tauri-app/src/pages/VideoGeneration/hooks/useVideoGeneration.ts
index cbca4c0..70fc99d 100644
--- a/tauri-app/src/pages/VideoGeneration/hooks/useVideoGeneration.ts
+++ b/tauri-app/src/pages/VideoGeneration/hooks/useVideoGeneration.ts
@@ -95,7 +95,7 @@ export function useVideoGeneration({
// 前置积分检查(严格模式)
const canProceed = await checkBalance(estimatedVideoPoints, '视频生成', true);
- if (!canProceed) return;
+ if (!canProceed) {return;}
setIsComposing(true);
const progress = useProgressStore.getState();
@@ -152,13 +152,12 @@ export function useVideoGeneration({
projectId,
filePath: clipPath,
});
- } catch (e) {
- console.warn(`[VideoGeneration] 删除临时截取片段失败: ${clipPath}`, e);
+ } catch {
+ // no-op: 删除临时文件失败不影响主流程
}
// 1d. 提交视频生成任务(仅当该分镜有 clipAudioUrl 时)
if (!shot.clipAudioUrl) {
- console.warn(`[VideoGeneration] Segment ${shot.id} 无 clipAudioUrl,跳过视频生成`);
continue;
}
@@ -374,8 +373,8 @@ export function useVideoGeneration({
projectId,
filePath: shot.lipSyncVideoPath,
});
- } catch (e) {
- console.warn(`[VideoGeneration] 删除生成视频失败: ${shot.lipSyncVideoPath}`, e);
+ } catch {
+ // no-op: 删除生成视频失败不影响主流程
}
}
if (shot.clipVideoPath) {
@@ -384,8 +383,8 @@ export function useVideoGeneration({
projectId,
filePath: shot.clipVideoPath,
});
- } catch (e) {
- console.warn(`[VideoGeneration] 删除片段视频失败: ${shot.clipVideoPath}`, e);
+ } catch {
+ // no-op: 删除片段视频失败不影响主流程
}
}
}
diff --git a/tauri-app/src/pages/VideoGeneration/index.tsx b/tauri-app/src/pages/VideoGeneration/index.tsx
index de9cab3..be73213 100644
--- a/tauri-app/src/pages/VideoGeneration/index.tsx
+++ b/tauri-app/src/pages/VideoGeneration/index.tsx
@@ -95,7 +95,6 @@ export default function VideoGeneration() {
try {
const fileExists = await exists(meta.avatarMaterialPath);
if (!fileExists) {
- console.warn('[VideoGeneration] 人物素材文件已不存在:', meta.avatarMaterialPath);
useProjectStore.setState({
avatarMaterialPath: undefined,
avatarMaterialName: undefined,
@@ -107,8 +106,8 @@ export default function VideoGeneration() {
avatarMaterialDuration: undefined,
});
}
- } catch (e) {
- console.warn('[VideoGeneration] 验证人物素材文件失败:', e);
+ } catch {
+ // no-op: 验证素材文件失败不影响主流程
}
}
@@ -256,7 +255,7 @@ export default function VideoGeneration() {
}
const filePath = selected;
- const fileName = filePath.split(/[\/]/).pop() || '未知文件';
+ const fileName = filePath.split(/[/\\]/).pop() || '未知文件';
const result = await validateLocalVideo(filePath);
diff --git a/tauri-app/src/store/authStore.ts b/tauri-app/src/store/authStore.ts
index af5ff58..01f95aa 100644
--- a/tauri-app/src/store/authStore.ts
+++ b/tauri-app/src/store/authStore.ts
@@ -10,6 +10,7 @@
import { create } from 'zustand';
import { invoke } from '@tauri-apps/api/core';
+import { getVersion } from '@tauri-apps/api/app';
import { client, clearAuthCache, PYTHON_API_BASE_URL, setOnTokenRefreshed, setOnAuthFailed } from '../api/client';
import { isTauri } from '../utils/env';
// uiStore 不再直接导入,弹窗由 React 组件通过状态驱动渲染
@@ -70,9 +71,8 @@ function connectSSE(accessToken: string) {
try {
const data = JSON.parse(event.data);
if (data.type === 'kick') {
- console.warn('[SSE] 收到踢人消息:', data);
const state = useAuthStore.getState();
- if (!state.isAuthenticated || state.showKickModal) return;
+ if (!state.isAuthenticated || state.showKickModal) {return;}
// 先弹窗,不清除状态;用户点击确认后再清除
useAuthStore.setState({
showKickModal: true,
@@ -145,6 +145,21 @@ const generateDeviceId = () => {
return newId;
};
+// 缓存应用版本号,避免每次登录都调用 IPC
+let appVersionCache: string | null = null;
+
+async function getAppVersion(): Promise {
+ if (appVersionCache) {
+ return appVersionCache;
+ }
+ try {
+ appVersionCache = await getVersion();
+ } catch {
+ appVersionCache = 'unknown';
+ }
+ return appVersionCache;
+}
+
// 注册 Token 刷新回调:client.ts 的 doRefreshToken 成功后会触发此回调,
// 确保新 Token 被持久化到 Tauri 文件存储 / localStorage
setOnTokenRefreshed((tokens) => {
@@ -164,7 +179,7 @@ setOnTokenRefreshed((tokens) => {
// 注意:不能调用 logout(),因为 logout() 内部会请求 /auth/logout,又可能触发 401 循环
setOnAuthFailed(() => {
const state = useAuthStore.getState();
- if (!state.isAuthenticated || state.showKickModal) return;
+ if (!state.isAuthenticated || state.showKickModal) {return;}
// 先弹窗,不清除状态;用户点击确认后再清除
useAuthStore.setState({
showKickModal: true,
@@ -237,7 +252,7 @@ export const useAuthStore = create((set, get) => ({
deviceId: generateDeviceId(),
deviceName: '美家卡智影桌面端',
osInfo: navigator.userAgent,
- appVersion: '0.1.0',
+ appVersion: await getAppVersion(),
});
const newState = {
@@ -254,6 +269,10 @@ export const useAuthStore = create((set, get) => ({
await saveAuthState(newState);
clearAuthCache();
connectSSE(data.accessToken);
+ } catch (error) {
+ console.error('[authStore] 登录失败:', error);
+ isLoggingIn = false;
+ throw error;
} finally {
isLoggingIn = false;
}
@@ -271,9 +290,8 @@ export const useAuthStore = create((set, get) => ({
// 先调用后端登出 API(清理设备记录)
try {
await client.post('/auth/logout');
- } catch (e) {
+ } catch {
// 后端登出失败不影响前端状态清理
- console.warn('[Auth] 后端登出调用失败:', e);
}
// 重置状态
diff --git a/tauri-app/src/store/pointStore.ts b/tauri-app/src/store/pointStore.ts
index 7644f1c..b7f38f9 100644
--- a/tauri-app/src/store/pointStore.ts
+++ b/tauri-app/src/store/pointStore.ts
@@ -48,7 +48,7 @@ export const usePointStore = create((set, get) => ({
},
loadRules: async () => {
- if (get().rulesLoaded) return;
+ if (get().rulesLoaded) {return;}
try {
const rules = await pointsApi.getRules();
set({ rules, rulesLoaded: true });
diff --git a/tauri-app/src/store/projectStore.ts b/tauri-app/src/store/projectStore.ts
index 4a522f3..cdfba59 100644
--- a/tauri-app/src/store/projectStore.ts
+++ b/tauri-app/src/store/projectStore.ts
@@ -143,7 +143,7 @@ export const useProjectStore = create()(
state.segments[shotIndex] = updatedShot as ScriptShot;
state.updatedAt = Date.now();
} else {
- console.warn('[ProjectStore] Shot not found:', id);
+ // no-op: 分镜不存在时不处理
}
// 自动保存已移除,数据将在点击下一步时统一落盘
}),
diff --git a/tauri-app/src/utils/audioAlign.ts b/tauri-app/src/utils/audioAlign.ts
index 1ebec26..61cef16 100644
--- a/tauri-app/src/utils/audioAlign.ts
+++ b/tauri-app/src/utils/audioAlign.ts
@@ -107,10 +107,6 @@ export function matchSegmentsToUtterances(
});
} else {
// 匹配失败:已消费的 utterances 确实属于这个失败的 segment,不回退 uIdx
- console.warn(
- `[audioAlign] Segment ${seg.id} 匹配失败: ` +
- `target="${targetNorm}" accumulated="${accumulatedNorm}"`
- );
}
}
diff --git a/tauri-app/src/utils/canvasSubtitleDrawer.ts b/tauri-app/src/utils/canvasSubtitleDrawer.ts
index 793486e..e523f80 100644
--- a/tauri-app/src/utils/canvasSubtitleDrawer.ts
+++ b/tauri-app/src/utils/canvasSubtitleDrawer.ts
@@ -223,7 +223,7 @@ export async function loadCustomFont(): Promise {
});
await fontFace.load();
document.fonts.add(fontFace);
- } catch (e) {
- console.warn('[CanvasSubtitle] 字体加载失败,将使用系统字体回退:', e);
+ } catch {
+ // no-op: 字体加载失败已在内部处理
}
}
|