feat: 分镜重生成后刷新时长预算并隔离过期响应
This commit is contained in:
1 parent
1b189228ce
commit
587685fab3
1 file changed
+20
-16
@@ -86,27 +86,29 @@ const durationAudit = ref<StoryboardDurationAudit | null>(null)
|
||||
const durationBudget = ref<ProjectDurationBudgetSummary | null>(null)
|
||||
const currentDurationBudget = computed(() => durationBudget.value?.episodes?.find(item => item.episodeNo === episodeNo.value) ?? null)
|
||||
const durationAuditError = ref('')
|
||||
/** 请求代次保证重生成刷新与切换项目时,迟到响应不会覆盖新数据。 */
|
||||
let durationRequestVersion = 0
|
||||
async function refreshDuration(projectId: string) {
|
||||
const version = ++durationRequestVersion
|
||||
const [audit, budget] = await Promise.allSettled([
|
||||
storyboardApi.durationAudit(projectId),
|
||||
projectsApi.durationBudget(projectId)
|
||||
])
|
||||
if (version !== durationRequestVersion || id.value !== projectId) return
|
||||
if (audit.status === 'fulfilled') durationAudit.value = audit.value
|
||||
if (budget.status === 'fulfilled' && Array.isArray(budget.value?.episodes)) durationBudget.value = budget.value
|
||||
durationAuditError.value = audit.status === 'rejected' || budget.status === 'rejected'
|
||||
? '部分时长信息暂不可用,不影响分镜操作。'
|
||||
: ''
|
||||
}
|
||||
watch(
|
||||
id,
|
||||
async (projectId, _old, onCleanup) => {
|
||||
const controller = new AbortController()
|
||||
onCleanup(() => controller.abort())
|
||||
projectId => {
|
||||
++durationRequestVersion
|
||||
durationAudit.value = null
|
||||
durationBudget.value = null
|
||||
durationAuditError.value = ''
|
||||
if (!projectId) return
|
||||
try {
|
||||
const [audit, budget] = await Promise.allSettled([
|
||||
storyboardApi.durationAudit(projectId, controller.signal),
|
||||
projectsApi.durationBudget(projectId, controller.signal)
|
||||
])
|
||||
if (controller.signal.aborted) return
|
||||
if (audit.status === 'fulfilled') durationAudit.value = audit.value
|
||||
if (budget.status === 'fulfilled' && Array.isArray(budget.value?.episodes)) durationBudget.value = budget.value
|
||||
if (audit.status === 'rejected' || budget.status === 'rejected') durationAuditError.value = '部分时长信息暂不可用,不影响分镜操作。'
|
||||
} catch {
|
||||
if (!controller.signal.aborted) durationAuditError.value = '分镜时长审计暂时不可用,不影响当前分镜操作。'
|
||||
}
|
||||
if (projectId) void refreshDuration(projectId)
|
||||
},
|
||||
{ immediate: true }
|
||||
)
|
||||
@@ -197,6 +199,8 @@ watch(
|
||||
receipt => {
|
||||
if (receipt) {
|
||||
toolsOpen.value = true
|
||||
/** 正式镜头重生成完成后重新读取预算与审计,避免展示旧时长。 */
|
||||
if (receipt.kind === 'shots' && id.value) void refreshDuration(id.value)
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
Reference in new issue
Block a user