fix: harden real backend admin workflows and ui

This commit is contained in:
hectorzhao
2026-07-03 19:29:56 +08:00
parent dd09d91c1e
commit 8cca361441
71 changed files with 5111 additions and 4439 deletions
+13 -3
View File
@@ -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>