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

This commit is contained in:
zhanjunhao
2026-11-09 21:45:37 +08:00
parent 6ad95e2baa
commit 5713d541b0
242 changed files with 9242 additions and 5043 deletions
@@ -18,17 +18,13 @@ For commercial licensing, please contact support@quantumnous.com
*/
import React from 'react';
import {
Button,
Space,
Tag,
Typography,
Modal,
Tooltip,
} from '@/components/ui';
import { Button as AntButton, Tooltip as AntTooltip } from 'antd';
import { Copy } from 'lucide-react';
import { Button, Space, Tag, Modal, Tooltip } from '@/components/ui';
import {
timestamp2string,
getLobeHubIcon,
renderGroup,
stringToColor,
isRoot,
} from '../../../helpers';
@@ -37,8 +33,6 @@ import {
renderDescription,
} from '../../common/ui/RenderUtils';
const { Text } = Typography;
// Render timestamp
function renderTimestamp(timestamp) {
return <>{timestamp2string(timestamp)}</>;
@@ -48,11 +42,7 @@ function renderTimestamp(timestamp) {
const renderModelIconCol = (record, vendorMap) => {
const iconKey = record?.icon || vendorMap[record?.vendor_id]?.icon;
if (!iconKey) return '-';
return (
<div className='flex items-center justify-center'>
{getLobeHubIcon(iconKey, 20)}
</div>
);
return <div className='models-model-icon'>{getLobeHubIcon(iconKey, 20)}</div>;
};
// Render vendor column with icon
@@ -125,9 +115,7 @@ const renderGroups = (groups) => {
return renderLimitedItems({
items: groups,
renderItem: (g, idx) => (
<Tag key={idx} size='small' shape='circle' color={stringToColor(g)}>
{g}
</Tag>
<React.Fragment key={idx}>{renderGroup(g)}</React.Fragment>
),
});
};
@@ -247,14 +235,19 @@ const renderOperations = (
manageModel,
refresh,
t,
setDetailModel,
) => {
return (
<Space wrap>
<Space wrap className='console-module-row-actions'>
<Button type='link' size='small' onClick={() => setDetailModel(record)}>
{t('详情')}
</Button>
{isRoot() && (
<>
{record.status === 1 ? (
<Button
type='danger'
type='link'
danger
size='small'
onClick={() => manageModel(record.id, 'disable', record)}
>
@@ -262,6 +255,7 @@ const renderOperations = (
</Button>
) : (
<Button
type='link'
size='small'
onClick={() => manageModel(record.id, 'enable', record)}
>
@@ -270,7 +264,7 @@ const renderOperations = (
)}
<Button
type='tertiary'
type='link'
size='small'
onClick={() => {
setEditingModel(record);
@@ -281,7 +275,8 @@ const renderOperations = (
</Button>
<Button
type='danger'
type='link'
danger
size='small'
onClick={() => {
Modal.confirm({
@@ -347,8 +342,10 @@ export const getModelsColumns = ({
setEditingModel,
setShowEdit,
refresh,
copyText,
vendorMap,
categoryNames = {},
setDetailModel,
}) => {
return [
{
@@ -362,9 +359,19 @@ export const getModelsColumns = ({
title: t('模型名称'),
dataIndex: 'model_name',
render: (text) => (
<Text copyable onClick={(e) => e.stopPropagation()}>
{text}
</Text>
<span className='models-name-cell' onClick={(e) => e.stopPropagation()}>
<span>{text}</span>
<AntTooltip title={t('复制模型名称')}>
<AntButton
type='text'
size='small'
className='models-name-copy'
aria-label={t('复制模型名称')}
icon={<Copy size={14} />}
onClick={() => copyText(text)}
/>
</AntTooltip>
</span>
),
},
{
@@ -436,7 +443,7 @@ export const getModelsColumns = ({
},
},
{
title: '',
title: t('操作'),
dataIndex: 'operate',
fixed: 'right',
render: (text, record, index) =>
@@ -448,6 +455,7 @@ export const getModelsColumns = ({
manageModel,
refresh,
t,
setDetailModel,
),
},
];
+27 -33
View File
@@ -18,7 +18,9 @@ For commercial licensing, please contact support@quantumnous.com
*/
import React, { useRef } from 'react';
import { Form, Button } from '@/components/ui';
import { Form } from '@/components/ui';
import { ConsoleFilterActions } from '../../console/ConsoleModuleFilters';
import { useFilterSearch } from '../../../hooks/common/useFilterSearch';
import { IconSearch } from '@/components/ui/icons';
import { MODEL_CATEGORY_NAMES } from '../../../constants';
@@ -30,12 +32,17 @@ const ModelsFilters = ({
searching,
t,
}) => {
const { scheduleSearch, submitSearch, cancelPendingSearch } = useFilterSearch(
() => searchModels(),
);
// Handle form reset and immediate search
const formApiRef = useRef(null);
const handleReset = () => {
if (!formApiRef.current) return;
formApiRef.current.reset();
cancelPendingSearch();
setTimeout(() => {
searchModels();
}, 100);
@@ -43,48 +50,52 @@ const ModelsFilters = ({
return (
<Form
initValues={formInitValues}
initValues={{
...formInitValues,
searchCategory: formInitValues.searchCategory || undefined,
}}
getFormApi={(api) => {
setFormApi(api);
formApiRef.current = api;
}}
onSubmit={searchModels}
onSubmit={submitSearch}
allowEmpty={true}
autoComplete='off'
layout='horizontal'
layout='vertical'
trigger='change'
stopValidateWithError={false}
className='w-full md:w-auto order-1 md:order-2'
className='console-module-filter-form'
onValueChange={scheduleSearch}
>
<div className='flex flex-col md:flex-row items-center gap-2 w-full md:w-auto'>
<div className='relative w-full md:w-56'>
<div className='console-module-filter-grid'>
<div className='console-module-field'>
<Form.Input
label={t('模型名称')}
field='searchKeyword'
prefix={<IconSearch />}
placeholder={t('搜索模型名称')}
showClear
pure
size='small'
/>
</div>
<div className='relative w-full md:w-56'>
<div className='console-module-field'>
<Form.Input
label={t('供应商')}
field='searchVendor'
prefix={<IconSearch />}
placeholder={t('搜索供应商')}
showClear
pure
size='small'
/>
</div>
<div className='relative w-full md:w-56'>
<div className='console-module-field'>
<Form.Select
label={t('分类')}
field='searchCategory'
placeholder={t('选择分类')}
showClear
pure
size='small'
style={{ width: '100%' }}
>
@@ -96,28 +107,11 @@ const ModelsFilters = ({
))}
</Form.Select>
</div>
<div className='flex gap-2 w-full md:w-auto'>
<Button
type='tertiary'
htmlType='submit'
loading={loading || searching}
className='flex-1 md:flex-initial md:w-auto'
size='small'
>
{t('查询')}
</Button>
<Button
type='tertiary'
onClick={handleReset}
className='flex-1 md:flex-initial md:w-auto'
size='small'
>
{t('重置')}
</Button>
</div>
</div>
<ConsoleFilterActions
onReset={handleReset}
loading={loading || searching}
/>
</Form>
);
};
+62 -34
View File
@@ -17,17 +17,18 @@ 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 { Descriptions } from 'antd';
import { Modal } from '@/components/ui';
import CardTable from '../../common/ui/CardTable';
import {
IllustrationNoResult,
IllustrationNoResultDark,
} from '../../common/illustrations';
import { getModelsColumns } from './ModelsColumnDefs';
import { useModelCategories } from '../../../hooks/models/useModelCategories';
import './models-vendor-tabs.css';
const ModelsTable = (modelsData) => {
const [detailModel, setDetailModel] = useState(null);
const {
models,
loading,
@@ -44,6 +45,7 @@ const ModelsTable = (modelsData) => {
setShowEdit,
refresh,
vendorMap,
copyText,
t,
} = modelsData;
@@ -60,6 +62,8 @@ const ModelsTable = (modelsData) => {
refresh,
vendorMap,
categoryNames,
setDetailModel,
copyText,
});
}, [
t,
@@ -69,6 +73,7 @@ const ModelsTable = (modelsData) => {
refresh,
vendorMap,
categoryNames,
copyText,
]);
// Handle compact mode by removing fixed positioning
@@ -85,36 +90,59 @@ const ModelsTable = (modelsData) => {
}, [compactMode, columns]);
return (
<CardTable
columns={tableColumns}
dataSource={models}
scroll={compactMode ? undefined : { x: 'max-content' }}
pagination={{
currentPage: activePage,
pageSize: pageSize,
total: modelCount,
showSizeChanger: true,
pageSizeOptions: [10, 20, 50, 100],
onPageSizeChange: handlePageSizeChange,
onPageChange: handlePageChange,
}}
hidePagination={true}
loading={loading}
rowSelection={rowSelection}
onRow={handleRow}
empty={
<Empty
image={<IllustrationNoResult style={{ width: 150, height: 150 }} />}
darkModeImage={
<IllustrationNoResultDark style={{ width: 150, height: 150 }} />
<>
<Modal
title={t('详情')}
visible={Boolean(detailModel)}
onCancel={() => setDetailModel(null)}
maskClosable
footer={null}
width={720}
>
<Descriptions
className='models-detail-descriptions'
bordered
column={1}
items={
detailModel
? columns
.filter((column) => column.dataIndex !== 'operate')
.map((column, key) => ({
key,
label: column.title,
children: column.render
? column.render(
detailModel[column.dataIndex],
detailModel,
)
: (detailModel[column.dataIndex] ?? '-'),
}))
: []
}
description={t('搜索无结果')}
style={{ padding: 30 }}
/>
}
className='rounded-xl overflow-hidden'
size='middle'
/>
</Modal>
<CardTable
columns={tableColumns}
dataSource={models}
scroll={compactMode ? undefined : { x: 'max-content' }}
pagination={{
currentPage: activePage,
pageSize: pageSize,
total: modelCount,
showSizeChanger: true,
pageSizeOptions: [10, 20, 50, 100],
onPageSizeChange: handlePageSizeChange,
onPageChange: handlePageChange,
}}
hidePagination={true}
loading={loading}
rowSelection={rowSelection}
onRow={handleRow}
empty={<TableEmpty />}
className='rounded-xl overflow-hidden'
size='middle'
/>
</>
);
};
+92 -103
View File
@@ -18,8 +18,10 @@ For commercial licensing, please contact support@quantumnous.com
*/
import React from 'react';
import { Tabs, TabPane, Tag, Button, Dropdown, Modal } from '@/components/ui';
import { IconEdit, IconDelete } from '@/components/ui/icons';
import { Modal } from '@/components/ui';
import { Button } from 'antd';
import { Plus } from 'lucide-react';
import { IconEdit, IconClose } from '@/components/ui/icons';
import {
getLobeHubIcon,
showError,
@@ -27,6 +29,7 @@ import {
isRoot,
} from '../../../helpers';
import { API } from '../../../helpers';
import './models-vendor-tabs.css';
const ModelsTabs = ({
activeVendorKey,
@@ -52,13 +55,13 @@ const ModelsTabs = ({
};
const handleEditVendor = (vendor, e) => {
e.stopPropagation(); // 阻止事件冒泡,避免触发tab切换
e.stopPropagation();
setEditingVendor(vendor);
setShowEditVendor(true);
};
const handleDeleteVendor = async (vendor, e) => {
e.stopPropagation(); // 阻止事件冒泡,避免触发tab切换
e.stopPropagation();
try {
const res = await API.delete(`/api/vendors/${vendor.id}`);
if (res.data.success) {
@@ -80,109 +83,95 @@ const ModelsTabs = ({
};
return (
<Tabs
activeKey={activeVendorKey}
type='card'
collapsible
onChange={handleTabChange}
className='mb-2'
tabBarExtraContent={
canManageVendors && (
<div className='models-vendor-toolbar'>
<div className='models-vendor-list' role='group' aria-label={t('供应商')}>
<div
className={`models-vendor-group${activeVendorKey === 'all' ? ' is-selected' : ''}`}
>
<Button
type='primary'
size='small'
onClick={() => setShowAddVendor(true)}
type='text'
className='models-vendor-filter'
aria-pressed={activeVendorKey === 'all'}
onClick={() => handleTabChange('all')}
>
{t('新增供应商')}
<span>{t('全部')}</span>
<span className='models-vendor-count'>{vendorCounts.all || 0}</span>
</Button>
)
}
>
<TabPane
itemKey='all'
tab={
<span className='flex items-center gap-2'>
{t('全部')}
<Tag
color={activeVendorKey === 'all' ? 'red' : 'grey'}
shape='circle'
</div>
{vendors.map((vendor) => {
const key = String(vendor.id);
return (
<div
key={key}
className={`models-vendor-group${activeVendorKey === key ? ' is-selected' : ''}`}
>
{vendorCounts['all'] || 0}
</Tag>
</span>
}
/>
{vendors.map((vendor) => {
const key = String(vendor.id);
const count = vendorCounts[vendor.id] || 0;
return (
<TabPane
key={key}
itemKey={key}
tab={
<span className='flex items-center gap-2'>
{getLobeHubIcon(vendor.icon || 'Layers', 14)}
{vendor.name}
<Tag
color={activeVendorKey === key ? 'red' : 'grey'}
shape='circle'
>
{count}
</Tag>
{canManageVendors && (
<Dropdown
trigger='click'
position='bottomRight'
render={
<Dropdown.Menu>
<Dropdown.Item
icon={<IconEdit />}
onClick={(e) => handleEditVendor(vendor, e)}
>
{t('编辑')}
</Dropdown.Item>
<Dropdown.Item
type='danger'
icon={<IconDelete />}
onClick={(e) => {
e.stopPropagation();
Modal.confirm({
title: t('确认删除'),
content: t(
'确定要删除供应商 "{{name}}" 吗?此操作不可撤销。',
{ name: vendor.name },
),
onOk: () => handleDeleteVendor(vendor, e),
okText: t('删除'),
cancelText: t('取消'),
type: 'warning',
okType: 'danger',
});
}}
>
{t('删除')}
</Dropdown.Item>
</Dropdown.Menu>
}
onClickOutSide={(e) => e.stopPropagation()}
>
<Button
size='small'
type='tertiary'
theme='outline'
onClick={(e) => e.stopPropagation()}
>
{t('操作')}
</Button>
</Dropdown>
)}
</span>
}
/>
);
})}
</Tabs>
<Button
type='text'
className='models-vendor-filter'
aria-pressed={activeVendorKey === key}
onClick={() => handleTabChange(key)}
>
<span className='models-vendor-icon'>
{getLobeHubIcon(vendor.icon || 'Layers', 14)}
</span>
<span className='models-vendor-name' title={vendor.name}>
{vendor.name}
</span>
<span className='models-vendor-count'>
{vendorCounts[vendor.id] || 0}
</span>
</Button>
{canManageVendors && (
<div className='models-vendor-actions'>
<Button
type='text'
size='small'
icon={<IconEdit />}
aria-label={`${t('编辑')}${vendor.name}`}
title={t('编辑')}
onClick={(e) => handleEditVendor(vendor, e)}
/>
<Button
type='text'
danger
size='small'
icon={<IconClose />}
aria-label={`${t('删除')}${vendor.name}`}
title={t('删除')}
onClick={(e) => {
e.stopPropagation();
Modal.confirm({
title: t('确认删除'),
content: t(
'确定要删除供应商 "{{name}}" 吗?此操作不可撤销。',
{ name: vendor.name },
),
onOk: () => handleDeleteVendor(vendor, e),
okText: t('删除'),
cancelText: t('取消'),
type: 'warning',
okType: 'danger',
});
}}
/>
</div>
)}
</div>
);
})}
</div>
{canManageVendors && (
<Button
className='console-create-action'
type='primary'
size='middle'
icon={<Plus size={16} />}
onClick={() => setShowAddVendor(true)}
>
{t('新增供应商')}
</Button>
)}
</div>
);
};
+12 -11
View File
@@ -98,6 +98,18 @@ const ModelsPage = () => {
<ModelsCategoryStats t={t} />
<CardPro
tableTitle={t('模型列表')}
tableActionsOffset
searchArea={
<ModelsFilters
formInitValues={formInitValues}
setFormApi={setFormApi}
searchModels={searchModels}
loading={loading}
searching={searching}
t={t}
/>
}
type='type3'
tabsArea={<ModelsTabs {...modelsData} />}
actionsArea={
@@ -118,17 +130,6 @@ const ModelsPage = () => {
setCompactMode={setCompactMode}
t={t}
/>
<div className='w-full md:w-full lg:w-auto order-1 md:order-2'>
<ModelsFilters
formInitValues={formInitValues}
setFormApi={setFormApi}
searchModels={searchModels}
loading={loading}
searching={searching}
t={t}
/>
</div>
</div>
}
paginationArea={createCardProPagination({
@@ -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' }}
/>
@@ -0,0 +1,124 @@
.models-vendor-toolbar {
display: flex;
align-items: flex-start;
flex-wrap: wrap;
gap: 8px 16px;
}
.models-vendor-list {
display: flex;
align-items: center;
flex-wrap: wrap;
flex: 1;
min-width: 0;
gap: 8px;
}
.models-vendor-group {
display: flex;
align-items: center;
max-width: 100%;
min-height: 34px;
padding-inline: 2px;
border: 1px solid var(--ui-color-border);
border-radius: var(--ui-border-radius-small);
background: var(--ui-color-fill-0);
}
.models-vendor-group.is-selected {
border-color: var(--ui-color-primary-light-active);
background: var(--ui-color-primary-light-default);
}
.models-vendor-group .models-vendor-filter {
display: inline-flex;
align-items: center;
min-width: 0;
gap: 8px;
border: 0;
background: transparent;
box-shadow: none;
}
.models-vendor-icon {
display: inline-flex;
align-items: center;
flex-shrink: 0;
width: 14px;
height: 14px;
justify-content: center;
}
.models-vendor-name {
overflow: hidden;
max-width: 200px;
text-overflow: ellipsis;
white-space: nowrap;
}
.models-model-icon {
display: flex;
align-items: center;
justify-content: center;
}
.models-detail-descriptions .models-model-icon {
justify-content: flex-start;
}
.models-name-cell {
display: inline-flex;
align-items: center;
gap: 4px;
}
.models-name-copy.ant-btn {
display: inline-flex;
align-items: center;
justify-content: center;
flex-shrink: 0;
width: 24px;
min-width: 24px;
height: 24px;
padding: 0;
font-size: inherit;
color: var(--ui-color-primary);
}
.models-name-cell .models-name-copy.ant-btn .lucide {
width: 0.8em;
height: 0.8em;
}
.models-vendor-count {
flex-shrink: 0;
font-size: 12px;
opacity: 0.65;
}
/* Sticky headers need an opaque surface below the translucent header tint. */
.console-page[data-console-page='models']
.console-table
.ant-table-thead
> tr
> th.ant-table-cell-fix-right {
background-color: var(--console-surface);
background-image: linear-gradient(var(--console-fill), var(--console-fill));
}
.models-vendor-actions {
display: flex;
flex-shrink: 0;
visibility: hidden;
}
.models-vendor-group:hover .models-vendor-actions,
.models-vendor-group:focus-within .models-vendor-actions {
visibility: visible;
}
@media (hover: none) {
.models-vendor-actions {
visibility: visible;
}
}