fix: polish channel groups and add production deployment
This commit is contained in:
@@ -5,7 +5,6 @@ const pageTitleMap: Record<string, string> = {
|
||||
'/client/templates': '模板管理',
|
||||
'/client/signatures': '签名与引流信息',
|
||||
'/client/billing': '充值套餐',
|
||||
'/client/invoices': '账单流水',
|
||||
'/client/settings': '账号设置',
|
||||
'/admin/monitor': '发送监控',
|
||||
'/admin/analytics': '数据统计',
|
||||
@@ -13,7 +12,6 @@ const pageTitleMap: Record<string, string> = {
|
||||
'/admin/templates': '模板审核',
|
||||
'/admin/signatures': '签名审核',
|
||||
'/admin/channels': '通道管理',
|
||||
'/admin/billing': '账单流水',
|
||||
'/admin/settings': '系统配置',
|
||||
};
|
||||
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
import type { ReactNode } from 'react';
|
||||
import { useEffect, useMemo, useState } from 'react';
|
||||
import { Pagination } from './PagePrimitives';
|
||||
|
||||
export type TableColumn<T> = {
|
||||
key: string;
|
||||
@@ -13,13 +15,26 @@ type TableProps<T> = {
|
||||
data: T[];
|
||||
rowKey: keyof T | ((record: T) => string);
|
||||
emptyText?: string;
|
||||
pagination?: boolean;
|
||||
pageSize?: number;
|
||||
};
|
||||
|
||||
export function Table<T>({ columns, data, rowKey, emptyText = '暂无数据' }: TableProps<T>) {
|
||||
export function Table<T>({ columns, data, rowKey, emptyText = '暂无数据', pageSize = 10, pagination = true }: TableProps<T>) {
|
||||
const [page, setPage] = useState(1);
|
||||
const minimumTableWidth = columns.reduce((sum, column) => {
|
||||
const match = column.width?.match(/^(\d+)px$/);
|
||||
return sum + (match ? Number(match[1]) : 0);
|
||||
}, 0);
|
||||
const totalPages = Math.max(1, Math.ceil(data.length / pageSize));
|
||||
const activePage = Math.min(page, totalPages);
|
||||
const visibleData = useMemo(
|
||||
() => pagination ? data.slice((activePage - 1) * pageSize, activePage * pageSize) : data,
|
||||
[activePage, data, pageSize, pagination],
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
setPage(1);
|
||||
}, [data, pageSize]);
|
||||
|
||||
function getRowKey(record: T) {
|
||||
if (typeof rowKey === 'function') {
|
||||
@@ -50,14 +65,14 @@ export function Table<T>({ columns, data, rowKey, emptyText = '暂无数据' }:
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{data.length === 0 ? (
|
||||
{visibleData.length === 0 ? (
|
||||
<tr>
|
||||
<td className="ui-table__empty" colSpan={columns.length}>
|
||||
{emptyText}
|
||||
</td>
|
||||
</tr>
|
||||
) : (
|
||||
data.map((record, index) => (
|
||||
visibleData.map((record, index) => (
|
||||
<tr key={getRowKey(record)}>
|
||||
{columns.map((column) => (
|
||||
<td
|
||||
@@ -72,6 +87,16 @@ export function Table<T>({ columns, data, rowKey, emptyText = '暂无数据' }:
|
||||
)}
|
||||
</tbody>
|
||||
</table>
|
||||
{pagination && data.length > pageSize ? (
|
||||
<Pagination
|
||||
nextDisabled={activePage >= totalPages}
|
||||
onNext={() => setPage((current) => Math.min(totalPages, current + 1))}
|
||||
onPrevious={() => setPage((current) => Math.max(1, current - 1))}
|
||||
page={activePage}
|
||||
previousDisabled={activePage <= 1}
|
||||
total={data.length}
|
||||
/>
|
||||
) : null}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user