feat: 锁屏添加OMC升级等待
This commit is contained in:
@@ -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();
|
||||
}
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user