feat: 自行开发设计 ui样式优化 超管端-控制台 相关的页面
This commit is contained in:
@@ -17,6 +17,7 @@ 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, { useEffect, useState, useRef, useMemo } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import {
|
||||
@@ -60,18 +61,14 @@ import ChannelKeyDisplay from '../../../common/ui/ChannelKeyDisplay';
|
||||
import { useSecureVerification } from '../../../../hooks/common/useSecureVerification';
|
||||
import { createApiCalls } from '../../../../services/secureVerification';
|
||||
import {
|
||||
IconSave,
|
||||
IconClose,
|
||||
IconServer,
|
||||
IconSetting,
|
||||
IconCode,
|
||||
IconGlobe,
|
||||
IconBolt,
|
||||
IconChevronUp,
|
||||
IconChevronDown,
|
||||
} from '@/components/ui/icons';
|
||||
|
||||
const { Text, Title } = Typography;
|
||||
const { Text } = Typography;
|
||||
|
||||
const MODEL_MAPPING_EXAMPLE = {
|
||||
'gpt-3.5-turbo': 'gpt-3.5-turbo-0125',
|
||||
@@ -351,23 +348,6 @@ const EditChannelModal = (props) => {
|
||||
t,
|
||||
]);
|
||||
|
||||
// 表单块导航相关状态
|
||||
const formSectionRefs = useRef({
|
||||
basicInfo: null,
|
||||
apiConfig: null,
|
||||
modelConfig: null,
|
||||
advancedSettings: null,
|
||||
channelExtraSettings: null,
|
||||
});
|
||||
const [currentSectionIndex, setCurrentSectionIndex] = useState(0);
|
||||
const formSections = [
|
||||
'basicInfo',
|
||||
'apiConfig',
|
||||
'modelConfig',
|
||||
'advancedSettings',
|
||||
'channelExtraSettings',
|
||||
];
|
||||
const formContainerRef = useRef(null);
|
||||
const doubaoApiClickCountRef = useRef(0);
|
||||
const initialModelsRef = useRef([]);
|
||||
const initialModelMappingRef = useRef('');
|
||||
@@ -411,43 +391,6 @@ const EditChannelModal = (props) => {
|
||||
});
|
||||
};
|
||||
|
||||
// 表单导航功能
|
||||
const scrollToSection = (sectionKey) => {
|
||||
const sectionElement = formSectionRefs.current[sectionKey];
|
||||
if (sectionElement) {
|
||||
sectionElement.scrollIntoView({
|
||||
behavior: 'smooth',
|
||||
block: 'start',
|
||||
inline: 'nearest',
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
const navigateToSection = (direction) => {
|
||||
const availableSections = formSections.filter((section) => {
|
||||
if (section === 'apiConfig') {
|
||||
return showApiConfigCard;
|
||||
}
|
||||
return true;
|
||||
});
|
||||
|
||||
let newIndex;
|
||||
if (direction === 'up') {
|
||||
newIndex =
|
||||
currentSectionIndex > 0
|
||||
? currentSectionIndex - 1
|
||||
: availableSections.length - 1;
|
||||
} else {
|
||||
newIndex =
|
||||
currentSectionIndex < availableSections.length - 1
|
||||
? currentSectionIndex + 1
|
||||
: 0;
|
||||
}
|
||||
|
||||
setCurrentSectionIndex(newIndex);
|
||||
scrollToSection(availableSections[newIndex]);
|
||||
};
|
||||
|
||||
const handleApiConfigSecretClick = () => {
|
||||
if (inputs.type !== 45) return;
|
||||
const next = doubaoApiClickCountRef.current + 1;
|
||||
@@ -1055,8 +998,6 @@ const EditChannelModal = (props) => {
|
||||
fetchModelGroups();
|
||||
// 重置手动输入模式状态
|
||||
setUseManualInput(false);
|
||||
// 重置导航状态
|
||||
setCurrentSectionIndex(0);
|
||||
} else {
|
||||
// 统一的模态框关闭重置逻辑
|
||||
resetModalState();
|
||||
@@ -1655,7 +1596,7 @@ const EditChannelModal = (props) => {
|
||||
|
||||
const batchAllowed = !isEdit || isMultiKeyChannel;
|
||||
const batchExtra = batchAllowed ? (
|
||||
<Space>
|
||||
<Space wrap className='console-channel-key-actions'>
|
||||
{!isEdit && (
|
||||
<Checkbox
|
||||
disabled={isEdit}
|
||||
@@ -1827,76 +1768,25 @@ const EditChannelModal = (props) => {
|
||||
return (
|
||||
<>
|
||||
<SideSheet
|
||||
placement={isEdit ? 'right' : 'left'}
|
||||
title={
|
||||
<Space>
|
||||
<Tag color='blue' shape='circle'>
|
||||
{isEdit ? t('编辑') : t('新建')}
|
||||
</Tag>
|
||||
<Title heading={4} className='m-0'>
|
||||
{isEdit ? t('更新渠道信息') : t('创建新的渠道')}
|
||||
</Title>
|
||||
</Space>
|
||||
}
|
||||
rootClassName='console-channel-drawer'
|
||||
classNames={{ header: 'console-channel-editor-header' }}
|
||||
placement='right'
|
||||
title={isEdit ? t('更新渠道信息') : t('创建新的渠道')}
|
||||
bodyStyle={{ padding: '0' }}
|
||||
visible={props.visible}
|
||||
width={isMobile ? '100%' : 600}
|
||||
footer={
|
||||
<div className='flex justify-between items-center'>
|
||||
<div className='flex gap-2'>
|
||||
<Button
|
||||
size='small'
|
||||
type='tertiary'
|
||||
icon={<IconChevronUp />}
|
||||
onClick={() => navigateToSection('up')}
|
||||
style={{
|
||||
borderRadius: '50%',
|
||||
width: '32px',
|
||||
height: '32px',
|
||||
padding: 0,
|
||||
display: 'flex',
|
||||
alignItems: 'center',
|
||||
justifyContent: 'center',
|
||||
}}
|
||||
title={t('上一个表单块')}
|
||||
/>
|
||||
<Button
|
||||
size='small'
|
||||
type='tertiary'
|
||||
icon={<IconChevronDown />}
|
||||
onClick={() => navigateToSection('down')}
|
||||
style={{
|
||||
borderRadius: '50%',
|
||||
width: '32px',
|
||||
height: '32px',
|
||||
padding: 0,
|
||||
display: 'flex',
|
||||
alignItems: 'center',
|
||||
justifyContent: 'center',
|
||||
}}
|
||||
title={t('下一个表单块')}
|
||||
/>
|
||||
</div>
|
||||
<Space>
|
||||
<Button
|
||||
theme='solid'
|
||||
onClick={() => formApiRef.current?.submitForm()}
|
||||
icon={<IconSave />}
|
||||
>
|
||||
{t('提交')}
|
||||
</Button>
|
||||
<Button
|
||||
theme='light'
|
||||
type='primary'
|
||||
onClick={handleCancel}
|
||||
icon={<IconClose />}
|
||||
>
|
||||
{t('取消')}
|
||||
</Button>
|
||||
</Space>
|
||||
<div className='console-channel-footer'>
|
||||
<Button onClick={handleCancel}>{t('取消')}</Button>
|
||||
<Button
|
||||
theme='solid'
|
||||
type='primary'
|
||||
onClick={() => formApiRef.current?.submitForm()}
|
||||
>
|
||||
{t('提交')}
|
||||
</Button>
|
||||
</div>
|
||||
}
|
||||
closeIcon={null}
|
||||
onCancel={() => handleCancel()}
|
||||
>
|
||||
<Form
|
||||
@@ -1907,16 +1797,12 @@ const EditChannelModal = (props) => {
|
||||
>
|
||||
{() => (
|
||||
<Spin spinning={loading}>
|
||||
<div className='p-2' ref={formContainerRef}>
|
||||
<div ref={(el) => (formSectionRefs.current.basicInfo = el)}>
|
||||
<div className='console-channel-sections p-2'>
|
||||
<div>
|
||||
<Card className='!rounded-2xl shadow-sm border-0 mb-6'>
|
||||
{/* Header: Basic Info */}
|
||||
<div className='flex items-center mb-2'>
|
||||
<Avatar
|
||||
size='small'
|
||||
color='blue'
|
||||
className='mr-2 shadow-md'
|
||||
>
|
||||
<div className='console-channel-section'>
|
||||
<Avatar size='small' color='blue'>
|
||||
<IconServer size={16} />
|
||||
</Avatar>
|
||||
<div>
|
||||
@@ -2438,9 +2324,8 @@ const EditChannelModal = (props) => {
|
||||
<Form.Input
|
||||
field='openai_organization'
|
||||
label={t('组织')}
|
||||
placeholder={t('请输入组织org-xxx')}
|
||||
placeholder={t('组织 org-xxx(留空使用默认组织)')}
|
||||
showClear
|
||||
helpText={t('组织,不填则为默认组织')}
|
||||
onChange={(value) =>
|
||||
handleInputChange('openai_organization', value)
|
||||
}
|
||||
@@ -2451,18 +2336,14 @@ const EditChannelModal = (props) => {
|
||||
|
||||
{/* API Configuration Card */}
|
||||
{showApiConfigCard && (
|
||||
<div ref={(el) => (formSectionRefs.current.apiConfig = el)}>
|
||||
<div>
|
||||
<Card className='!rounded-2xl shadow-sm border-0 mb-6'>
|
||||
{/* Header: API Config */}
|
||||
<div
|
||||
className='flex items-center mb-2'
|
||||
className='console-channel-section'
|
||||
onClick={handleApiConfigSecretClick}
|
||||
>
|
||||
<Avatar
|
||||
size='small'
|
||||
color='green'
|
||||
className='mr-2 shadow-md'
|
||||
>
|
||||
<Avatar size='small' color='green'>
|
||||
<IconGlobe size={16} />
|
||||
</Avatar>
|
||||
<div>
|
||||
@@ -2679,15 +2560,11 @@ const EditChannelModal = (props) => {
|
||||
)}
|
||||
|
||||
{/* Model Configuration Card */}
|
||||
<div ref={(el) => (formSectionRefs.current.modelConfig = el)}>
|
||||
<div>
|
||||
<Card className='!rounded-2xl shadow-sm border-0 mb-6'>
|
||||
{/* Header: Model Config */}
|
||||
<div className='flex items-center mb-2'>
|
||||
<Avatar
|
||||
size='small'
|
||||
color='purple'
|
||||
className='mr-2 shadow-md'
|
||||
>
|
||||
<div className='console-channel-section'>
|
||||
<Avatar size='small' color='purple'>
|
||||
<IconCode size={16} />
|
||||
</Avatar>
|
||||
<div>
|
||||
@@ -2740,7 +2617,7 @@ const EditChannelModal = (props) => {
|
||||
};
|
||||
}}
|
||||
extraText={
|
||||
<Space wrap>
|
||||
<Space wrap className='console-channel-model-actions'>
|
||||
<Button
|
||||
size='small'
|
||||
type='primary'
|
||||
@@ -2778,13 +2655,15 @@ const EditChannelModal = (props) => {
|
||||
<Button
|
||||
size='small'
|
||||
type='tertiary'
|
||||
onClick={() => {
|
||||
onClick={async () => {
|
||||
if (inputs.models.length === 0) {
|
||||
showInfo(t('没有模型可以复制'));
|
||||
return;
|
||||
}
|
||||
try {
|
||||
copy(inputs.models.join(','));
|
||||
if (!(await copy(inputs.models.join(',')))) {
|
||||
throw new Error('Clipboard copy failed');
|
||||
}
|
||||
showSuccess(t('模型列表已复制到剪贴板'));
|
||||
} catch (error) {
|
||||
showError(t('复制失败'));
|
||||
@@ -2888,17 +2767,11 @@ const EditChannelModal = (props) => {
|
||||
</div>
|
||||
|
||||
{/* Advanced Settings Card */}
|
||||
<div
|
||||
ref={(el) => (formSectionRefs.current.advancedSettings = el)}
|
||||
>
|
||||
<div>
|
||||
<Card className='!rounded-2xl shadow-sm border-0 mb-6'>
|
||||
{/* Header: Advanced Settings */}
|
||||
<div className='flex items-center mb-2'>
|
||||
<Avatar
|
||||
size='small'
|
||||
color='orange'
|
||||
className='mr-2 shadow-md'
|
||||
>
|
||||
<div className='console-channel-section'>
|
||||
<Avatar size='small' color='orange'>
|
||||
<IconSetting size={16} />
|
||||
</Avatar>
|
||||
<div>
|
||||
@@ -3432,19 +3305,11 @@ const EditChannelModal = (props) => {
|
||||
</div>
|
||||
|
||||
{/* Channel Extra Settings Card */}
|
||||
<div
|
||||
ref={(el) =>
|
||||
(formSectionRefs.current.channelExtraSettings = el)
|
||||
}
|
||||
>
|
||||
<div>
|
||||
<Card className='!rounded-2xl shadow-sm border-0 mb-6'>
|
||||
{/* Header: Channel Extra Settings */}
|
||||
<div className='flex items-center mb-2'>
|
||||
<Avatar
|
||||
size='small'
|
||||
color='violet'
|
||||
className='mr-2 shadow-md'
|
||||
>
|
||||
<div className='console-channel-section'>
|
||||
<Avatar size='small' color='violet'>
|
||||
<IconBolt size={16} />
|
||||
</Avatar>
|
||||
<div>
|
||||
|
||||
Reference in New Issue
Block a user