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
@@ -11,6 +11,7 @@ | @@ -11,6 +11,7 @@ | ||
11 | - **SvgIcon** 修复图标样式问题 | 11 | - **SvgIcon** 修复图标样式问题 |
12 | - **Table** 修复为 table 提供 rowSelection.onChange 时,无法手动变更 table 的选中项的问题 | 12 | - **Table** 修复为 table 提供 rowSelection.onChange 时,无法手动变更 table 的选中项的问题 |
13 | - **Icon** 修复 SvgIcon 缺少部分样式的问题 | 13 | - **Icon** 修复 SvgIcon 缺少部分样式的问题 |
14 | +- **LockScreen** 修复锁屏功能可以通过刷新页面或复制 URL 打开新的浏览器标签来跳过锁定状态的问题 | ||
14 | 15 | ||
15 | ## 2.5.2(2021-06-27) | 16 | ## 2.5.2(2021-06-27) |
16 | 17 |
src/store/modules/lock.ts
@@ -23,10 +23,10 @@ export const useLockStore = defineStore({ | @@ -23,10 +23,10 @@ export const useLockStore = defineStore({ | ||
23 | actions: { | 23 | actions: { |
24 | setLockInfo(info: LockInfo) { | 24 | setLockInfo(info: LockInfo) { |
25 | this.lockInfo = Object.assign({}, this.lockInfo, info); | 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 | resetLockInfo() { | 28 | resetLockInfo() { |
29 | - Persistent.removeLocal(LOCK_INFO_KEY); | 29 | + Persistent.removeLocal(LOCK_INFO_KEY, true); |
30 | this.lockInfo = null; | 30 | this.lockInfo = null; |
31 | }, | 31 | }, |
32 | // Unlock | 32 | // Unlock |
src/utils/cache/persistent.ts
@@ -57,12 +57,14 @@ export class Persistent { | @@ -57,12 +57,14 @@ export class Persistent { | ||
57 | immediate && ls.set(APP_LOCAL_CACHE_KEY, localMemory.getCache); | 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 | localMemory.remove(key); | 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 | localMemory.clear(); | 66 | localMemory.clear(); |
67 | + immediate && ls.clear(); | ||
66 | } | 68 | } |
67 | 69 | ||
68 | static getSession<T>(key: SessionKeys) { | 70 | static getSession<T>(key: SessionKeys) { |
@@ -74,16 +76,22 @@ export class Persistent { | @@ -74,16 +76,22 @@ export class Persistent { | ||
74 | immediate && ss.set(APP_SESSION_CACHE_KEY, sessionMemory.getCache); | 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 | sessionMemory.remove(key); | 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 | sessionMemory.clear(); | 84 | sessionMemory.clear(); |
85 | + immediate && ss.clear(); | ||
82 | } | 86 | } |
83 | 87 | ||
84 | - static clearAll() { | 88 | + static clearAll(immediate = false) { |
85 | sessionMemory.clear(); | 89 | sessionMemory.clear(); |
86 | localMemory.clear(); | 90 | localMemory.clear(); |
91 | + if (immediate) { | ||
92 | + ls.clear(); | ||
93 | + ss.clear(); | ||
94 | + } | ||
87 | } | 95 | } |
88 | } | 96 | } |
89 | 97 |