usefulFn中过去几个没有处理的exception

This commit is contained in:
Xu Chang 2024-02-27 21:50:34 +08:00
parent 4363f9de3e
commit 050219aae0
3 changed files with 75 additions and 101 deletions

View File

@ -45,44 +45,31 @@ export function resolvePath(dataSchema, entity, path) {
idx++;
continue;
}
try {
const relation = judgeRelation(dataSchema, _entity, attr);
if (relation === 1) {
const attributes = getAttributes(dataSchema[_entity].attributes);
attribute = attributes[attr];
attrType = attribute.type;
if (attr === 'id') {
attrType = 'ref';
}
else {
if (attrType === 'ref') {
attr = attribute.ref;
}
const relation = judgeRelation(dataSchema, _entity, attr, true);
if (relation === 1) {
const attributes = getAttributes(dataSchema[_entity].attributes);
attribute = attributes[attr];
attrType = attribute.type;
if (attr === 'id') {
attrType = 'ref';
}
else {
if (attrType === 'ref') {
attr = attribute.ref;
}
}
else if (relation === 2) {
// entity entityId
if (attr === 'entityId') {
attrType = 'ref';
}
_entity = attr;
}
else if (typeof relation === 'string') {
_entity = relation;
}
idx++;
}
catch (err) {
if (process.env.NODE_ENV === 'development') {
console.warn(`存在非「${_entity}」schema属性: ${path}`);
else if (relation === 2) {
// entity entityId
if (attr === 'entityId') {
attrType = 'ref';
}
return {
entity: 'notExist',
attr: path,
attrType: undefined,
attribute,
};
_entity = attr;
}
else if (typeof relation === 'string') {
_entity = relation;
}
idx++;
}
return {
entity: _entity,
@ -123,11 +110,15 @@ export function getLabel(attribute, entity, attr, t) {
}
if (attr === '$$createAt$$' ||
attr === '$$updateAt$$' ||
attr === '$$deleteAt$$') {
attr === '$$deleteAt$$' ||
attr === '$$seq$$') {
return t(`common::${attr}`, {
'#oakModule': 'oak-frontend-base',
});
}
if (attr === 'id') {
return 'id';
}
return t(`${entity}:attr.${attr}`, {});
}
// 目前width属性可以是undefined只有特殊type或用户自定义才有值这样其余attr属性可以自适应

View File

@ -50,44 +50,31 @@ function resolvePath(dataSchema, entity, path) {
idx++;
continue;
}
try {
const relation = (0, relation_1.judgeRelation)(dataSchema, _entity, attr);
if (relation === 1) {
const attributes = getAttributes(dataSchema[_entity].attributes);
attribute = attributes[attr];
attrType = attribute.type;
if (attr === 'id') {
attrType = 'ref';
}
else {
if (attrType === 'ref') {
attr = attribute.ref;
}
const relation = (0, relation_1.judgeRelation)(dataSchema, _entity, attr, true);
if (relation === 1) {
const attributes = getAttributes(dataSchema[_entity].attributes);
attribute = attributes[attr];
attrType = attribute.type;
if (attr === 'id') {
attrType = 'ref';
}
else {
if (attrType === 'ref') {
attr = attribute.ref;
}
}
else if (relation === 2) {
// entity entityId
if (attr === 'entityId') {
attrType = 'ref';
}
_entity = attr;
}
else if (typeof relation === 'string') {
_entity = relation;
}
idx++;
}
catch (err) {
if (process.env.NODE_ENV === 'development') {
console.warn(`存在非「${_entity}」schema属性: ${path}`);
else if (relation === 2) {
// entity entityId
if (attr === 'entityId') {
attrType = 'ref';
}
return {
entity: 'notExist',
attr: path,
attrType: undefined,
attribute,
};
_entity = attr;
}
else if (typeof relation === 'string') {
_entity = relation;
}
idx++;
}
return {
entity: _entity,
@ -131,11 +118,15 @@ function getLabel(attribute, entity, attr, t) {
}
if (attr === '$$createAt$$' ||
attr === '$$updateAt$$' ||
attr === '$$deleteAt$$') {
attr === '$$deleteAt$$' ||
attr === '$$seq$$') {
return t(`common::${attr}`, {
'#oakModule': 'oak-frontend-base',
});
}
if (attr === 'id') {
return 'id';
}
return t(`${entity}:attr.${attr}`, {});
}
exports.getLabel = getLabel;

View File

@ -85,42 +85,30 @@ export function resolvePath<ED extends EntityDict & BaseEntityDict>(
idx++;
continue;
}
try {
const relation = judgeRelation(dataSchema, _entity, attr);
if (relation === 1) {
const attributes = getAttributes(
dataSchema[_entity].attributes
);
attribute = attributes[attr];
attrType = attribute.type;
if (attr === 'id') {
attrType = 'ref';
} else {
if (attrType === 'ref') {
attr = attribute.ref as string;
}
const relation = judgeRelation(dataSchema, _entity, attr, true);
if (relation === 1) {
const attributes = getAttributes(
dataSchema[_entity].attributes
);
attribute = attributes[attr];
attrType = attribute.type;
if (attr === 'id') {
attrType = 'ref';
} else {
if (attrType === 'ref') {
attr = attribute.ref as string;
}
} else if (relation === 2) {
// entity entityId
if (attr === 'entityId') {
attrType = 'ref';
}
_entity = attr as keyof ED;
} else if (typeof relation === 'string') {
_entity = relation as keyof ED;
}
idx++;
} catch (err) {
if (process.env.NODE_ENV === 'development') {
console.warn(`存在非「${_entity as string}」schema属性: ${path}`);
} else if (relation === 2) {
// entity entityId
if (attr === 'entityId') {
attrType = 'ref';
}
return {
entity: 'notExist',
attr: path,
attrType: undefined,
attribute,
};
_entity = attr as keyof ED;
} else if (typeof relation === 'string') {
_entity = relation as keyof ED;
}
idx++;
}
return {
entity: _entity,
@ -174,12 +162,16 @@ export function getLabel<ED extends EntityDict & BaseEntityDict>(
if (
attr === '$$createAt$$' ||
attr === '$$updateAt$$' ||
attr === '$$deleteAt$$'
attr === '$$deleteAt$$' ||
attr === '$$seq$$'
) {
return t(`common::${attr}`, {
'#oakModule': 'oak-frontend-base',
});
}
if (attr === 'id') {
return 'id';
}
return t(`${entity as string}:attr.${attr}`, {});
}