feat:重构代码

This commit is contained in:
zyronon
2025-07-12 02:25:30 +08:00
parent 6bf6d8638e
commit cd4a779e6e
32 changed files with 789 additions and 317 deletions

18
src/utils/article.ts Normal file
View File

@@ -0,0 +1,18 @@
import {Dict, DictResource, getDefaultDict} from "@/types.ts";
import {getDictFile} from "@/utils/index.ts";
import {cloneDeep} from "lodash-es";
import {nanoid} from "nanoid";
export async function getArticleBookDataByUrl(val: DictResource) {
let dictResourceUrl = `./dicts/${val.language}/${val.type}/${val.translateLanguage}/${val.url}`;
let s = await getDictFile(dictResourceUrl)
let articles = cloneDeep(s.map(v => {
v.id = nanoid(6)
return v
}))
return cloneDeep({
...getDefaultDict(),
...val,
articles
})
}