feat: 1.升级 Ant Design Ui 至 v6 2. 修复企业充值金额输入限制

This commit is contained in:
zhanjunhao
2026-11-10 18:49:38 +08:00
parent 425077f94b
commit fc4db4e75d
106 changed files with 1417 additions and 1010 deletions
+126
View File
@@ -0,0 +1,126 @@
/*
Copyright (C) 2025 QuantumNous
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
For commercial licensing, please contact support@quantumnous.com
*/
import assert from 'node:assert/strict';
import test from 'node:test';
import React from 'react';
import * as Ant from 'antd';
import dayjs from 'dayjs';
import * as pagination from '../../src/components/ui/pagination.js';
import * as overlayPolicy from '../../src/components/ui/overlayPolicy.js';
import { loadFrontendModule } from './frontend-module.js';
const context = {
useConsolePage: () => null,
useConsoleControlSize: (size) => (size === 'default' ? 'middle' : size),
};
const controls = await loadFrontendModule(
new URL('../../src/components/ui/controls.jsx', import.meta.url),
{ react: React, antd: Ant, dayjs, '../console/ConsoleContext': context },
);
const ui = await loadFrontendModule(
new URL('../../src/components/ui/index.jsx', import.meta.url),
{
react: React,
antd: Ant,
'./controls': controls,
'./pagination': pagination,
'./overlayPolicy': overlayPolicy,
'./pagination.css': {},
'./form': {},
'./chat': {},
'../../hooks/common/useIsMobile': { useIsMobile: () => false },
'../console/ConsoleContext': context,
'../console/consoleTableAdapter': {},
'../console/ConsolePrimitives': {},
},
);
test('legacy controls keep value callbacks and remote search behavior in v6', () => {
const values = [];
const input = controls.Input.render(
{ onChange: (...args) => values.push(args) },
null,
);
const event = { target: { value: 'changed' } };
input.props.onChange(event);
assert.equal(values[0][0], 'changed');
assert.equal(values[0][1], event);
const onSearch = () => {};
const select = controls.Select({
remote: true,
multiple: true,
autoClearSearchValue: false,
onSearch,
styles: { popup: { root: { minWidth: 300 } } },
classNames: { popup: { root: 'existing-popup' } },
});
assert.equal(select.props.mode, 'multiple');
assert.equal(select.props.showSearch.enabled, true);
assert.equal(select.props.showSearch.filterOption, false);
assert.equal(select.props.showSearch.autoClearSearchValue, false);
assert.equal(select.props.showSearch.onSearch, onSearch);
assert.equal(select.props.styles.popup.root.minWidth, 300);
assert.equal(select.props.classNames.popup.root, 'existing-popup');
assert.equal(Object.hasOwn(select.props, 'onSearch'), false);
});
test('card semantic styles survive the legacy adapter without losing slots', () => {
const card = ui.Card.render(
{
bodyStyle: { padding: 16 },
styles: { header: { color: 'inherit' } },
},
null,
);
assert.equal(card.props.styles.body.padding, 16);
assert.equal(card.props.styles.header.color, 'inherit');
assert.equal(card.props.size, 'medium');
});
test('overlay migration preserves disabled masks, dismissal policy and drawer dimensions', () => {
const configured = { enabled: false, closable: false, blur: false };
const personal = overlayPolicy.overlayMask(
configured,
false,
'/user-center/settings',
);
assert.equal(personal.enabled, false);
assert.equal(personal.closable, true);
assert.equal(configured.closable, false);
assert.equal(
overlayPolicy.overlayMask(false, false, '/console/token').closable,
false,
);
const onCancel = () => {};
const drawer = ui.SideSheet({ visible: true, width: 560, onCancel });
assert.equal(drawer.props.size, 560);
assert.equal(drawer.props.open, true);
assert.equal(drawer.props.onClose, onCancel);
assert.equal(Object.hasOwn(drawer.props, 'width'), false);
assert.equal(Object.hasOwn(drawer.props, 'maskClosable'), false);
assert.equal(
ui.SideSheet({ placement: 'bottom', height: '75vh' }).props.size,
'75vh',
);
const modal = ui.Modal({ visible: true, mask: false, maskClosable: false });
assert.equal(modal.props.mask.enabled, false);
assert.equal(modal.props.mask.closable, false);
assert.equal(Object.hasOwn(modal.props, 'maskClosable'), false);
});