后台:json上传
This commit is contained in:
@@ -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>();
|
||||
|
||||
Reference in New Issue
Block a user