fix: 锁屏页面重构
This commit is contained in:
32
src/store/modules/locked.ts
Normal file
32
src/store/modules/locked.ts
Normal 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;
|
||||
Reference in New Issue
Block a user