|
|
|
@ -1390,6 +1390,8 @@ const commandProgress = reactive({ |
|
|
|
let commandPollTimer = null |
|
|
|
let commandAutoCloseTimer = null |
|
|
|
let commandPollFails = 0 |
|
|
|
let commandPollInFlight = false |
|
|
|
let commandProgressEpoch = 0 |
|
|
|
|
|
|
|
function buttonStatusText(title) { |
|
|
|
if (commandProgress.buttonTitle !== title || !commandProgress.status) return '状态:待执行' |
|
|
|
@ -1410,6 +1412,7 @@ function clearCommandTimers() { |
|
|
|
|
|
|
|
function closeCommandProgress() { |
|
|
|
clearCommandTimers() |
|
|
|
commandProgressEpoch += 1 |
|
|
|
commandProgress.open = false |
|
|
|
} |
|
|
|
|
|
|
|
@ -1431,9 +1434,12 @@ function scheduleAutoClose() { |
|
|
|
} |
|
|
|
|
|
|
|
async function pollCommandOnce() { |
|
|
|
if (!commandProgress.commandId) return |
|
|
|
if (!commandProgress.commandId || commandPollInFlight) return |
|
|
|
const epoch = commandProgressEpoch |
|
|
|
commandPollInFlight = true |
|
|
|
try { |
|
|
|
const cmd = await request.get(urls.COMMAND(commandProgress.commandId)) |
|
|
|
if (epoch !== commandProgressEpoch) return |
|
|
|
commandPollFails = 0 |
|
|
|
const meta = applyCommandStatus(cmd) |
|
|
|
if (meta.terminal) { |
|
|
|
@ -1442,8 +1448,9 @@ async function pollCommandOnce() { |
|
|
|
scheduleAutoClose() |
|
|
|
} |
|
|
|
} catch (e) { |
|
|
|
if (epoch !== commandProgressEpoch) return |
|
|
|
commandPollFails += 1 |
|
|
|
const status = e?.response?.status |
|
|
|
const status = e?.status ?? e?.response?.status |
|
|
|
if (status === 403 || status === 404 || commandPollFails >= 3) { |
|
|
|
clearInterval(commandPollTimer) |
|
|
|
commandPollTimer = null |
|
|
|
@ -1455,11 +1462,15 @@ async function pollCommandOnce() { |
|
|
|
: (e.message || '进度查询失败') |
|
|
|
scheduleAutoClose() |
|
|
|
} |
|
|
|
} finally { |
|
|
|
commandPollInFlight = false |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
function startCommandProgress(cmd, title, deviceName) { |
|
|
|
clearCommandTimers() |
|
|
|
commandPollInFlight = false |
|
|
|
commandProgressEpoch += 1 |
|
|
|
commandPollFails = 0 |
|
|
|
commandProgress.open = true |
|
|
|
commandProgress.title = title |
|
|
|
|