Modify the name field of word

This commit is contained in:
zyronon
2023-12-13 17:17:59 +08:00
parent 998c1196b5
commit 4179bfaf5b
22 changed files with 115759 additions and 886 deletions

View File

@@ -10,7 +10,7 @@ export const APP_NAME = 'Typing Word'
export const SAVE_DICT_KEY = {
key: 'typing-word-dict',
version: 3
version: 4
}
export const SAVE_SETTING_KEY = {
key: 'typing-word-setting',

View File

@@ -1,4 +1,3 @@
import localforage from "localforage";
import {SAVE_DICT_KEY, SAVE_SETTING_KEY} from "@/utils/const.ts";
import {BaseState, DefaultBaseState} from "@/stores/base.ts";
import {DefaultSettingState, SettingState} from "@/stores/setting.ts";
@@ -13,7 +12,7 @@ export function no() {
ElMessage.warning('未现实')
}
export function checkAndUpgradeSaveDict(val: string) {
export function checkAndUpgradeSaveDict(val: any) {
// console.log(configStr)
// console.log('s', new Blob([val]).size)
// val = ''
@@ -43,6 +42,42 @@ export function checkAndUpgradeSaveDict(val: string) {
}
return defaultBaseState
} else {
if (version <= 3) {
// if (false) {
let temp = (list: any[]): any[] => {
return list.map(a => {
return {
word: a.name,
trans: a.trans.map(b => {
return {
cn: b,
}
}),
phonetic0: a.usphone,
phonetic1: a.ukphone,
}
})
}
state.myDictList.map(v => {
if ([DictType.collect, DictType.simple, DictType.wrong].includes(v.type)) {
v.originWords = temp(v.originWords)
if (v.words) v.words = temp(v.words)
v.chapterWords.map((s, i) => {
v.chapterWords[i] = temp(s)
})
} else {
if (v.isCustom) {
if (v.type === DictType.word) {
v.originWords = temp(v.originWords)
if (v.words) v.words = temp(v.words)
v.chapterWords.map((s, i) => {
v.chapterWords[i] = temp(s)
})
}
}
}
})
}
//防止人为删除数据,导致数据不完整报错
for (const [key, value] of Object.entries(defaultBaseState)) {
if (state[key] !== undefined) defaultBaseState[key] = state[key]
@@ -56,7 +91,7 @@ export function checkAndUpgradeSaveDict(val: string) {
return {}
}
export function checkAndUpgradeSaveSetting(val: string) {
export function checkAndUpgradeSaveSetting(val: any) {
// console.log(configStr)
// console.log('s', new Blob([val]).size)
// val = ''
@@ -124,6 +159,6 @@ export function shakeCommonDict(n: BaseState): BaseState {
return data
}
export function isMobile():boolean {
export function isMobile(): boolean {
return /Mobi|Android|iPhone/i.test(navigator.userAgent)
}