feat: 自行开发设计 ui样式优化 超管端-控制台 相关的页面

This commit is contained in:
zhanjunhao
2026-11-09 21:45:37 +08:00
parent 9fc5fd212d
commit 28e924e371
242 changed files with 9242 additions and 5043 deletions
@@ -17,7 +17,8 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
For commercial licensing, please contact support@quantumnous.com
*/
import React, { useState, useEffect, useRef, useMemo } from 'react';
import '../../../console/module-alignment.css';
import React, { useState, useEffect, useRef } from 'react';
import JSONEditor from '../../../common/ui/JSONEditor';
import {
SideSheet,
@@ -27,18 +28,17 @@ import {
Spin,
Typography,
Card,
Tag,
Avatar,
Col,
Row,
} from '@/components/ui';
import { Save, X, FileText } from 'lucide-react';
import { FileText } from 'lucide-react';
import { IconLink } from '@/components/ui/icons';
import { API, showError, showSuccess } from '../../../../helpers';
import { useTranslation } from 'react-i18next';
import { useIsMobile } from '../../../../hooks/common/useIsMobile';
const { Text, Title } = Typography;
const { Text } = Typography;
// Example endpoint template for quick fill
const ENDPOINT_TEMPLATE = {
@@ -63,7 +63,6 @@ const EditModelModal = (props) => {
const isMobile = useIsMobile();
const formApiRef = useRef(null);
const isEdit = props.editingModel && props.editingModel.id !== undefined;
const placement = useMemo(() => (isEdit ? 'right' : 'left'), [isEdit]);
// 供应商列表
const [vendors, setVendors] = useState([]);
@@ -308,51 +307,26 @@ const EditModelModal = (props) => {
return (
<SideSheet
placement={placement}
title={
<Space>
{isEdit ? (
<Tag color='blue' shape='circle'>
{t('更新')}
</Tag>
) : (
<Tag color='green' shape='circle'>
{t('新建')}
</Tag>
)}
<Title heading={4} className='m-0'>
{isEdit ? t('更新模型信息') : t('创建新的模型')}
</Title>
</Space>
}
rootClassName='console-model-drawer'
classNames={{ header: 'console-model-editor-header' }}
placement='right'
title={isEdit ? t('更新模型信息') : t('创建新的模型')}
bodyStyle={{ padding: '0' }}
visible={props.visiable}
width={isMobile ? '100%' : 600}
footer={
<div className='flex justify-end'>
<Space>
<Button
theme='solid'
className='!rounded-lg'
onClick={() => formApiRef.current?.submitForm()}
icon={<Save size={16} />}
loading={loading}
>
{t('提交')}
</Button>
<Button
theme='light'
className='!rounded-lg'
type='primary'
onClick={handleCancel}
icon={<X size={16} />}
>
{t('取消')}
</Button>
</Space>
<div className='console-model-footer'>
<Button onClick={handleCancel}>{t('取消')}</Button>
<Button
theme='solid'
type='primary'
onClick={() => formApiRef.current?.submitForm()}
loading={loading}
>
{t('确定')}
</Button>
</div>
}
closeIcon={null}
onCancel={() => handleCancel()}
>
<Spin spinning={loading}>
@@ -366,8 +340,8 @@ const EditModelModal = (props) => {
<div className='p-2'>
{/* 基本信息 */}
<Card className='!rounded-2xl shadow-sm border-0'>
<div className='flex items-center mb-2'>
<Avatar size='small' color='green' className='mr-2 shadow-md'>
<div className='console-model-section'>
<Avatar size='small' color='green'>
<FileText size={16} />
</Avatar>
<div>
@@ -470,7 +444,7 @@ const EditModelModal = (props) => {
style={{ width: '100%' }}
{...(tagGroups.length > 0 && {
extraText: (
<Space wrap>
<Space wrap className='console-model-tag-presets'>
{tagGroups.map((group) => (
<Button
key={group.id}
@@ -602,7 +576,7 @@ const EditModelModal = (props) => {
)}
/>
</Col>
<Col span={24}>
<Col span={24} className='console-model-endpoints'>
<JSONEditor
field='endpoints'
label={t('端点映射')}
@@ -615,6 +589,7 @@ const EditModelModal = (props) => {
}
formApi={formApiRef.current}
editorType='object'
objectValueAutoSize={{ minRows: 3, maxRows: 8 }}
template={ENDPOINT_TEMPLATE}
templateLabel={t('填入模板')}
extraText={t('留空则使用默认端点;支持 {path, method}')}
@@ -17,28 +17,14 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
For commercial licensing, please contact support@quantumnous.com
*/
import '../../../console/module-alignment.css';
import React, { useState, useRef, useEffect } from 'react';
import JSONEditor from '../../../common/ui/JSONEditor';
import {
SideSheet,
Button,
Form,
Typography,
Space,
Tag,
Row,
Col,
Card,
Avatar,
Spin,
} from '@/components/ui';
import { IconLayers, IconSave, IconClose } from '@/components/ui/icons';
import { Modal, Form, Row, Col, Spin } from '@/components/ui';
import { API, showError, showSuccess } from '../../../../helpers';
import { useTranslation } from 'react-i18next';
import { useIsMobile } from '../../../../hooks/common/useIsMobile';
const { Text, Title } = Typography;
// Example endpoint template for quick fill
const ENDPOINT_TEMPLATE = {
openai: { path: '/v1/chat/completions', method: 'POST' },
@@ -112,53 +98,13 @@ const EditPrefillGroupModal = ({
};
return (
<SideSheet
placement='left'
title={
<Space>
{isEdit ? (
<Tag color='blue' shape='circle'>
{t('更新')}
</Tag>
) : (
<Tag color='green' shape='circle'>
{t('新建')}
</Tag>
)}
<Title heading={4} className='m-0'>
{isEdit ? t('更新预填组') : t('创建新的预填组')}
</Title>
</Space>
}
<Modal
title={isEdit ? t('更新预填组') : t('创建新的预填组')}
visible={visible}
onCancel={onClose}
width={isMobile ? '100%' : 600}
bodyStyle={{ padding: '0' }}
footer={
<div className='flex justify-end'>
<Space>
<Button
theme='solid'
className='!rounded-lg'
onClick={() => formRef.current?.submitForm()}
icon={<IconSave />}
loading={loading}
>
{t('提交')}
</Button>
<Button
theme='light'
className='!rounded-lg'
type='primary'
onClick={onClose}
icon={<IconClose />}
>
{t('取消')}
</Button>
</Space>
</div>
}
closeIcon={null}
onOk={() => formRef.current?.submitForm()}
confirmLoading={loading}
size={isMobile ? 'full-width' : 'small'}
>
<Spin spinning={loading}>
<Form
@@ -185,89 +131,71 @@ const EditPrefillGroupModal = ({
}}
onSubmit={handleSubmit}
>
<div className='p-2'>
{/* 基本信息 */}
<Card className='!rounded-2xl shadow-sm border-0'>
<div className='flex items-center mb-2'>
<Avatar size='small' color='green' className='mr-2 shadow-md'>
<IconLayers size={16} />
</Avatar>
<div>
<Text className='text-lg font-medium'>{t('基本信息')}</Text>
<div className='text-xs text-gray-600'>
{t('设置预填组的基本信息')}
</div>
</div>
</div>
<Row gutter={12}>
<Col span={24}>
<Form.Input
field='name'
label={t('组名')}
placeholder={t('请输入组名')}
rules={[{ required: true, message: t('请输入组名') }]}
showClear
/>
</Col>
<Col span={24}>
<Form.Select
field='type'
label={t('类型')}
placeholder={t('选择组类型')}
optionList={typeOptions}
rules={[{ required: true, message: t('请选择组类型') }]}
style={{ width: '100%' }}
onChange={(val) => setSelectedType(val)}
/>
</Col>
<Col span={24}>
<Form.TextArea
field='description'
label={t('描述')}
placeholder={t('请输入组描述')}
rows={3}
showClear
/>
</Col>
<Col span={24}>
{selectedType === 'endpoint' ? (
<JSONEditor
field='items'
label={t('端点映射')}
value={
formRef.current?.getValue('items') ??
(typeof editingGroup?.items === 'string'
? editingGroup.items
: JSON.stringify(editingGroup.items || {}, null, 2))
}
onChange={(val) =>
formRef.current?.setValue('items', val)
}
editorType='object'
placeholder={
'{\n "openai": {"path": "/v1/chat/completions", "method": "POST"}\n}'
}
template={ENDPOINT_TEMPLATE}
templateLabel={t('填入模板')}
extraText={t('键为端点类型,值为路径和方法对象')}
/>
) : (
<Form.TagInput
field='items'
label={t('项目')}
placeholder={t('输入项目名称,按回车添加')}
addOnBlur
showClear
style={{ width: '100%' }}
/>
)}
</Col>
</Row>
</Card>
</div>
<Row gutter={12}>
<Col span={24}>
<Form.Input
field='name'
label={t('组名')}
placeholder={t('请输入组名')}
rules={[{ required: true, message: t('请输入组名') }]}
showClear
/>
</Col>
<Col span={24}>
<Form.Select
field='type'
label={t('类型')}
placeholder={t('选择组类型')}
optionList={typeOptions}
rules={[{ required: true, message: t('请选择组类型') }]}
style={{ width: '100%' }}
onChange={(val) => setSelectedType(val)}
/>
</Col>
<Col span={24}>
<Form.TextArea
field='description'
label={t('描述')}
placeholder={t('请输入组描述')}
rows={3}
showClear
/>
</Col>
<Col span={24}>
{selectedType === 'endpoint' ? (
<JSONEditor
field='items'
label={t('端点映射')}
value={
formRef.current?.getValue('items') ??
(typeof editingGroup?.items === 'string'
? editingGroup.items
: JSON.stringify(editingGroup.items || {}, null, 2))
}
onChange={(val) => formRef.current?.setValue('items', val)}
editorType='object'
placeholder={
'{\n "openai": {"path": "/v1/chat/completions", "method": "POST"}\n}'
}
template={ENDPOINT_TEMPLATE}
templateLabel={t('填入模板')}
extraText={t('键为端点类型,值为路径和方法对象')}
/>
) : (
<Form.TagInput
field='items'
label={t('项目')}
placeholder={t('输入项目名称,按回车添加')}
addOnBlur
showClear
style={{ width: '100%' }}
/>
)}
</Col>
</Row>
</Form>
</Spin>
</SideSheet>
</Modal>
);
};
@@ -37,6 +37,7 @@ import { MODEL_TABLE_PAGE_SIZE } from '../../../../constants';
import { useIsMobile } from '../../../../hooks/common/useIsMobile';
const MissingModelsModal = ({ visible, onClose, onConfigureModel, t }) => {
const [paginationSize, setPaginationSize] = useState(MODEL_TABLE_PAGE_SIZE);
const [loading, setLoading] = useState(false);
const [missingModels, setMissingModels] = useState([]);
const [searchKeyword, setSearchKeyword] = useState('');
@@ -74,8 +75,8 @@ const MissingModelsModal = ({ visible, onClose, onConfigureModel, t }) => {
);
const dataSource = (() => {
const start = (currentPage - 1) * MODEL_TABLE_PAGE_SIZE;
const end = start + MODEL_TABLE_PAGE_SIZE;
const start = (currentPage - 1) * paginationSize;
const end = start + paginationSize;
return filteredModels.slice(start, end).map((model) => ({
model,
key: model,
@@ -169,10 +170,14 @@ const MissingModelsModal = ({ visible, onClose, onConfigureModel, t }) => {
dataSource={dataSource}
pagination={{
currentPage: currentPage,
pageSize: MODEL_TABLE_PAGE_SIZE,
pageSize: paginationSize,
total: filteredModels.length,
showSizeChanger: false,
onPageChange: (page) => setCurrentPage(page),
onPageSizeChange: (size) => {
setCurrentPage(1);
setPaginationSize(size);
},
}}
/>
) : (
@@ -17,7 +17,8 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
For commercial licensing, please contact support@quantumnous.com
*/
import React, { useState, useEffect } from 'react';
import '../../../console/module-alignment.css';
import React, { useState, useEffect, useCallback } from 'react';
import {
SideSheet,
Button,
@@ -50,7 +51,7 @@ import {
renderDescription,
} from '../../../common/ui/RenderUtils';
const { Text, Title } = Typography;
const { Text } = Typography;
const PrefillGroupManagement = ({ visible, onClose }) => {
const { t } = useTranslation();
@@ -67,7 +68,7 @@ const PrefillGroupManagement = ({ visible, onClose }) => {
];
// 加载组列表
const loadGroups = async () => {
const loadGroups = useCallback(async () => {
setLoading(true);
try {
const res = await API.get('/api/prefill_group');
@@ -80,7 +81,7 @@ const PrefillGroupManagement = ({ visible, onClose }) => {
showError(t('获取组列表失败'));
}
setLoading(false);
};
}, [t]);
// 删除组
const deleteGroup = async (id) => {
@@ -193,20 +194,20 @@ const PrefillGroupManagement = ({ visible, onClose }) => {
},
},
{
title: '',
title: t('操作'),
key: 'action',
fixed: 'right',
width: 140,
render: (_, record) => (
<Space>
<Button size='small' onClick={() => handleEdit(record)}>
<Space className='console-module-row-actions'>
<Button type='link' size='small' onClick={() => handleEdit(record)}>
{t('编辑')}
</Button>
<Popconfirm
title={t('确定删除此组?')}
onConfirm={() => deleteGroup(record.id)}
>
<Button size='small' type='danger'>
<Button size='small' type='link' danger>
{t('删除')}
</Button>
</Popconfirm>
@@ -219,33 +220,25 @@ const PrefillGroupManagement = ({ visible, onClose }) => {
if (visible) {
loadGroups();
}
}, [visible]);
}, [visible, loadGroups]);
return (
<>
<SideSheet
placement='left'
title={
<Space>
<Tag color='blue' shape='circle'>
{t('管理')}
</Tag>
<Title heading={4} className='m-0'>
{t('预填组管理')}
</Title>
</Space>
}
rootClassName='console-model-drawer'
placement='right'
title={t('预填组管理')}
classNames={{ header: 'prefill-management-header' }}
visible={visible}
onCancel={onClose}
width={isMobile ? '100%' : 800}
bodyStyle={{ padding: '0' }}
closeIcon={null}
>
<Spin spinning={loading}>
<div className='p-2'>
<Card className='!rounded-2xl shadow-sm border-0'>
<div className='flex items-center mb-2'>
<Avatar size='small' color='blue' className='mr-2 shadow-md'>
<div className='console-model-section'>
<Avatar size='small' color='blue'>
<IconLayers size={16} />
</Avatar>
<div>
@@ -257,6 +250,7 @@ const PrefillGroupManagement = ({ visible, onClose }) => {
</div>
<div className='flex justify-end mb-4'>
<Button
className='console-create-action'
type='primary'
theme='solid'
size='small'
@@ -41,7 +41,7 @@ const SyncWizardModal = ({ visible, onClose, onConfirm, loading, t }) => {
visible={visible}
onCancel={onClose}
footer={
<div className='flex justify-end'>
<div className='console-model-footer'>
{step === 1 && (
<Button onClick={() => setStep(0)}>{t('上一步')}</Button>
)}
@@ -49,6 +49,7 @@ const SyncWizardModal = ({ visible, onClose, onConfirm, loading, t }) => {
{step === 0 && (
<Button
type='primary'
theme='solid'
onClick={() => setStep(1)}
disabled={option !== 'official'}
>
@@ -69,7 +70,7 @@ const SyncWizardModal = ({ visible, onClose, onConfirm, loading, t }) => {
)}
</div>
}
width={isMobile ? '100%' : 'small'}
width={isMobile ? '100%' : '65%'}
>
<div className='mb-3'>
<Steps type='basic' current={step} size='small'>
@@ -54,6 +54,7 @@ const UpstreamConflictModal = ({
t,
loading = false,
}) => {
const [paginationSize, setPaginationSize] = useState(MODEL_TABLE_PAGE_SIZE);
const [selections, setSelections] = useState({});
const isMobile = useIsMobile();
const [currentPage, setCurrentPage] = useState(1);
@@ -247,10 +248,10 @@ const UpstreamConflictModal = ({
]);
const pagedDataSource = useMemo(() => {
const start = (currentPage - 1) * MODEL_TABLE_PAGE_SIZE;
const end = start + MODEL_TABLE_PAGE_SIZE;
const start = (currentPage - 1) * paginationSize;
const end = start + paginationSize;
return filteredDataSource.slice(start, end);
}, [filteredDataSource, currentPage]);
}, [filteredDataSource, currentPage, paginationSize]);
const handleOk = async () => {
const payload = Object.entries(selections)
@@ -302,10 +303,14 @@ const UpstreamConflictModal = ({
dataSource={pagedDataSource}
pagination={{
currentPage: currentPage,
pageSize: MODEL_TABLE_PAGE_SIZE,
pageSize: paginationSize,
total: filteredDataSource.length,
showSizeChanger: false,
onPageChange: (page) => setCurrentPage(page),
onPageSizeChange: (size) => {
setCurrentPage(1);
setPaginationSize(size);
},
}}
scroll={{ x: 'max-content' }}
/>