fix: harden real backend admin workflows and ui
This commit is contained in:
@@ -16,6 +16,11 @@ type TableProps<T> = {
|
||||
};
|
||||
|
||||
export function Table<T>({ columns, data, rowKey, emptyText = '暂无数据' }: TableProps<T>) {
|
||||
const minimumTableWidth = columns.reduce((sum, column) => {
|
||||
const match = column.width?.match(/^(\d+)px$/);
|
||||
return sum + (match ? Number(match[1]) : 0);
|
||||
}, 0);
|
||||
|
||||
function getRowKey(record: T) {
|
||||
if (typeof rowKey === 'function') {
|
||||
return rowKey(record);
|
||||
@@ -26,13 +31,18 @@ export function Table<T>({ columns, data, rowKey, emptyText = '暂无数据' }:
|
||||
|
||||
return (
|
||||
<div className="ui-table-wrap">
|
||||
<table className="ui-table">
|
||||
<table className="ui-table" style={{ minWidth: minimumTableWidth ? `${minimumTableWidth}px` : undefined }}>
|
||||
<colgroup>
|
||||
{columns.map((column) => (
|
||||
<col key={column.key} style={{ width: column.width }} />
|
||||
))}
|
||||
</colgroup>
|
||||
<thead>
|
||||
<tr>
|
||||
{columns.map((column) => (
|
||||
<th
|
||||
key={column.key}
|
||||
style={{ width: column.width, textAlign: column.align ?? 'left' }}
|
||||
style={{ minWidth: column.width, width: column.width, textAlign: column.align ?? 'left' }}
|
||||
>
|
||||
{column.title}
|
||||
</th>
|
||||
@@ -52,7 +62,7 @@ export function Table<T>({ columns, data, rowKey, emptyText = '暂无数据' }:
|
||||
{columns.map((column) => (
|
||||
<td
|
||||
key={column.key}
|
||||
style={{ textAlign: column.align ?? 'left' }}
|
||||
style={{ minWidth: column.width, textAlign: column.align ?? 'left', width: column.width }}
|
||||
>
|
||||
{column.render(record, index)}
|
||||
</td>
|
||||
|
||||
Reference in New Issue
Block a user