fix(admin): standardize resource initialization and lists

This commit is contained in:
2026-08-05 12:19:13 +08:00
parent d88e18bd09
commit 2162fe5e11
36 changed files with 419 additions and 267 deletions

View File

@@ -199,6 +199,28 @@ const fieldLabels: Record<string, string> = {
path: '路由',
menu_identities: '菜单权限',
status: '状态',
confirm_type: '确认方式',
delivery_basic_identity: '配送点唯一标识',
description: '说明',
ec_category_identity: '商品分类唯一标识',
ec_product_identity: '商品唯一标识',
gas_basic_identity: '气站唯一标识',
gasorder_contract_identity: '配送合同唯一标识',
gasorder_contract_product_identities: '合同气瓶唯一标识',
producer_account_identity: '生产商唯一标识',
product_info_identity: '智能气阀唯一标识',
product_type_identity: '智能气阀类型唯一标识',
proof_uri: '凭证地址',
recipient_name: '签收人姓名',
recipient_phone: '签收人电话',
staff_account_identity: '工作人员唯一标识',
subject_identity: '结算主体唯一标识',
user_account_identity: '用户唯一标识',
user_address_identity: '用户地址唯一标识',
wallet_bank_identity: '银行卡唯一标识',
wallet_basic_identity: '钱包唯一标识',
warehouse_identity: '库房唯一标识',
withdrawable: '计入可提现余额',
};
const numbers = new Set([
@@ -224,6 +246,8 @@ const textareas = new Set([
]);
function f(key: string, options: Partial<ResourceField> = {}): ResourceField {
const label = fieldLabels[key];
if (!label) throw new Error(`资源字段缺少中文名称:${key}`);
const type: ResourceFieldType = key.endsWith('_identity')
? 'identity'
: money.has(key)
@@ -241,7 +265,7 @@ function f(key: string, options: Partial<ResourceField> = {}): ResourceField {
: key === 'password'
? 'password'
: 'text';
return { key, label: fieldLabels[key] ?? key, type, ...options };
return { key, label, type, ...options };
}
function relation(key: string, resource: string, required = false): ResourceField {