Skip to content

Commit

Permalink
fix(lock-screen): fix lock-screen can skip on new window
Browse files Browse the repository at this point in the history
修复锁屏功能可以通过刷新页面或复制 URL 打开新的浏览器标签来跳过锁定状态的问题
  • Loading branch information
mynetfan committed Jun 29, 2021
1 parent c99cf5e commit d7b84c7
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 7 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.zh_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
- **SvgIcon** 修复图标样式问题
- **Table** 修复为 table 提供 rowSelection.onChange 时,无法手动变更 table 的选中项的问题
- **Icon** 修复 SvgIcon 缺少部分样式的问题
- **LockScreen** 修复锁屏功能可以通过刷新页面或复制 URL 打开新的浏览器标签来跳过锁定状态的问题

## 2.5.2(2021-06-27)

Expand Down
4 changes: 2 additions & 2 deletions src/store/modules/lock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ export const useLockStore = defineStore({
actions: {
setLockInfo(info: LockInfo) {
this.lockInfo = Object.assign({}, this.lockInfo, info);
Persistent.setLocal(LOCK_INFO_KEY, this.lockInfo);
Persistent.setLocal(LOCK_INFO_KEY, this.lockInfo, true);
},
resetLockInfo() {
Persistent.removeLocal(LOCK_INFO_KEY);
Persistent.removeLocal(LOCK_INFO_KEY, true);
this.lockInfo = null;
},
// Unlock
Expand Down
18 changes: 13 additions & 5 deletions src/utils/cache/persistent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,14 @@ export class Persistent {
immediate && ls.set(APP_LOCAL_CACHE_KEY, localMemory.getCache);
}

static removeLocal(key: LocalKeys): void {
static removeLocal(key: LocalKeys, immediate = false): void {
localMemory.remove(key);
immediate && ls.set(APP_LOCAL_CACHE_KEY, localMemory.getCache);
}

static clearLocal(): void {
static clearLocal(immediate = false): void {
localMemory.clear();
immediate && ls.clear();
}

static getSession<T>(key: SessionKeys) {
Expand All @@ -74,16 +76,22 @@ export class Persistent {
immediate && ss.set(APP_SESSION_CACHE_KEY, sessionMemory.getCache);
}

static removeSession(key: SessionKeys): void {
static removeSession(key: SessionKeys, immediate = false): void {
sessionMemory.remove(key);
immediate && ss.set(APP_SESSION_CACHE_KEY, sessionMemory.getCache);
}
static clearSession(): void {
static clearSession(immediate = false): void {
sessionMemory.clear();
immediate && ss.clear();
}

static clearAll() {
static clearAll(immediate = false) {
sessionMemory.clear();
localMemory.clear();
if (immediate) {
ls.clear();
ss.clear();
}
}
}

Expand Down

0 comments on commit d7b84c7

Please sign in to comment.