This commit is contained in:
zyronon
2023-12-03 23:40:24 +08:00
parent 20165db2f3
commit f839e54617
10 changed files with 100 additions and 71 deletions

View File

@@ -2,7 +2,7 @@
import {onMounted, watch} from "vue";
import {BaseState, useBaseStore} from "@/stores/base.ts";
import {DictType, SaveConfig, SaveDict} from "@/types.ts"
import {Dict, DictType, SaveConfig, SaveDict} from "@/types.ts"
import Practice from "@/pages/practice/index.vue"
import {useRuntimeStore} from "@/stores/runtime.ts";
import {useSettingStore} from "@/stores/setting.ts";
@@ -21,11 +21,19 @@ const {setTheme} = useTheme()
watch(store.$state, (n: BaseState) => {
let data: BaseState = cloneDeep(n)
data.myDictList.map((v: any) => {
if (v.type === DictType.word) v.originWords = []
if (v.type === DictType.article) v.articles = []
v.words = []
v.chapterWords = []
data.myDictList.map((v: Dict) => {
if (v.isCustom) {
if (v.type === DictType.article) {
v.articles.map(s => {
delete s.sections
})
}
} else {
if (v.type === DictType.word) v.originWords = []
if (v.type === DictType.article) v.articles = []
v.words = []
v.chapterWords = []
}
})
localforage.setItem(SaveDict.key, JSON.stringify({val: data, version: SaveDict.version}))
})