fix(capcut): 优化触发目录扫描时的代码组织

在 `capcut-tracks.js` 中将 `execFile` 的导入移到模块顶部,并修复临时目录清理时的 fs 引用问题
This commit is contained in:
2026-05-06 23:22:37 +08:00
parent b309f54430
commit e2c1415156

View File

@@ -415,10 +415,10 @@ async function addSlotsLocally(draftUrl, items, timeline, trackId, options = {})
}) })
if (matVideo) { if (matVideo) {
items[i]._segmentId = matVideo.id items[i]._segmentId = matVideo.id
slots.push(buildSlot(matVideo.id, videoTrack.id, i, tl, US)) slots.push(buildSlot(matVideo.id, videoTrack.id, i, tl))
} }
} else { } else {
slots.push(buildSlot(segId, videoTrack.id, i, tl, US)) slots.push(buildSlot(segId, videoTrack.id, i, tl))
} }
} }
@@ -458,12 +458,13 @@ function generateUUID() {
}) })
} }
const { execFile } = require('child_process')
function triggerDirScan(dir) { function triggerDirScan(dir) {
const { execFile } = require('child_process')
const tmp = dir + '.slot_tmp' const tmp = dir + '.slot_tmp'
if (process.platform === 'darwin') { if (process.platform === 'darwin') {
execFile('rsync', ['-a', dir + '/', tmp], (err) => { execFile('rsync', ['-a', dir + '/', tmp], (err) => {
try { require('fs').rmSync(tmp, { recursive: true, force: true }) } catch {} try { fs.rmSync(tmp, { recursive: true, force: true }) } catch {}
}) })
} }
} }