feat: 统一账户角色展示并优化资源页面

This commit is contained in:
czl231
2026-08-11 02:01:00 +08:00
parent 9cf16ccb3c
commit ff345dc42a
28 changed files with 555 additions and 76 deletions

View File

@@ -161,13 +161,21 @@ export function displayResourceField(
field: ResourceField,
row: ResourceRow,
relationOptions: Record<string, ResourceRow[]>,
fieldOptions: Record<string, Array<{ label: string; value: string | number }>> = {},
) {
const value = row[field.key] ?? row[`${field.key}_masked`];
if (value == null || value === '') return field.emptyText ?? '-';
const option = field.options?.find(
const hasOptionSource =
Object.prototype.hasOwnProperty.call(fieldOptions, field.key) ||
Boolean(field.options);
const options = fieldOptions[field.key] ?? field.options;
const option = options?.find(
(item) => String(item.value) === String(value),
);
if (option) return option.label;
if (hasOptionSource && field.unknownValueLabel) {
return `${field.unknownValueLabel}${String(value)}`;
}
if (field.type === 'identity' && typeof value === 'string') {
return relationLabel(field, value, relationOptions);
}