fix: catch 块类型安全 + 视频合成路径分隔符跨平台兼容
1. SubtitleBurning.tsx: - catch 参数显式标注 :unknown - fallback 从 '压制失败' 改为 String(error),保留原始错误信息 2. VideoComposite.tsx: - 路径分隔符从单 '/' 检查改为同时检查 '/' 和 '\' - 修复 Windows 下 '打开文件夹' 按钮变成 '打开文件' 的问题
This commit is contained in:
@@ -344,11 +344,11 @@ export default function SubtitleBurning() {
|
||||
useProjectStore.setState({ burnedVideoPath: outputPath });
|
||||
await saveMetaToLocalFile({ burnedVideoPath: outputPath });
|
||||
useProgressStore.getState().success('字幕压制完成');
|
||||
} catch (error) {
|
||||
const msg = error instanceof Error ? error.message : '压制失败';
|
||||
} catch (error: unknown) {
|
||||
const msg = error instanceof Error ? error.message : String(error);
|
||||
console.error('[SubtitleBurning] 压制失败:', error);
|
||||
useProgressStore.getState().error(msg);
|
||||
toast.error(msg);
|
||||
useProgressStore.getState().error(msg || '压制失败');
|
||||
toast.error(msg || '压制失败');
|
||||
} finally {
|
||||
setIsBurning(false);
|
||||
}
|
||||
|
||||
@@ -307,10 +307,10 @@ export default function VideoComposite() {
|
||||
className="btn btn-primary"
|
||||
style={{ flex: 1 }}
|
||||
onClick={() => {
|
||||
// 提取文件所在目录并打开
|
||||
const lastSlash = resultPath.lastIndexOf('/');
|
||||
if (lastSlash > 0) {
|
||||
openPath(resultPath.slice(0, lastSlash));
|
||||
// 提取文件所在目录并打开(兼容 Windows \ 和 macOS/Linux /)
|
||||
const lastSep = Math.max(resultPath.lastIndexOf('/'), resultPath.lastIndexOf('\\'));
|
||||
if (lastSep > 0) {
|
||||
openPath(resultPath.slice(0, lastSep));
|
||||
} else {
|
||||
openPath(resultPath);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user