后台:json上传

This commit is contained in:
luying
2021-05-12 18:56:47 +08:00
parent 2fc5017af8
commit 148a11edab
102 changed files with 1675 additions and 1117 deletions
+13 -11
View File
@@ -1,5 +1,5 @@
// 物品表
import { decodeArrayListStr, readJsonFile, parseGoodStr } from '../util'
import { decodeArrayListStr, readFileAndParse, parseGoodStr } from '../util'
import { FILENAME, ABI_TYPE} from '../../consts'
const _ = require('lodash');
@@ -19,9 +19,6 @@ export interface DicTitle {
readonly material:Array<{id: number, number: number}>;
}
const str = readJsonFile(FILENAME.DIC_TITLE);
let arr = JSON.parse(str);
type KeysEnum<T> = { [P in keyof Required<T>]: true };
const DicTitleKeys: KeysEnum<DicTitle> = {
id: true,
@@ -31,14 +28,19 @@ const DicTitleKeys: KeysEnum<DicTitle> = {
material: true
}
export const dicTitle = new Map<number, DicTitle>();
arr.forEach(o => {
o.mainAttrValue = parseMainAttr(o);
o.assiAttrValue = parseAttr(o.assiAttrValue);
o.material = parseGoodStr(o.material);
dicTitle.set(o.id, _.pick(o, Object.keys(DicTitleKeys)));
});
export function loadTitle() {
arr = undefined;
let arr = readFileAndParse(FILENAME.DIC_TITLE);
arr.forEach(o => {
o.mainAttrValue = parseMainAttr(o);
o.assiAttrValue = parseAttr(o.assiAttrValue);
o.material = parseGoodStr(o.material);
dicTitle.set(o.id, _.pick(o, Object.keys(DicTitleKeys)));
});
arr = undefined;
}
function parseAttr(str: string) {
let result = new Map<number, number>();