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({ return request({
url: `/bootloader`, url: `/bootloader`,
method: 'delete', method: 'delete',
timeout: 180_000
}); });
} }

View File

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