优化购物车关联名称展示
This commit is contained in:
@@ -79,6 +79,29 @@ for (const [key, label] of [
|
||||
}
|
||||
}
|
||||
|
||||
// 购物车关联列必须展示用户和商品名称,UUID仅作为复制与排障信息保留。
|
||||
const cartDefinition = resources.match(
|
||||
/define\('ec_cart',[\s\S]*?\n\s*\]\),/,
|
||||
)?.[0];
|
||||
if (!cartDefinition) throw new Error('无法读取购物车资源定义');
|
||||
for (const [key, label] of [
|
||||
['user_account_identity', '用户'],
|
||||
['ec_product_identity', '商品'],
|
||||
]) {
|
||||
const field = cartDefinition.match(
|
||||
new RegExp(`relation\\('${key}'[\\s\\S]*?\\}\\)`),
|
||||
)?.[0];
|
||||
if (
|
||||
!field ||
|
||||
!field.includes(`listLabel: '${label}'`) ||
|
||||
!field.includes('listRelationNameOnly: true') ||
|
||||
!field.includes('displayRelationLabel: true') ||
|
||||
!field.includes('showIdentityCopy: true')
|
||||
) {
|
||||
throw new Error(`购物车的${label}列必须以业务名称展示并保留唯一标识复制入口`);
|
||||
}
|
||||
}
|
||||
|
||||
if (/title="ID"|data-index="id"/.test(listPage)) {
|
||||
throw new Error('标准资源列表不得把数据库ID作为业务列展示');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user