feat: 自行开发设计 ui样式优化 超管端-控制台 相关的页面
This commit is contained in:
@@ -17,6 +17,40 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
For commercial licensing, please contact support@quantumnous.com
|
||||
*/
|
||||
|
||||
import i18next from 'i18next';
|
||||
|
||||
export const isCenterPaginationScope = () =>
|
||||
typeof window !== 'undefined' &&
|
||||
/^\/(console|org)(\/|$)/.test(window.location?.pathname || '');
|
||||
|
||||
export const centerPaginationOptions = (config, isMobile = false) => ({
|
||||
...config,
|
||||
className: ['center-pagination', config.className].filter(Boolean).join(' '),
|
||||
size: 'small',
|
||||
showSizeChanger: true,
|
||||
showQuickJumper: isMobile,
|
||||
pageSizeOptions: [10, 20, 50, 100],
|
||||
showTotal: (total) => i18next.t('共 {{total}} 条', { total }),
|
||||
});
|
||||
|
||||
// Ant emits both size and page notifications for one resize. Dispatch one request.
|
||||
export function centerPaginationEvents(config) {
|
||||
const { onPageChange, onPageSizeChange, onChange, onShowSizeChange } = config;
|
||||
return {
|
||||
onChange(page, size) {
|
||||
if (size !== (config.pageSize ?? 10)) {
|
||||
if (onPageSizeChange) onPageSizeChange(size);
|
||||
else if (onShowSizeChange) onShowSizeChange(1, size);
|
||||
else onChange?.(1, size);
|
||||
return;
|
||||
}
|
||||
onPageChange?.(page);
|
||||
onChange?.(page, size);
|
||||
},
|
||||
onShowSizeChange: undefined,
|
||||
};
|
||||
}
|
||||
|
||||
// Legacy pagination accepts a boolean; Ant Design calls a renderer when enabled.
|
||||
export const paginationShowTotal = (showTotal) =>
|
||||
showTotal === true ? (total) => `${total}` : showTotal;
|
||||
|
||||
Reference in New Issue
Block a user