fix: 系统重置操作等待遮罩

This commit is contained in:
TsMask
2024-05-14 15:01:30 +08:00
parent c8a6aa3210
commit 76839ae18a
2 changed files with 14 additions and 20 deletions

View File

@@ -32,6 +32,7 @@ export function bootloaderReset() {
return request({
url: `/bootloader`,
method: 'delete',
timeout: 180_000
});
}

View File

@@ -10,14 +10,12 @@ const { t } = useI18n();
type StateType = {
visible: boolean;
confirmLoading: boolean;
count: number;
timer: any;
};
let state: StateType = reactive({
visible: false,
confirmLoading: false,
count: 10,
timer: null,
});
@@ -38,23 +36,18 @@ function fnModalVisible() {
/**对话框提交确认 */
function fnModalOk() {
// 发送请求
const hide = message.loading(t('common.loading'), 0);
state.confirmLoading = true;
bootloaderReset()
.then(res => {
state.confirmLoading = false;
if (res.code === RESULT_CODE_SUCCESS) {
fnModalCancel();
lockedStore.fnLock('reload');
} else {
message.error(res.msg, 3);
clearInterval(state.timer);
state.timer = null;
}
})
.finally(() => {
hide();
});
lockedStore.fnLock('reset');
bootloaderReset().then(res => {
if (res.code === RESULT_CODE_SUCCESS) {
fnModalCancel();
lockedStore.fnLock('reload');
} else {
lockedStore.fnLock('none');
message.error(res.msg, 3);
clearInterval(state.timer);
state.timer = null;
}
});
}
/**对话框取消操作 */
@@ -80,7 +73,7 @@ function fnModalCancel() {
:ok-text="
state.count > 0 ? `${t('common.ok')} ${state.count}` : t('common.ok')
"
:confirmLoading="state.count > 0 || state.confirmLoading"
:confirmLoading="state.count > 0"
@ok="fnModalOk()"
@cancel="fnModalCancel()"
>