fix: 锁屏页面重构

This commit is contained in:
TsMask
2024-01-17 16:00:55 +08:00
parent 5d1a60d94f
commit 46f0a7a92d
8 changed files with 80 additions and 41 deletions

View File

@@ -0,0 +1,32 @@
import { CACHE_LOCAL_LOCK } from '@/constants/cache-keys-constants';
import { localGet, localSet } from '@/utils/cache-local-utils';
import { defineStore } from 'pinia';
/**锁屏信息类型 */
type Locked = {
/**锁定状态 */
isLocked: boolean;
/**锁屏类型 */
lockType: 'lock' | 'reload' | 'upgrade';
/**超时锁屏时间,秒*/
lockTimeout: number;
};
const useLockedStore = defineStore('locked', {
state: (): Locked => ({
isLocked: localGet(CACHE_LOCAL_LOCK) === 'true',
lockType: 'lock',
lockTimeout: 0,
}),
getters: {},
actions: {
// 设置锁定
async fnLock(type: 'lock' | 'reload' | 'upgrade', v: boolean) {
this.lockType = type;
this.isLocked = v;
localSet(CACHE_LOCAL_LOCK, `${v}`);
},
},
});
export default useLockedStore;