feat:重构代码
This commit is contained in:
@@ -6,7 +6,7 @@ export const SoundFileOptions = [
|
||||
{value: '笔记本键盘', label: '笔记本键盘'},
|
||||
]
|
||||
|
||||
export const APP_NAME = 'Typing Word'
|
||||
export const APP_NAME = 'Type Words'
|
||||
|
||||
export const SAVE_DICT_KEY = {
|
||||
key: 'typing-word-dict',
|
||||
@@ -20,4 +20,4 @@ export const SAVE_SETTING_KEY = {
|
||||
export const EXPORT_DATA_KEY = {
|
||||
key: 'typing-word-export',
|
||||
version: 1
|
||||
}
|
||||
}
|
||||
|
||||
@@ -120,9 +120,6 @@ export function shakeCommonDict(n: BaseState): BaseState {
|
||||
data.wordDictList.map((v: Dict) => {
|
||||
if (!v.isCustom) v.words = []
|
||||
})
|
||||
data.articleDictList.map((v: Dict) => {
|
||||
if (!v.isCustom) v.articles = []
|
||||
})
|
||||
return data
|
||||
}
|
||||
|
||||
@@ -133,6 +130,7 @@ export function isMobile(): boolean {
|
||||
export function getDictFile(url: string) {
|
||||
return new Promise<any[]>(async resolve => {
|
||||
let r = await fetch(url).catch(r => {
|
||||
console.log('getDictFile_error',r)
|
||||
})
|
||||
let v = await r.json()
|
||||
resolve(v)
|
||||
@@ -177,10 +175,9 @@ export function _fetch(url: string) {
|
||||
export async function _checkDictWords(dict: Dict) {
|
||||
console.log('_checkDictWords', dict)
|
||||
if ([DictType.collect,
|
||||
DictType.simple,
|
||||
DictType.known,
|
||||
DictType.wrong].includes(dict.dictType)) {
|
||||
} else {
|
||||
|
||||
//TODO 需要和其他需要下载的地方统一
|
||||
//如果不是自定义词典,并且有url地址才去下载
|
||||
if (!dict.isCustom && dict.fileName) {
|
||||
@@ -201,7 +198,7 @@ export async function _checkDictWords(dict: Dict) {
|
||||
if (res && res.request.responseURL !== url) {
|
||||
r = res.data
|
||||
} else {
|
||||
let dictLocalUrl = `./dicts/${dict.langTypeStr}/${dict.dictType}/${dict.tranTypeStr}/${dict.fileName}-v${dict.version}.json`;
|
||||
let dictLocalUrl = `./dicts/${dict.language}/${dict.type}/${dict.translateLanguage}/${dict.url}`;
|
||||
let r3 = await fetch(dictLocalUrl)
|
||||
try {
|
||||
r = await r3.json()
|
||||
@@ -286,4 +283,4 @@ export function _parseLRC(lrc: string): { start: number, end: number, text: stri
|
||||
}
|
||||
|
||||
return parsed;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user