优化后台业务
This commit is contained in:
@@ -226,6 +226,7 @@ import {
|
||||
} from '@/shared/api/java-modules'
|
||||
import { getPywebviewApi, type UploadedJavaFile } from '@/shared/bridges/pywebview'
|
||||
import { getTaskPollIntervalMs } from '@/shared/task-progress-config'
|
||||
import { createCategorizedTimers } from '@/shared/utils/categorized-timers'
|
||||
|
||||
interface SessionDeleteBrandItem extends DeleteBrandResultItem {
|
||||
_pushed?: boolean
|
||||
@@ -263,6 +264,8 @@ const activeItemKey = ref('')
|
||||
const autoAdvancing = ref(false)
|
||||
const autoRetryTimer = ref<number | null>(null)
|
||||
const waitingForBackendRecovery = ref(false)
|
||||
let disposed = false
|
||||
const timers = createCategorizedTimers('delete-brand')
|
||||
const displayPaths = computed(() => selectedPaths.value.slice(0, 10))
|
||||
|
||||
const currentSectionItems = computed(() => {
|
||||
@@ -892,14 +895,16 @@ function getPollIntervalMs() {
|
||||
}
|
||||
|
||||
function scheduleNextPoll(immediate = false) {
|
||||
if (disposed) return
|
||||
if (pollTimer.value) {
|
||||
if (!immediate) return
|
||||
clearTimeout(pollTimer.value)
|
||||
timers.clearTimer('task-poll', pollTimer.value)
|
||||
pollTimer.value = null
|
||||
}
|
||||
|
||||
const executePoll = async () => {
|
||||
pollTimer.value = null
|
||||
if (disposed) return
|
||||
if (pollingInFlight.value) {
|
||||
scheduleNextPoll()
|
||||
return
|
||||
@@ -933,7 +938,7 @@ function scheduleNextPoll(immediate = false) {
|
||||
syncResultState()
|
||||
}
|
||||
|
||||
if (getPollingTaskIds().length > 0) {
|
||||
if (!disposed && getPollingTaskIds().length > 0) {
|
||||
scheduleNextPoll()
|
||||
}
|
||||
}
|
||||
@@ -941,7 +946,7 @@ function scheduleNextPoll(immediate = false) {
|
||||
if (immediate) {
|
||||
executePoll()
|
||||
} else {
|
||||
pollTimer.value = window.setTimeout(executePoll, getPollIntervalMs())
|
||||
pollTimer.value = timers.setTimeout('task-poll', executePoll, getPollIntervalMs())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -969,7 +974,7 @@ function getTaskStatusInfo(item: DeleteBrandResultItem) {
|
||||
|
||||
function stopPolling() {
|
||||
if (pollTimer.value) {
|
||||
window.clearTimeout(pollTimer.value)
|
||||
timers.clearTimer('task-poll', pollTimer.value)
|
||||
pollTimer.value = null
|
||||
}
|
||||
clearAutoRetryTimer()
|
||||
@@ -1178,16 +1183,17 @@ function debugAutoAdvance(step: string, payload?: Record<string, unknown>) {
|
||||
|
||||
function clearAutoRetryTimer() {
|
||||
if (autoRetryTimer.value) {
|
||||
window.clearTimeout(autoRetryTimer.value)
|
||||
timers.clearTimer('auto-retry', autoRetryTimer.value)
|
||||
autoRetryTimer.value = null
|
||||
}
|
||||
}
|
||||
|
||||
function scheduleAutoAdvanceRetry(delayMs = 3000) {
|
||||
if (disposed) return
|
||||
clearAutoRetryTimer()
|
||||
autoRetryTimer.value = window.setTimeout(() => {
|
||||
autoRetryTimer.value = timers.setTimeout('auto-retry', () => {
|
||||
autoRetryTimer.value = null
|
||||
maybeAutoAdvance().catch(() => undefined)
|
||||
if (!disposed) maybeAutoAdvance().catch(() => undefined)
|
||||
}, delayMs)
|
||||
}
|
||||
|
||||
@@ -1428,7 +1434,9 @@ onMounted(() => {
|
||||
})
|
||||
|
||||
onUnmounted(() => {
|
||||
disposed = true
|
||||
stopPolling()
|
||||
timers.clearScope()
|
||||
})
|
||||
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user