Skip to content

Commit

Permalink
fix: 重置时应该移除本地储存
Browse files Browse the repository at this point in the history
  • Loading branch information
Chanzhaoyu committed Mar 23, 2023
1 parent c52195c commit 917feec
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 4 additions & 0 deletions src/store/modules/settings/helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,7 @@ export function getLocalState(): SettingsState {
export function setLocalState(setting: SettingsState): void {
ss.set(LOCAL_NAME, setting)
}

export function removeLocalState() {
ss.remove(LOCAL_NAME)
}
4 changes: 2 additions & 2 deletions src/store/modules/settings/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { defineStore } from 'pinia'
import type { SettingsState } from './helper'
import { defaultSetting, getLocalState, setLocalState } from './helper'
import { defaultSetting, getLocalState, removeLocalState, setLocalState } from './helper'

export const useSettingStore = defineStore('setting-store', {
state: (): SettingsState => getLocalState(),
Expand All @@ -12,7 +12,7 @@ export const useSettingStore = defineStore('setting-store', {

resetSetting() {
this.$state = defaultSetting()
this.recordState()
removeLocalState()
},

recordState() {
Expand Down

0 comments on commit 917feec

Please sign in to comment.