功能:按资源配置平台列表搜索
This commit is contained in:
@@ -32,6 +32,11 @@ const embeddedResources = new Set([
|
||||
'payment_refund',
|
||||
'wallet_apply_cash',
|
||||
]);
|
||||
const fieldLabelKeys = new Set(
|
||||
[...source.matchAll(/^\s{2}([a-z0-9_]+):\s*'/gm)].map(
|
||||
(match) => match[1],
|
||||
),
|
||||
);
|
||||
|
||||
for (const name of frontendNames) {
|
||||
const item = backend.get(name);
|
||||
@@ -50,8 +55,31 @@ for (const item of contract.resources) {
|
||||
);
|
||||
if (!embeddedResources.has(item.name) && !routes.includes(`'/${item.name}'`))
|
||||
throw new Error(`缺少后端资源路由:${item.name}`);
|
||||
const searchKeys = new Set();
|
||||
for (const field of item.searchFields ?? []) {
|
||||
if (searchKeys.has(field.key))
|
||||
throw new Error(`搜索字段重复:${item.name}.${field.key}`);
|
||||
searchKeys.add(field.key);
|
||||
if (!fieldLabelKeys.has(field.key))
|
||||
throw new Error(`搜索字段缺少中文列名:${item.name}.${field.key}`);
|
||||
if (!['text', 'enum'].includes(field.kind))
|
||||
throw new Error(`搜索字段类型无效:${item.name}.${field.key}`);
|
||||
if (field.kind === 'enum') {
|
||||
if (!field.values?.length)
|
||||
throw new Error(`搜索枚举缺少值:${item.name}.${field.key}`);
|
||||
for (const value of field.values) {
|
||||
if (!value.value || !value.label || value.value === value.label)
|
||||
throw new Error(`搜索枚举中英文映射无效:${item.name}.${field.key}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (item.pageKind === 'tree' && searchKeys.size)
|
||||
throw new Error(`树形资源不应声明标准列表搜索:${item.name}`);
|
||||
}
|
||||
|
||||
if (backend.get('user_address')?.searchFields?.length)
|
||||
throw new Error('用户地址包含动态用户关系,本轮必须隐藏搜索框');
|
||||
|
||||
const forbidden = [
|
||||
'/platform/platform_',
|
||||
'/gas/gas_',
|
||||
|
||||
Reference in New Issue
Block a user