feat: 锁屏添加OMC升级等待

This commit is contained in:
TsMask
2024-01-17 17:29:31 +08:00
parent ce076ef7f8
commit e3a01b8998
5 changed files with 100 additions and 43 deletions

View File

@@ -1,4 +1,6 @@
import { getSysConf } from '@/api';
import { CACHE_LOCAL_LOCK } from '@/constants/cache-keys-constants';
import { RESULT_CODE_SUCCESS } from '@/constants/result-constants';
import { localGet, localSet } from '@/utils/cache-local-utils';
import { defineStore } from 'pinia';
@@ -7,7 +9,7 @@ type Locked = {
/**锁定状态 */
isLocked: boolean;
/**锁屏类型 */
lockType: 'lock' | 'reload' | 'upgrade';
lockType: 'lock' | 'reload';
/**超时锁屏时间,秒*/
lockTimeout: number;
};
@@ -20,11 +22,27 @@ const useLockedStore = defineStore('locked', {
}),
getters: {},
actions: {
// 重启等待-轮询
async relaodWait() {
const res = await getSysConf();
if (res.code === RESULT_CODE_SUCCESS && res.data) {
console.log(res);
this.fnLock('lock',false)
} else {
// 延迟5秒
setTimeout(() => {
this.relaodWait();
}, 5_000);
}
},
// 设置锁定
async fnLock(type: 'lock' | 'reload' | 'upgrade', v: boolean) {
async fnLock(type: 'lock' | 'reload', v: boolean) {
this.lockType = type;
this.isLocked = v;
localSet(CACHE_LOCAL_LOCK, `${v}`);
if (type === 'reload') {
this.relaodWait();
}
},
},
});