Skip to content

Commit

Permalink
feat(frontend): 临时密码修改结果页优化 TencentBlueKing#7031
Browse files Browse the repository at this point in the history
# Reviewed, transaction id: 23165
  • Loading branch information
JustaCattt committed Nov 7, 2024
1 parent 62ded70 commit a55922b
Showing 1 changed file with 35 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,22 @@
<div class="password-temporary-modify">
<template v-if="submitted">
<div
v-if="queryLoading"
v-if="isActive"
class="submitting-mask">
<DbIcon
class="submitting-icon"
svg
type="sync-pending" />
<RouterLink
target="_blank"
:to="{
name: 'taskHistoryDetail',
params: {
root_id: rootId,
},
}">
{{ t('查看详情') }}
</RouterLink>
<p class="submitting-text">
{{ t('密码正在修改中,请稍等') }}
</p>
Expand Down Expand Up @@ -136,33 +146,34 @@
},
);

const currentScope = getCurrentScope();
const rootId = ref('');
const modifyResult = ref<ModifyAdminPassword>();
const modifyResult = ref<ModifyAdminPassword>('');

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();
return;
}
},
onError() {
modifyResult.value = {} as ModifyAdminPassword;
!isActive.value && resume();
},
});

// 轮询
const { isActive, resume, pause } = useTimeoutPoll(() => {
queryAsyncModifyResultRun({
root_id: rootId.value,
});
}, 10000);

const { run: modifyAdminPasswordRun, loading: submitting } = useRequest(modifyAdminPassword, {
manual: true,
onSuccess(data) {
Expand Down Expand Up @@ -238,17 +249,20 @@
border-radius: 2px;

.submitting-mask {
display: flex;
padding: 90px 0 138px;
text-align: center;
flex-direction: column;
align-items: center;

.submitting-icon {
margin-bottom: 18px;
font-size: 64px;
color: @primary-color;
animation: rotate 2s linear infinite;
}

.submitting-text {
margin-top: 36px;
margin-top: 18px;
font-size: 24px;
color: #313238;
}
Expand Down

0 comments on commit a55922b

Please sign in to comment.