diff --git a/dbm-ui/frontend/src/views/temporary-paassword-modify/index/Index.vue b/dbm-ui/frontend/src/views/temporary-paassword-modify/index/Index.vue index c7dfcafa65..a3587552f0 100644 --- a/dbm-ui/frontend/src/views/temporary-paassword-modify/index/Index.vue +++ b/dbm-ui/frontend/src/views/temporary-paassword-modify/index/Index.vue @@ -16,15 +16,26 @@
(); + const modifyResult = ref(''); - const { run: queryAsyncModifyResultRun, loading: queryLoading } = useRequest(queryAsyncModifyResult, { + // 轮询 + const { isActive, resume, pause } = useTimeoutPoll(() => { + queryAsyncModifyResultRun({ + root_id: rootId.value, + }); + }, 2000); + + const { run: queryAsyncModifyResultRun } = useRequest(queryAsyncModifyResult, { manual: true, onSuccess({ data, status }) { - modifyResult.value = data; - // 设置轮询 - if (currentScope?.active) { - !isActive.value && ['PENDING', 'RUNNING', 'FINISHED'].includes(status) && resume(); - } else { + /** + * 设置轮询 + * FINISHED: 完成态 + * FAILED: 失败态 + * REVOKED: 取消态 + */ + if (['FINISHED', 'FAILED', 'REVOKED'].includes(status)) { + modifyResult.value = data; pause(); + } else if (!isActive.value) { + resume(); } }, - onError() { - modifyResult.value = {} as ModifyAdminPassword; - }, }); - // 轮询 - const { isActive, resume, pause } = useTimeoutPoll(() => { - queryAsyncModifyResultRun({ - root_id: rootId.value, - }); - }, 10000); - const { run: modifyAdminPasswordRun, loading: submitting } = useRequest(modifyAdminPassword, { manual: true, onSuccess(data) { @@ -229,6 +253,10 @@ handleReset(); submitted.value = false; }; + + onBeforeUnmount(() => { + pause(); + });