feat: 自行开发设计 ui样式优化 超管端-控制台 相关的页面
This commit is contained in:
@@ -17,13 +17,11 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
For commercial licensing, please contact support@quantumnous.com
|
||||
*/
|
||||
|
||||
import React, { useMemo } from 'react';
|
||||
import { Empty } from '@/components/ui';
|
||||
import TableEmpty from '../../common/table/TableEmpty';
|
||||
import React, { useMemo, useState } from 'react';
|
||||
import CardTable from '../../common/ui/CardTable';
|
||||
import {
|
||||
IllustrationNoResult,
|
||||
IllustrationNoResultDark,
|
||||
} from '../../common/illustrations';
|
||||
|
||||
import { isRoot } from '../../../helpers';
|
||||
import { getChannelsColumns } from './ChannelsColumnDefs';
|
||||
|
||||
const ChannelsTable = (channelsData) => {
|
||||
@@ -34,7 +32,7 @@ const ChannelsTable = (channelsData) => {
|
||||
activePage,
|
||||
pageSize,
|
||||
channelCount,
|
||||
enableBatchDelete,
|
||||
selectedChannels,
|
||||
compactMode,
|
||||
visibleColumns,
|
||||
setSelectedChannels,
|
||||
@@ -66,8 +64,25 @@ const ChannelsTable = (channelsData) => {
|
||||
autoBanExclusionFilter,
|
||||
// Daily quota info
|
||||
dailyQuotaInfo,
|
||||
idSort,
|
||||
setIdSort,
|
||||
enableTagMode,
|
||||
loadChannels,
|
||||
} = channelsData;
|
||||
|
||||
const [idSortOrder, setIdSortOrder] = useState('descend');
|
||||
|
||||
const handleTableChange = ({ sorter, extra, action }) => {
|
||||
if ((action ?? extra?.action) !== 'sort') return;
|
||||
const order = sorter?.columnKey === COLUMN_KEYS.ID ? sorter.order : null;
|
||||
setIdSortOrder(order || 'descend');
|
||||
const nextIdSort = Boolean(order);
|
||||
if (nextIdSort === idSort) return;
|
||||
localStorage.setItem('id-sort', String(nextIdSort));
|
||||
setIdSort(nextIdSort);
|
||||
loadChannels(activePage, pageSize, nextIdSort, enableTagMode);
|
||||
};
|
||||
|
||||
// Filter channels based on auto-ban exclusion filter
|
||||
const filteredChannels = useMemo(() => {
|
||||
if (!autoBanExclusionFilter || autoBanExclusionFilter === 'all') {
|
||||
@@ -174,14 +189,28 @@ const ChannelsTable = (channelsData) => {
|
||||
}, [visibleColumns, allColumns]);
|
||||
|
||||
const tableColumns = useMemo(() => {
|
||||
const sortableColumns = visibleColumnsList.map((column) =>
|
||||
column.key === COLUMN_KEYS.ID
|
||||
? {
|
||||
...column,
|
||||
sorter: (a, b) => {
|
||||
if (a.children !== undefined || b.children !== undefined)
|
||||
return 0;
|
||||
return Number(a.id) - Number(b.id);
|
||||
},
|
||||
sortOrder: idSort ? idSortOrder : null,
|
||||
}
|
||||
: column,
|
||||
);
|
||||
return compactMode
|
||||
? visibleColumnsList.map(({ fixed, ...rest }) => rest)
|
||||
: visibleColumnsList;
|
||||
}, [compactMode, visibleColumnsList]);
|
||||
? sortableColumns.map(({ fixed, ...rest }) => rest)
|
||||
: sortableColumns;
|
||||
}, [compactMode, visibleColumnsList, COLUMN_KEYS.ID, idSort, idSortOrder]);
|
||||
|
||||
return (
|
||||
<CardTable
|
||||
columns={tableColumns}
|
||||
onChange={handleTableChange}
|
||||
dataSource={filteredChannels}
|
||||
scroll={compactMode ? undefined : { x: 'max-content' }}
|
||||
pagination={{
|
||||
@@ -197,24 +226,21 @@ const ChannelsTable = (channelsData) => {
|
||||
expandAllRows={false}
|
||||
onRow={handleRow}
|
||||
rowSelection={
|
||||
enableBatchDelete
|
||||
isRoot()
|
||||
? {
|
||||
selectedRowKeys: selectedChannels.map(
|
||||
(channel) => channel.key ?? String(channel.id),
|
||||
),
|
||||
getCheckboxProps: (record) => ({
|
||||
disabled: record.children !== undefined,
|
||||
}),
|
||||
onChange: (selectedRowKeys, selectedRows) => {
|
||||
setSelectedChannels(selectedRows);
|
||||
},
|
||||
}
|
||||
: null
|
||||
}
|
||||
empty={
|
||||
<Empty
|
||||
image={<IllustrationNoResult style={{ width: 150, height: 150 }} />}
|
||||
darkModeImage={
|
||||
<IllustrationNoResultDark style={{ width: 150, height: 150 }} />
|
||||
}
|
||||
description={t('搜索无结果')}
|
||||
style={{ padding: 30 }}
|
||||
/>
|
||||
}
|
||||
empty={<TableEmpty />}
|
||||
className='rounded-xl overflow-hidden'
|
||||
size='middle'
|
||||
loading={loading || searching}
|
||||
|
||||
Reference in New Issue
Block a user