feat: 参考原型图 ui优化提交 企业端-企业中心 相关的页面

This commit is contained in:
zhanjunhao
2026-11-06 20:19:43 +08:00
parent d4495eb703
commit 84803192ba
147 changed files with 9816 additions and 8768 deletions
+56
View File
@@ -23,6 +23,9 @@ import { paginationEvents } from '../src/components/ui/pagination.js';
import test from 'node:test';
import { runInNewContext } from 'node:vm';
import React from 'react';
import { renderToStaticMarkup } from 'react-dom/server';
import * as Ant from 'antd';
import * as pagination from '../src/components/ui/pagination.js';
import { transformWithEsbuild } from 'vite';
async function compile(relativePath) {
@@ -156,3 +159,56 @@ for (const isMobile of [false, true]) {
assert.deepEqual(calls, [['page', 2]]);
});
}
const loadUi = await compile('../src/components/ui/index.jsx');
const { Table, Pagination } = loadUi({
react: React,
antd: Ant,
'./controls': { controlSize: (size) => size },
'./pagination': pagination,
'./overlayPolicy': {},
'./form': {},
'./chat': {},
});
for (const [name, render] of [
[
'Table',
(props) =>
Table({
columns: [{ title: 'Model', dataIndex: 'model' }],
dataSource: [{ key: '1', model: 'test-model' }],
pagination: props,
}),
],
['Pagination', (props) => Pagination(props)],
]) {
test(`${name} renders legacy boolean showTotal without crashing`, () => {
const element = render({ total: 25, pageSize: 10, showTotal: true });
const html = renderToStaticMarkup(element);
assert.match(html, /class="ant-pagination-total-text">25<\/li>/);
});
test(`${name} preserves a custom total renderer and its range arguments`, () => {
const showTotal = (total, range) => `${range.join('-')} of ${total}`;
const element = render({ total: 25, pageSize: 10, showTotal });
const props = name === 'Table' ? element.props.pagination : element.props;
assert.equal(props.showTotal, showTotal);
assert.match(renderToStaticMarkup(element), /1-10 of 25/);
});
for (const showTotal of [false, undefined]) {
test(`${name} hides the total when showTotal is ${showTotal}`, () => {
const html = renderToStaticMarkup(
render({ total: 25, pageSize: 10, showTotal }),
);
assert.doesNotMatch(html, /ant-pagination-total-text/);
});
}
}
test('Table keeps pagination disabled for settings tables without pagination', () => {
const element = Table({ columns: [], dataSource: [], pagination: false });
assert.equal(element.props.pagination, false);
assert.doesNotMatch(renderToStaticMarkup(element), /ant-pagination/);
});