Commit d7b84c78744f7d0077a779b232e1358040b50383
1 parent
c99cf5e5
fix(lock-screen): fix lock-screen can skip on new window
修复锁屏功能可以通过刷新页面或复制 URL 打开新的浏览器标签来跳过锁定状态的问题
Showing
3 changed files
with
16 additions
and
7 deletions
CHANGELOG.zh_CN.md
src/store/modules/lock.ts
... | ... | @@ -23,10 +23,10 @@ export const useLockStore = defineStore({ |
23 | 23 | actions: { |
24 | 24 | setLockInfo(info: LockInfo) { |
25 | 25 | this.lockInfo = Object.assign({}, this.lockInfo, info); |
26 | - Persistent.setLocal(LOCK_INFO_KEY, this.lockInfo); | |
26 | + Persistent.setLocal(LOCK_INFO_KEY, this.lockInfo, true); | |
27 | 27 | }, |
28 | 28 | resetLockInfo() { |
29 | - Persistent.removeLocal(LOCK_INFO_KEY); | |
29 | + Persistent.removeLocal(LOCK_INFO_KEY, true); | |
30 | 30 | this.lockInfo = null; |
31 | 31 | }, |
32 | 32 | // Unlock | ... | ... |
src/utils/cache/persistent.ts
... | ... | @@ -57,12 +57,14 @@ export class Persistent { |
57 | 57 | immediate && ls.set(APP_LOCAL_CACHE_KEY, localMemory.getCache); |
58 | 58 | } |
59 | 59 | |
60 | - static removeLocal(key: LocalKeys): void { | |
60 | + static removeLocal(key: LocalKeys, immediate = false): void { | |
61 | 61 | localMemory.remove(key); |
62 | + immediate && ls.set(APP_LOCAL_CACHE_KEY, localMemory.getCache); | |
62 | 63 | } |
63 | 64 | |
64 | - static clearLocal(): void { | |
65 | + static clearLocal(immediate = false): void { | |
65 | 66 | localMemory.clear(); |
67 | + immediate && ls.clear(); | |
66 | 68 | } |
67 | 69 | |
68 | 70 | static getSession<T>(key: SessionKeys) { |
... | ... | @@ -74,16 +76,22 @@ export class Persistent { |
74 | 76 | immediate && ss.set(APP_SESSION_CACHE_KEY, sessionMemory.getCache); |
75 | 77 | } |
76 | 78 | |
77 | - static removeSession(key: SessionKeys): void { | |
79 | + static removeSession(key: SessionKeys, immediate = false): void { | |
78 | 80 | sessionMemory.remove(key); |
81 | + immediate && ss.set(APP_SESSION_CACHE_KEY, sessionMemory.getCache); | |
79 | 82 | } |
80 | - static clearSession(): void { | |
83 | + static clearSession(immediate = false): void { | |
81 | 84 | sessionMemory.clear(); |
85 | + immediate && ss.clear(); | |
82 | 86 | } |
83 | 87 | |
84 | - static clearAll() { | |
88 | + static clearAll(immediate = false) { | |
85 | 89 | sessionMemory.clear(); |
86 | 90 | localMemory.clear(); |
91 | + if (immediate) { | |
92 | + ls.clear(); | |
93 | + ss.clear(); | |
94 | + } | |
87 | 95 | } |
88 | 96 | } |
89 | 97 | ... | ... |