浏览代码

fix: reset data according to version

nian 1 月之前
父节点
当前提交
17430c90c1
共有 2 个文件被更改,包括 10 次插入6 次删除
  1. 9 5
      src/helpers/resetSystemData.ts
  2. 1 1
      src/stores/preferences.ts

+ 9 - 5
src/helpers/resetSystemData.ts

@@ -1,15 +1,19 @@
 import { DEFAULT_PREFERENCES_OPTIONS, usePreferencesStore } from '@/stores/preferences'
 import { useTabsStore } from '@/stores/tabs'
 import { useUserStore } from '@/stores/user'
-import { haveSameKeys } from '@/utils/lodash-helpers'
+import { haveSameKeys,getAllKeys } from '@/utils/lodash-helpers'
+
+const preferencesStore = usePreferencesStore()
+const tabsStore = useTabsStore()
+const userStore = useUserStore()
 
 export function resetSystemData() {
-  const preferencesStore = usePreferencesStore()
-  const tabsStore = useTabsStore()
-  const userStore = useUserStore()
+
+  console.log(getAllKeys(preferencesStore.preferences))
+  console.log(getAllKeys(DEFAULT_PREFERENCES_OPTIONS))
 
   const oldLocalStorage = localStorage.getItem('configure')
-  if (oldLocalStorage || haveSameKeys(preferencesStore.preferences, DEFAULT_PREFERENCES_OPTIONS)) {
+  if (oldLocalStorage || !haveSameKeys(preferencesStore.preferences, DEFAULT_PREFERENCES_OPTIONS)) {
     tabsStore.clearTabs()
     preferencesStore.reset()
     userStore.cleanup()

+ 1 - 1
src/stores/preferences.ts

@@ -65,7 +65,7 @@ export const DEFAULT_PREFERENCES_OPTIONS: PreferencesOptions = {
     fontStyle: 'normal',
     fontWeight: 400,
     lineHeight: 16,
-    image: undefined,
+    image: '',
     imageHeight: 64,
     imageWidth: 64,
     imageOpacity: 0.5,