2025-07-19 03:30:44 +08:00
|
|
|
|
/*
|
|
|
|
|
|
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
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
2025-07-31 22:08:16 +08:00
|
|
|
|
import React, { useEffect, useState, useRef, useMemo } from 'react';
|
|
|
|
|
|
import { useTranslation } from 'react-i18next';
|
2024-03-23 21:24:39 +08:00
|
|
|
|
import {
|
|
|
|
|
|
API,
|
|
|
|
|
|
showError,
|
|
|
|
|
|
showInfo,
|
2025-04-04 12:00:38 +08:00
|
|
|
|
showSuccess,
|
|
|
|
|
|
verifyJSON,
|
2025-07-19 00:58:18 +08:00
|
|
|
|
} from '../../../../helpers';
|
2025-08-18 04:14:35 +08:00
|
|
|
|
import { useIsMobile } from '../../../../hooks/common/useIsMobile';
|
2025-07-31 22:08:16 +08:00
|
|
|
|
import { CHANNEL_OPTIONS } from '../../../../constants';
|
2024-03-23 21:24:39 +08:00
|
|
|
|
import {
|
2025-07-26 18:06:46 +08:00
|
|
|
|
SideSheet,
|
|
|
|
|
|
Space,
|
|
|
|
|
|
Spin,
|
2025-07-31 22:08:16 +08:00
|
|
|
|
Button,
|
2025-07-26 18:06:46 +08:00
|
|
|
|
Typography,
|
2025-07-31 22:08:16 +08:00
|
|
|
|
Checkbox,
|
|
|
|
|
|
Banner,
|
|
|
|
|
|
Modal,
|
|
|
|
|
|
ImagePreview,
|
|
|
|
|
|
Card,
|
|
|
|
|
|
Tag,
|
|
|
|
|
|
Avatar,
|
|
|
|
|
|
Form,
|
|
|
|
|
|
Row,
|
|
|
|
|
|
Col,
|
|
|
|
|
|
Highlight,
|
2025-08-25 14:45:48 +08:00
|
|
|
|
Input,
|
2024-03-23 21:24:39 +08:00
|
|
|
|
} from '@douyinfe/semi-ui';
|
2025-08-30 21:15:10 +08:00
|
|
|
|
import {
|
|
|
|
|
|
getChannelModels,
|
|
|
|
|
|
copy,
|
|
|
|
|
|
getChannelIcon,
|
|
|
|
|
|
getModelCategories,
|
|
|
|
|
|
selectFilter,
|
|
|
|
|
|
} from '../../../../helpers';
|
2025-07-28 01:33:23 +08:00
|
|
|
|
import ModelSelectModal from './ModelSelectModal';
|
2025-08-04 21:58:10 +08:00
|
|
|
|
import JSONEditor from '../../../common/ui/JSONEditor';
|
2025-08-25 14:45:48 +08:00
|
|
|
|
import TwoFactorAuthModal from '../../../common/modals/TwoFactorAuthModal';
|
|
|
|
|
|
import ChannelKeyDisplay from '../../../common/ui/ChannelKeyDisplay';
|
2025-05-25 12:53:00 +08:00
|
|
|
|
import {
|
2025-07-26 18:06:46 +08:00
|
|
|
|
IconSave,
|
2025-07-31 22:08:16 +08:00
|
|
|
|
IconClose,
|
2025-07-26 18:06:46 +08:00
|
|
|
|
IconServer,
|
|
|
|
|
|
IconSetting,
|
2025-07-31 22:08:16 +08:00
|
|
|
|
IconCode,
|
|
|
|
|
|
IconGlobe,
|
|
|
|
|
|
IconBolt,
|
2025-09-19 18:09:26 +08:00
|
|
|
|
IconChevronUp,
|
|
|
|
|
|
IconChevronDown,
|
2025-05-25 12:53:00 +08:00
|
|
|
|
} from '@douyinfe/semi-icons';
|
|
|
|
|
|
|
|
|
|
|
|
const { Text, Title } = Typography;
|
2023-04-23 12:43:10 +08:00
|
|
|
|
|
2023-06-28 12:56:01 +08:00
|
|
|
|
const MODEL_MAPPING_EXAMPLE = {
|
2025-04-04 12:00:38 +08:00
|
|
|
|
'gpt-3.5-turbo': 'gpt-3.5-turbo-0125',
|
2023-06-28 12:56:01 +08:00
|
|
|
|
};
|
|
|
|
|
|
|
2024-04-20 21:05:23 +08:00
|
|
|
|
const STATUS_CODE_MAPPING_EXAMPLE = {
|
2025-04-04 12:00:38 +08:00
|
|
|
|
400: '500',
|
2024-04-20 21:05:23 +08:00
|
|
|
|
};
|
|
|
|
|
|
|
2024-08-28 18:43:40 +08:00
|
|
|
|
const REGION_EXAMPLE = {
|
2025-08-30 21:15:10 +08:00
|
|
|
|
default: 'global',
|
|
|
|
|
|
'gemini-1.5-pro-002': 'europe-west2',
|
|
|
|
|
|
'gemini-1.5-flash-002': 'europe-west2',
|
2025-04-04 12:00:38 +08:00
|
|
|
|
'claude-3-5-sonnet-20240620': 'europe-west1',
|
2024-11-19 01:13:18 +08:00
|
|
|
|
};
|
2024-08-28 18:43:40 +08:00
|
|
|
|
|
2025-09-27 01:19:09 +08:00
|
|
|
|
// 支持并且已适配通过接口获取模型列表的渠道类型
|
|
|
|
|
|
const MODEL_FETCHABLE_TYPES = new Set([
|
|
|
|
|
|
1,
|
|
|
|
|
|
4,
|
|
|
|
|
|
14,
|
|
|
|
|
|
34,
|
|
|
|
|
|
17,
|
|
|
|
|
|
26,
|
|
|
|
|
|
24,
|
|
|
|
|
|
47,
|
|
|
|
|
|
25,
|
|
|
|
|
|
20,
|
|
|
|
|
|
23,
|
|
|
|
|
|
31,
|
|
|
|
|
|
35,
|
|
|
|
|
|
40,
|
|
|
|
|
|
42,
|
|
|
|
|
|
48,
|
|
|
|
|
|
]);
|
|
|
|
|
|
|
2023-09-03 15:50:49 +08:00
|
|
|
|
function type2secretPrompt(type) {
|
2024-03-23 21:24:39 +08:00
|
|
|
|
// inputs.type === 15 ? '按照如下格式输入:APIKey|SecretKey' : (inputs.type === 18 ? '按照如下格式输入:APPID|APISecret|APIKey' : '请输入渠道对应的鉴权密钥')
|
|
|
|
|
|
switch (type) {
|
|
|
|
|
|
case 15:
|
|
|
|
|
|
return '按照如下格式输入:APIKey|SecretKey';
|
|
|
|
|
|
case 18:
|
|
|
|
|
|
return '按照如下格式输入:APPID|APISecret|APIKey';
|
|
|
|
|
|
case 22:
|
|
|
|
|
|
return '按照如下格式输入:APIKey-AppId,例如:fastgpt-0sp2gtvfdgyi4k30jwlgwf1i-64f335d84283f05518e9e041';
|
|
|
|
|
|
case 23:
|
|
|
|
|
|
return '按照如下格式输入:AppId|SecretId|SecretKey';
|
2024-04-23 11:44:40 +08:00
|
|
|
|
case 33:
|
|
|
|
|
|
return '按照如下格式输入:Ak|Sk|Region';
|
2025-06-21 20:36:52 +08:00
|
|
|
|
case 50:
|
2025-07-21 15:06:26 +08:00
|
|
|
|
return '按照如下格式输入: AccessKey|SecretKey, 如果上游是New API,则直接输ApiKey';
|
2025-06-21 21:03:57 +08:00
|
|
|
|
case 51:
|
|
|
|
|
|
return '按照如下格式输入: Access Key ID|Secret Access Key';
|
2024-03-23 21:24:39 +08:00
|
|
|
|
default:
|
|
|
|
|
|
return '请输入渠道对应的鉴权密钥';
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-07-19 00:58:18 +08:00
|
|
|
|
const EditChannelModal = (props) => {
|
2024-12-13 19:03:14 +08:00
|
|
|
|
const { t } = useTranslation();
|
2024-03-23 21:24:39 +08:00
|
|
|
|
const channelId = props.editingChannel.id;
|
|
|
|
|
|
const isEdit = channelId !== undefined;
|
|
|
|
|
|
const [loading, setLoading] = useState(isEdit);
|
📱 refactor(web): remove legacy isMobile util and migrate to useIsMobile hook
BREAKING CHANGE:
helpers/utils.js no longer exports `isMobile()`.
Any external code that relied on this function must switch to the `useIsMobile` React hook.
Summary
-------
1. Deleted the obsolete `isMobile()` function from helpers/utils.js.
2. Introduced `MOBILE_BREAKPOINT` constant and `matchMedia`-based detection for non-React contexts.
3. Reworked toast positioning logic in utils.js to rely on `matchMedia`.
4. Updated render.js:
• Removed isMobile import.
• Added MOBILE_BREAKPOINT detection in `truncateText`.
5. Migrated every page/component to the `useIsMobile` hook:
• Layout: HeaderBar, PageLayout, SiderBar
• Pages: Home, Detail, Playground, User (Add/Edit), Token, Channel, Redemption, Ratio Sync
• Components: ChannelsTable, ChannelSelectorModal, ConflictConfirmModal
6. Purged all remaining `isMobile()` calls and legacy imports.
7. Added missing `const isMobile = useIsMobile()` declarations where required.
Benefits
--------
• Unifies mobile detection with a React-friendly hook.
• Eliminates duplicated logic and improves maintainability.
• Keeps non-React helpers lightweight by using `matchMedia` directly.
2025-07-16 02:54:58 +08:00
|
|
|
|
const isMobile = useIsMobile();
|
2024-03-23 21:24:39 +08:00
|
|
|
|
const handleCancel = () => {
|
|
|
|
|
|
props.handleClose();
|
|
|
|
|
|
};
|
|
|
|
|
|
const originInputs = {
|
|
|
|
|
|
name: '',
|
|
|
|
|
|
type: 1,
|
|
|
|
|
|
key: '',
|
|
|
|
|
|
openai_organization: '',
|
2024-04-23 11:44:40 +08:00
|
|
|
|
max_input_tokens: 0,
|
2024-03-23 21:24:39 +08:00
|
|
|
|
base_url: '',
|
|
|
|
|
|
other: '',
|
|
|
|
|
|
model_mapping: '',
|
2024-04-20 21:05:23 +08:00
|
|
|
|
status_code_mapping: '',
|
2024-03-23 21:24:39 +08:00
|
|
|
|
models: [],
|
|
|
|
|
|
auto_ban: 1,
|
2024-04-04 17:28:56 +08:00
|
|
|
|
test_model: '',
|
2024-03-23 21:24:39 +08:00
|
|
|
|
groups: ['default'],
|
2024-11-19 01:13:18 +08:00
|
|
|
|
priority: 0,
|
|
|
|
|
|
weight: 0,
|
2025-04-04 12:00:38 +08:00
|
|
|
|
tag: '',
|
2025-07-07 01:12:01 +08:00
|
|
|
|
multi_key_mode: 'random',
|
2025-07-26 11:39:09 +08:00
|
|
|
|
// 渠道额外设置的默认值
|
|
|
|
|
|
force_format: false,
|
|
|
|
|
|
thinking_to_content: false,
|
|
|
|
|
|
proxy: '',
|
|
|
|
|
|
pass_through_body_enabled: false,
|
|
|
|
|
|
system_prompt: '',
|
2025-08-09 12:53:06 +08:00
|
|
|
|
system_prompt_override: false,
|
2025-08-10 20:21:30 +08:00
|
|
|
|
settings: '',
|
2025-09-12 19:11:17 +08:00
|
|
|
|
// 仅 Vertex: 密钥格式(存入 settings.vertex_key_type)
|
|
|
|
|
|
vertex_key_type: 'json',
|
2024-03-23 21:24:39 +08:00
|
|
|
|
};
|
|
|
|
|
|
const [batch, setBatch] = useState(false);
|
2025-07-07 01:12:01 +08:00
|
|
|
|
const [multiToSingle, setMultiToSingle] = useState(false);
|
|
|
|
|
|
const [multiKeyMode, setMultiKeyMode] = useState('random');
|
2024-03-23 21:24:39 +08:00
|
|
|
|
const [autoBan, setAutoBan] = useState(true);
|
|
|
|
|
|
const [inputs, setInputs] = useState(originInputs);
|
|
|
|
|
|
const [originModelOptions, setOriginModelOptions] = useState([]);
|
|
|
|
|
|
const [modelOptions, setModelOptions] = useState([]);
|
|
|
|
|
|
const [groupOptions, setGroupOptions] = useState([]);
|
|
|
|
|
|
const [basicModels, setBasicModels] = useState([]);
|
|
|
|
|
|
const [fullModels, setFullModels] = useState([]);
|
✨ feat(web): add model prefill group quick-add buttons to channel models selector
- Added support to fetch and render “model prefill groups” in `EditChannelModal.jsx`
- Users can now click a group button to instantly merge that group’s models into the models Select
- Mirrors the prefill-group UX used for tags/endpoints in `EditModelModal.jsx`
Details
- UI/UX:
- Renders one button per model group inside the models field’s extra actions
- Clicking a button merges its items into the selected models (trimmed, deduplicated), updating immediately
- Non-destructive and works alongside existing actions (fill related/all models, fetch upstream, clear, copy)
- API:
- GET `/api/prefill_group?type=model`
- Handles `items` as either an array or a JSON string array for robustness
- If request fails or returns no groups, buttons are simply not shown
- i18n:
- Reuses existing i18n; group names come from backend and are displayed as-is
- Performance:
- Simple set merge; negligible overhead
- Backward compatibility:
- No changes required on the backend or elsewhere; feature is additive
- Testing (manual):
1) Open channel modal (new or edit) and navigate to the Models section
2) Confirm model group buttons render when groups are configured
3) Click a group button → models Select updates with merged models (no duplicates)
4) Verify other actions (fill related/all, fetch upstream, clear, copy) still work
5) Close/reopen modal → state resets as expected
Implementation
- `web/src/components/table/channels/modals/EditChannelModal.jsx`
- Added `modelGroups` state and `fetchModelGroups()` (GET `/api/prefill_group?type=model`)
- Invoked `fetchModelGroups()` when the modal opens
- Rendered group buttons in the models Select `extraText`, merging group items into current selection
Chore
- Verified no new linter errors were introduced.
2025-08-08 04:48:18 +08:00
|
|
|
|
const [modelGroups, setModelGroups] = useState([]);
|
2024-03-23 21:24:39 +08:00
|
|
|
|
const [customModel, setCustomModel] = useState('');
|
2025-04-27 17:20:49 +08:00
|
|
|
|
const [modalImageUrl, setModalImageUrl] = useState('');
|
|
|
|
|
|
const [isModalOpenurl, setIsModalOpenurl] = useState(false);
|
2025-07-28 01:33:23 +08:00
|
|
|
|
const [modelModalVisible, setModelModalVisible] = useState(false);
|
|
|
|
|
|
const [fetchedModels, setFetchedModels] = useState([]);
|
✨ refactor(EditChannel&EditToken): refactor Channel & Token edit pages with Semi Form and UX enhancements
Overview
• Migrated both `EditChannel.js` and `EditToken.js` to fully leverage Semi UI `Form.*` components, removing legacy `Input/Select/TextArea` + manual labels.
• Unified data-loading strategy: when the drawer becomes visible we load (or reset) data via `props.visible + id` effect and `formApi.setValues()`, guaranteeing fields are always populated; form resets on close.
• Fixed blank-form bug when opening the same record twice.
Key improvements
1. Validation
• `type`, `models` always required.
• `key` required only while creating (not on edit).
2. Batch key creation
• Checkbox moved into `extraText`; hidden when editing or when channel type = 41.
3. Layout & UI
• `Row / Col` (12 + 12) for “Priority” and “Weight”.
• Placeholders revised; model selector now shows creation hint; removed obsolete banner.
• Help / extraText used for long hints, template buttons (`model_mapping`, `status_code_mapping`, `param_override`, etc.), and API address notice.
• Added `showClear`, `min`, rounded card class names for consistency.
4. Reusable helpers
• `batchAllowed`, `batchExtra` utilities.
• `getInitValues()` + centralized `inputs`→form synchronization.
5. Token editor aligned to the same pattern (`props.visiable` watcher).
Result
Cleaner code, consistent UX, instant field population on every open, and clearer validation/error feedback across both editors.
2025-07-04 05:36:10 +08:00
|
|
|
|
const formApiRef = useRef(null);
|
2025-07-07 01:12:01 +08:00
|
|
|
|
const [vertexKeys, setVertexKeys] = useState([]);
|
|
|
|
|
|
const [vertexFileList, setVertexFileList] = useState([]);
|
|
|
|
|
|
const vertexErroredNames = useRef(new Set()); // 避免重复报错
|
2025-07-07 01:53:19 +08:00
|
|
|
|
const [isMultiKeyChannel, setIsMultiKeyChannel] = useState(false);
|
2025-07-17 19:53:33 +08:00
|
|
|
|
const [channelSearchValue, setChannelSearchValue] = useState('');
|
|
|
|
|
|
const [useManualInput, setUseManualInput] = useState(false); // 是否使用手动输入模式
|
2025-08-02 10:57:03 +08:00
|
|
|
|
const [keyMode, setKeyMode] = useState('append'); // 密钥模式:replace(覆盖)或 append(追加)
|
2025-08-25 14:45:48 +08:00
|
|
|
|
|
|
|
|
|
|
// 2FA验证查看密钥相关状态
|
|
|
|
|
|
const [twoFAState, setTwoFAState] = useState({
|
|
|
|
|
|
showModal: false,
|
|
|
|
|
|
code: '',
|
|
|
|
|
|
loading: false,
|
|
|
|
|
|
showKey: false,
|
2025-08-30 21:15:10 +08:00
|
|
|
|
keyData: '',
|
2025-08-25 14:45:48 +08:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
// 专门的2FA验证状态(用于TwoFactorAuthModal)
|
|
|
|
|
|
const [show2FAVerifyModal, setShow2FAVerifyModal] = useState(false);
|
|
|
|
|
|
const [verifyCode, setVerifyCode] = useState('');
|
|
|
|
|
|
const [verifyLoading, setVerifyLoading] = useState(false);
|
|
|
|
|
|
|
2025-09-19 18:09:26 +08:00
|
|
|
|
// 表单块导航相关状态
|
|
|
|
|
|
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);
|
|
|
|
|
|
|
2025-08-25 14:45:48 +08:00
|
|
|
|
// 2FA状态更新辅助函数
|
|
|
|
|
|
const updateTwoFAState = (updates) => {
|
2025-08-30 21:15:10 +08:00
|
|
|
|
setTwoFAState((prev) => ({ ...prev, ...updates }));
|
2025-08-25 14:45:48 +08:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// 重置2FA状态
|
|
|
|
|
|
const resetTwoFAState = () => {
|
|
|
|
|
|
setTwoFAState({
|
|
|
|
|
|
showModal: false,
|
|
|
|
|
|
code: '',
|
|
|
|
|
|
loading: false,
|
|
|
|
|
|
showKey: false,
|
2025-08-30 21:15:10 +08:00
|
|
|
|
keyData: '',
|
2025-08-25 14:45:48 +08:00
|
|
|
|
});
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// 重置2FA验证状态
|
|
|
|
|
|
const reset2FAVerifyState = () => {
|
|
|
|
|
|
setShow2FAVerifyModal(false);
|
|
|
|
|
|
setVerifyCode('');
|
|
|
|
|
|
setVerifyLoading(false);
|
|
|
|
|
|
};
|
|
|
|
|
|
|
2025-09-19 18:09:26 +08:00
|
|
|
|
// 表单导航功能
|
|
|
|
|
|
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]);
|
|
|
|
|
|
};
|
|
|
|
|
|
|
2025-07-26 11:39:09 +08:00
|
|
|
|
// 渠道额外设置状态
|
|
|
|
|
|
const [channelSettings, setChannelSettings] = useState({
|
|
|
|
|
|
force_format: false,
|
|
|
|
|
|
thinking_to_content: false,
|
|
|
|
|
|
proxy: '',
|
|
|
|
|
|
pass_through_body_enabled: false,
|
|
|
|
|
|
system_prompt: '',
|
|
|
|
|
|
});
|
2025-09-27 09:35:03 +08:00
|
|
|
|
const showApiConfigCard = true; // 控制是否显示 API 配置卡片
|
✨ refactor(EditChannel&EditToken): refactor Channel & Token edit pages with Semi Form and UX enhancements
Overview
• Migrated both `EditChannel.js` and `EditToken.js` to fully leverage Semi UI `Form.*` components, removing legacy `Input/Select/TextArea` + manual labels.
• Unified data-loading strategy: when the drawer becomes visible we load (or reset) data via `props.visible + id` effect and `formApi.setValues()`, guaranteeing fields are always populated; form resets on close.
• Fixed blank-form bug when opening the same record twice.
Key improvements
1. Validation
• `type`, `models` always required.
• `key` required only while creating (not on edit).
2. Batch key creation
• Checkbox moved into `extraText`; hidden when editing or when channel type = 41.
3. Layout & UI
• `Row / Col` (12 + 12) for “Priority” and “Weight”.
• Placeholders revised; model selector now shows creation hint; removed obsolete banner.
• Help / extraText used for long hints, template buttons (`model_mapping`, `status_code_mapping`, `param_override`, etc.), and API address notice.
• Added `showClear`, `min`, rounded card class names for consistency.
4. Reusable helpers
• `batchAllowed`, `batchExtra` utilities.
• `getInitValues()` + centralized `inputs`→form synchronization.
5. Token editor aligned to the same pattern (`props.visiable` watcher).
Result
Cleaner code, consistent UX, instant field population on every open, and clearer validation/error feedback across both editors.
2025-07-04 05:36:10 +08:00
|
|
|
|
const getInitValues = () => ({ ...originInputs });
|
2025-07-26 13:33:10 +08:00
|
|
|
|
|
2025-07-26 11:39:09 +08:00
|
|
|
|
// 处理渠道额外设置的更新
|
|
|
|
|
|
const handleChannelSettingsChange = (key, value) => {
|
|
|
|
|
|
// 更新内部状态
|
2025-08-30 21:15:10 +08:00
|
|
|
|
setChannelSettings((prev) => ({ ...prev, [key]: value }));
|
2025-07-26 13:33:10 +08:00
|
|
|
|
|
2025-07-26 11:39:09 +08:00
|
|
|
|
// 同步更新到表单字段
|
|
|
|
|
|
if (formApiRef.current) {
|
|
|
|
|
|
formApiRef.current.setValue(key, value);
|
|
|
|
|
|
}
|
2025-07-26 13:33:10 +08:00
|
|
|
|
|
2025-07-26 11:39:09 +08:00
|
|
|
|
// 同步更新inputs状态
|
2025-08-30 21:15:10 +08:00
|
|
|
|
setInputs((prev) => ({ ...prev, [key]: value }));
|
2025-07-26 13:33:10 +08:00
|
|
|
|
|
2025-07-26 11:39:09 +08:00
|
|
|
|
// 生成setting JSON并更新
|
|
|
|
|
|
const newSettings = { ...channelSettings, [key]: value };
|
|
|
|
|
|
const settingsJson = JSON.stringify(newSettings);
|
|
|
|
|
|
handleInputChange('setting', settingsJson);
|
|
|
|
|
|
};
|
|
|
|
|
|
|
2025-08-10 20:21:30 +08:00
|
|
|
|
const handleChannelOtherSettingsChange = (key, value) => {
|
|
|
|
|
|
// 更新内部状态
|
2025-08-30 21:15:10 +08:00
|
|
|
|
setChannelSettings((prev) => ({ ...prev, [key]: value }));
|
2025-08-10 20:21:30 +08:00
|
|
|
|
|
|
|
|
|
|
// 同步更新到表单字段
|
|
|
|
|
|
if (formApiRef.current) {
|
|
|
|
|
|
formApiRef.current.setValue(key, value);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 同步更新inputs状态
|
2025-08-30 21:15:10 +08:00
|
|
|
|
setInputs((prev) => ({ ...prev, [key]: value }));
|
2025-08-10 20:21:30 +08:00
|
|
|
|
|
|
|
|
|
|
// 需要更新settings,是一个json,例如{"azure_responses_version": "preview"}
|
|
|
|
|
|
let settings = {};
|
|
|
|
|
|
if (inputs.settings) {
|
|
|
|
|
|
try {
|
|
|
|
|
|
settings = JSON.parse(inputs.settings);
|
|
|
|
|
|
} catch (error) {
|
|
|
|
|
|
console.error('解析设置失败:', error);
|
2025-07-26 11:39:09 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2025-08-10 20:21:30 +08:00
|
|
|
|
settings[key] = value;
|
|
|
|
|
|
const settingsJson = JSON.stringify(settings);
|
|
|
|
|
|
handleInputChange('settings', settingsJson);
|
2025-08-30 21:15:10 +08:00
|
|
|
|
};
|
2025-07-26 11:39:09 +08:00
|
|
|
|
|
2024-03-23 21:24:39 +08:00
|
|
|
|
const handleInputChange = (name, value) => {
|
✨ refactor(EditChannel&EditToken): refactor Channel & Token edit pages with Semi Form and UX enhancements
Overview
• Migrated both `EditChannel.js` and `EditToken.js` to fully leverage Semi UI `Form.*` components, removing legacy `Input/Select/TextArea` + manual labels.
• Unified data-loading strategy: when the drawer becomes visible we load (or reset) data via `props.visible + id` effect and `formApi.setValues()`, guaranteeing fields are always populated; form resets on close.
• Fixed blank-form bug when opening the same record twice.
Key improvements
1. Validation
• `type`, `models` always required.
• `key` required only while creating (not on edit).
2. Batch key creation
• Checkbox moved into `extraText`; hidden when editing or when channel type = 41.
3. Layout & UI
• `Row / Col` (12 + 12) for “Priority” and “Weight”.
• Placeholders revised; model selector now shows creation hint; removed obsolete banner.
• Help / extraText used for long hints, template buttons (`model_mapping`, `status_code_mapping`, `param_override`, etc.), and API address notice.
• Added `showClear`, `min`, rounded card class names for consistency.
4. Reusable helpers
• `batchAllowed`, `batchExtra` utilities.
• `getInitValues()` + centralized `inputs`→form synchronization.
5. Token editor aligned to the same pattern (`props.visiable` watcher).
Result
Cleaner code, consistent UX, instant field population on every open, and clearer validation/error feedback across both editors.
2025-07-04 05:36:10 +08:00
|
|
|
|
if (formApiRef.current) {
|
|
|
|
|
|
formApiRef.current.setValue(name, value);
|
|
|
|
|
|
}
|
2025-06-24 00:25:29 +08:00
|
|
|
|
if (name === 'models' && Array.isArray(value)) {
|
|
|
|
|
|
value = Array.from(new Set(value.map((m) => (m || '').trim())));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-03-15 19:38:05 +08:00
|
|
|
|
if (name === 'base_url' && value.endsWith('/v1')) {
|
|
|
|
|
|
Modal.confirm({
|
|
|
|
|
|
title: '警告',
|
2025-04-04 12:00:38 +08:00
|
|
|
|
content:
|
|
|
|
|
|
'不需要在末尾加/v1,New API会自动处理,添加后可能导致请求失败,是否继续?',
|
2025-03-15 19:38:05 +08:00
|
|
|
|
onOk: () => {
|
|
|
|
|
|
setInputs((inputs) => ({ ...inputs, [name]: value }));
|
2025-04-04 12:00:38 +08:00
|
|
|
|
},
|
|
|
|
|
|
});
|
|
|
|
|
|
return;
|
2025-03-15 19:38:05 +08:00
|
|
|
|
}
|
2024-03-23 21:24:39 +08:00
|
|
|
|
setInputs((inputs) => ({ ...inputs, [name]: value }));
|
2024-05-12 19:07:33 +08:00
|
|
|
|
if (name === 'type') {
|
2024-03-23 21:24:39 +08:00
|
|
|
|
let localModels = [];
|
|
|
|
|
|
switch (value) {
|
|
|
|
|
|
case 2:
|
|
|
|
|
|
localModels = [
|
|
|
|
|
|
'mj_imagine',
|
|
|
|
|
|
'mj_variation',
|
|
|
|
|
|
'mj_reroll',
|
|
|
|
|
|
'mj_blend',
|
|
|
|
|
|
'mj_upscale',
|
|
|
|
|
|
'mj_describe',
|
2025-04-04 12:00:38 +08:00
|
|
|
|
'mj_uploads',
|
2024-03-23 21:24:39 +08:00
|
|
|
|
];
|
|
|
|
|
|
break;
|
|
|
|
|
|
case 5:
|
|
|
|
|
|
localModels = [
|
|
|
|
|
|
'swap_face',
|
|
|
|
|
|
'mj_imagine',
|
2025-06-30 22:31:12 +08:00
|
|
|
|
'mj_video',
|
|
|
|
|
|
'mj_edits',
|
2024-03-23 21:24:39 +08:00
|
|
|
|
'mj_variation',
|
|
|
|
|
|
'mj_reroll',
|
|
|
|
|
|
'mj_blend',
|
|
|
|
|
|
'mj_upscale',
|
|
|
|
|
|
'mj_describe',
|
|
|
|
|
|
'mj_zoom',
|
|
|
|
|
|
'mj_shorten',
|
|
|
|
|
|
'mj_modal',
|
|
|
|
|
|
'mj_inpaint',
|
|
|
|
|
|
'mj_custom_zoom',
|
|
|
|
|
|
'mj_high_variation',
|
|
|
|
|
|
'mj_low_variation',
|
|
|
|
|
|
'mj_pan',
|
2025-04-04 12:00:38 +08:00
|
|
|
|
'mj_uploads',
|
2024-03-23 21:24:39 +08:00
|
|
|
|
];
|
|
|
|
|
|
break;
|
2024-06-12 20:37:42 +08:00
|
|
|
|
case 36:
|
2025-04-04 12:00:38 +08:00
|
|
|
|
localModels = ['suno_music', 'suno_lyrics'];
|
2024-06-12 20:37:42 +08:00
|
|
|
|
break;
|
2025-09-27 17:03:34 +08:00
|
|
|
|
case 45:
|
|
|
|
|
|
localModels = getChannelModels(value);
|
|
|
|
|
|
setInputs((prevInputs) => ({ ...prevInputs, base_url: 'https://ark.cn-beijing.volces.com' }));
|
|
|
|
|
|
break;
|
2024-05-12 19:07:33 +08:00
|
|
|
|
default:
|
|
|
|
|
|
localModels = getChannelModels(value);
|
|
|
|
|
|
break;
|
2024-03-23 21:24:39 +08:00
|
|
|
|
}
|
2024-05-12 19:07:33 +08:00
|
|
|
|
if (inputs.models.length === 0) {
|
|
|
|
|
|
setInputs((inputs) => ({ ...inputs, models: localModels }));
|
|
|
|
|
|
}
|
|
|
|
|
|
setBasicModels(localModels);
|
2025-07-19 00:58:18 +08:00
|
|
|
|
|
2025-07-17 19:53:33 +08:00
|
|
|
|
// 重置手动输入模式状态
|
|
|
|
|
|
setUseManualInput(false);
|
2023-07-29 12:24:23 +08:00
|
|
|
|
}
|
2024-03-23 21:24:39 +08:00
|
|
|
|
//setAutoBan
|
|
|
|
|
|
};
|
2023-04-23 12:43:10 +08:00
|
|
|
|
|
2024-03-23 21:24:39 +08:00
|
|
|
|
const loadChannel = async () => {
|
|
|
|
|
|
setLoading(true);
|
|
|
|
|
|
let res = await API.get(`/api/channel/${channelId}`);
|
2024-03-25 14:10:57 +08:00
|
|
|
|
if (res === undefined) {
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
2024-03-23 21:24:39 +08:00
|
|
|
|
const { success, message, data } = res.data;
|
|
|
|
|
|
if (success) {
|
|
|
|
|
|
if (data.models === '') {
|
|
|
|
|
|
data.models = [];
|
|
|
|
|
|
} else {
|
|
|
|
|
|
data.models = data.models.split(',');
|
|
|
|
|
|
}
|
|
|
|
|
|
if (data.group === '') {
|
|
|
|
|
|
data.groups = [];
|
|
|
|
|
|
} else {
|
|
|
|
|
|
data.groups = data.group.split(',');
|
|
|
|
|
|
}
|
|
|
|
|
|
if (data.model_mapping !== '') {
|
|
|
|
|
|
data.model_mapping = JSON.stringify(
|
|
|
|
|
|
JSON.parse(data.model_mapping),
|
|
|
|
|
|
null,
|
2025-04-04 12:00:38 +08:00
|
|
|
|
2,
|
2024-03-23 21:24:39 +08:00
|
|
|
|
);
|
|
|
|
|
|
}
|
2025-07-07 01:53:19 +08:00
|
|
|
|
const chInfo = data.channel_info || {};
|
|
|
|
|
|
const isMulti = chInfo.is_multi_key === true;
|
|
|
|
|
|
setIsMultiKeyChannel(isMulti);
|
|
|
|
|
|
if (isMulti) {
|
|
|
|
|
|
setBatch(true);
|
|
|
|
|
|
setMultiToSingle(true);
|
|
|
|
|
|
const modeVal = chInfo.multi_key_mode || 'random';
|
|
|
|
|
|
setMultiKeyMode(modeVal);
|
|
|
|
|
|
data.multi_key_mode = modeVal;
|
|
|
|
|
|
} else {
|
|
|
|
|
|
setBatch(false);
|
|
|
|
|
|
setMultiToSingle(false);
|
|
|
|
|
|
}
|
2025-07-26 11:39:09 +08:00
|
|
|
|
// 解析渠道额外设置并合并到data中
|
|
|
|
|
|
if (data.setting) {
|
|
|
|
|
|
try {
|
|
|
|
|
|
const parsedSettings = JSON.parse(data.setting);
|
|
|
|
|
|
data.force_format = parsedSettings.force_format || false;
|
2025-08-30 21:15:10 +08:00
|
|
|
|
data.thinking_to_content =
|
|
|
|
|
|
parsedSettings.thinking_to_content || false;
|
2025-07-26 11:39:09 +08:00
|
|
|
|
data.proxy = parsedSettings.proxy || '';
|
2025-08-30 21:15:10 +08:00
|
|
|
|
data.pass_through_body_enabled =
|
|
|
|
|
|
parsedSettings.pass_through_body_enabled || false;
|
2025-07-26 11:39:09 +08:00
|
|
|
|
data.system_prompt = parsedSettings.system_prompt || '';
|
2025-08-30 21:15:10 +08:00
|
|
|
|
data.system_prompt_override =
|
|
|
|
|
|
parsedSettings.system_prompt_override || false;
|
2025-07-26 11:39:09 +08:00
|
|
|
|
} catch (error) {
|
|
|
|
|
|
console.error('解析渠道设置失败:', error);
|
|
|
|
|
|
data.force_format = false;
|
|
|
|
|
|
data.thinking_to_content = false;
|
|
|
|
|
|
data.proxy = '';
|
|
|
|
|
|
data.pass_through_body_enabled = false;
|
2025-08-09 12:53:06 +08:00
|
|
|
|
data.system_prompt = '';
|
|
|
|
|
|
data.system_prompt_override = false;
|
2025-07-26 11:39:09 +08:00
|
|
|
|
}
|
|
|
|
|
|
} else {
|
|
|
|
|
|
data.force_format = false;
|
|
|
|
|
|
data.thinking_to_content = false;
|
|
|
|
|
|
data.proxy = '';
|
|
|
|
|
|
data.pass_through_body_enabled = false;
|
|
|
|
|
|
data.system_prompt = '';
|
2025-08-09 12:53:06 +08:00
|
|
|
|
data.system_prompt_override = false;
|
2025-07-26 11:39:09 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2025-08-10 20:21:30 +08:00
|
|
|
|
if (data.settings) {
|
|
|
|
|
|
try {
|
|
|
|
|
|
const parsedSettings = JSON.parse(data.settings);
|
2025-08-30 21:15:10 +08:00
|
|
|
|
data.azure_responses_version =
|
|
|
|
|
|
parsedSettings.azure_responses_version || '';
|
2025-09-12 19:11:17 +08:00
|
|
|
|
// 读取 Vertex 密钥格式
|
|
|
|
|
|
data.vertex_key_type = parsedSettings.vertex_key_type || 'json';
|
2025-08-10 20:21:30 +08:00
|
|
|
|
} catch (error) {
|
|
|
|
|
|
console.error('解析其他设置失败:', error);
|
|
|
|
|
|
data.azure_responses_version = '';
|
|
|
|
|
|
data.region = '';
|
2025-09-12 19:11:17 +08:00
|
|
|
|
data.vertex_key_type = 'json';
|
2025-08-10 20:21:30 +08:00
|
|
|
|
}
|
2025-09-12 19:11:17 +08:00
|
|
|
|
} else {
|
|
|
|
|
|
// 兼容历史数据:老渠道没有 settings 时,默认按 json 展示
|
|
|
|
|
|
data.vertex_key_type = 'json';
|
2025-08-10 20:21:30 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2024-03-23 21:24:39 +08:00
|
|
|
|
setInputs(data);
|
✨ refactor(EditChannel&EditToken): refactor Channel & Token edit pages with Semi Form and UX enhancements
Overview
• Migrated both `EditChannel.js` and `EditToken.js` to fully leverage Semi UI `Form.*` components, removing legacy `Input/Select/TextArea` + manual labels.
• Unified data-loading strategy: when the drawer becomes visible we load (or reset) data via `props.visible + id` effect and `formApi.setValues()`, guaranteeing fields are always populated; form resets on close.
• Fixed blank-form bug when opening the same record twice.
Key improvements
1. Validation
• `type`, `models` always required.
• `key` required only while creating (not on edit).
2. Batch key creation
• Checkbox moved into `extraText`; hidden when editing or when channel type = 41.
3. Layout & UI
• `Row / Col` (12 + 12) for “Priority” and “Weight”.
• Placeholders revised; model selector now shows creation hint; removed obsolete banner.
• Help / extraText used for long hints, template buttons (`model_mapping`, `status_code_mapping`, `param_override`, etc.), and API address notice.
• Added `showClear`, `min`, rounded card class names for consistency.
4. Reusable helpers
• `batchAllowed`, `batchExtra` utilities.
• `getInitValues()` + centralized `inputs`→form synchronization.
5. Token editor aligned to the same pattern (`props.visiable` watcher).
Result
Cleaner code, consistent UX, instant field population on every open, and clearer validation/error feedback across both editors.
2025-07-04 05:36:10 +08:00
|
|
|
|
if (formApiRef.current) {
|
|
|
|
|
|
formApiRef.current.setValues(data);
|
|
|
|
|
|
}
|
2024-03-23 21:24:39 +08:00
|
|
|
|
if (data.auto_ban === 0) {
|
|
|
|
|
|
setAutoBan(false);
|
|
|
|
|
|
} else {
|
|
|
|
|
|
setAutoBan(true);
|
|
|
|
|
|
}
|
2024-05-12 19:07:33 +08:00
|
|
|
|
setBasicModels(getChannelModels(data.type));
|
2025-07-26 11:39:09 +08:00
|
|
|
|
// 同步更新channelSettings状态显示
|
|
|
|
|
|
setChannelSettings({
|
|
|
|
|
|
force_format: data.force_format,
|
|
|
|
|
|
thinking_to_content: data.thinking_to_content,
|
|
|
|
|
|
proxy: data.proxy,
|
|
|
|
|
|
pass_through_body_enabled: data.pass_through_body_enabled,
|
|
|
|
|
|
system_prompt: data.system_prompt,
|
2025-08-09 12:53:06 +08:00
|
|
|
|
system_prompt_override: data.system_prompt_override || false,
|
2025-07-26 11:39:09 +08:00
|
|
|
|
});
|
2024-03-23 21:24:39 +08:00
|
|
|
|
// console.log(data);
|
|
|
|
|
|
} else {
|
|
|
|
|
|
showError(message);
|
|
|
|
|
|
}
|
|
|
|
|
|
setLoading(false);
|
|
|
|
|
|
};
|
2023-06-11 11:08:16 +08:00
|
|
|
|
|
2024-05-23 19:49:28 +08:00
|
|
|
|
const fetchUpstreamModelList = async (name) => {
|
2024-12-24 18:02:08 +08:00
|
|
|
|
// if (inputs['type'] !== 1) {
|
|
|
|
|
|
// showError(t('仅支持 OpenAI 接口格式'));
|
|
|
|
|
|
// return;
|
|
|
|
|
|
// }
|
2024-11-19 01:13:18 +08:00
|
|
|
|
setLoading(true);
|
2025-07-28 01:33:23 +08:00
|
|
|
|
const models = [];
|
2024-05-23 19:49:28 +08:00
|
|
|
|
let err = false;
|
2024-12-24 18:02:08 +08:00
|
|
|
|
|
2024-05-23 19:49:28 +08:00
|
|
|
|
if (isEdit) {
|
2025-07-11 23:37:47 +08:00
|
|
|
|
// 如果是编辑模式,使用已有的 channelId 获取模型列表
|
2025-08-30 21:15:10 +08:00
|
|
|
|
const res = await API.get('/api/channel/fetch_models/' + channelId, {
|
|
|
|
|
|
skipErrorHandler: true,
|
|
|
|
|
|
});
|
2025-07-11 23:37:47 +08:00
|
|
|
|
if (res && res.data && res.data.success) {
|
2024-11-19 01:13:18 +08:00
|
|
|
|
models.push(...res.data.data);
|
2024-05-23 19:49:28 +08:00
|
|
|
|
} else {
|
2024-11-19 01:13:18 +08:00
|
|
|
|
err = true;
|
2024-05-23 19:49:28 +08:00
|
|
|
|
}
|
|
|
|
|
|
} else {
|
2024-12-24 18:02:08 +08:00
|
|
|
|
// 如果是新建模式,通过后端代理获取模型列表
|
2024-11-19 01:13:18 +08:00
|
|
|
|
if (!inputs?.['key']) {
|
2024-12-13 19:03:14 +08:00
|
|
|
|
showError(t('请填写密钥'));
|
2024-11-19 01:13:18 +08:00
|
|
|
|
err = true;
|
2024-05-23 19:49:28 +08:00
|
|
|
|
} else {
|
|
|
|
|
|
try {
|
2025-07-11 23:37:47 +08:00
|
|
|
|
const res = await API.post(
|
|
|
|
|
|
'/api/channel/fetch_models',
|
|
|
|
|
|
{
|
|
|
|
|
|
base_url: inputs['base_url'],
|
|
|
|
|
|
type: inputs['type'],
|
|
|
|
|
|
key: inputs['key'],
|
|
|
|
|
|
},
|
|
|
|
|
|
{ skipErrorHandler: true },
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
if (res && res.data && res.data.success) {
|
2024-12-24 18:02:08 +08:00
|
|
|
|
models.push(...res.data.data);
|
2024-05-23 19:49:28 +08:00
|
|
|
|
} else {
|
2024-11-19 01:13:18 +08:00
|
|
|
|
err = true;
|
2024-05-23 19:49:28 +08:00
|
|
|
|
}
|
2024-11-19 01:13:18 +08:00
|
|
|
|
} catch (error) {
|
2024-12-24 18:02:08 +08:00
|
|
|
|
console.error('Error fetching models:', error);
|
2024-11-19 01:13:18 +08:00
|
|
|
|
err = true;
|
2024-05-23 19:49:28 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2024-12-24 18:02:08 +08:00
|
|
|
|
|
2024-05-23 19:49:28 +08:00
|
|
|
|
if (!err) {
|
2025-07-28 01:33:23 +08:00
|
|
|
|
const uniqueModels = Array.from(new Set(models));
|
|
|
|
|
|
setFetchedModels(uniqueModels);
|
|
|
|
|
|
setModelModalVisible(true);
|
2024-05-23 19:49:28 +08:00
|
|
|
|
} else {
|
2024-12-13 19:03:14 +08:00
|
|
|
|
showError(t('获取模型列表失败'));
|
2024-05-23 19:49:28 +08:00
|
|
|
|
}
|
|
|
|
|
|
setLoading(false);
|
2024-11-19 01:13:18 +08:00
|
|
|
|
};
|
2024-05-23 19:49:28 +08:00
|
|
|
|
|
2024-03-23 21:24:39 +08:00
|
|
|
|
const fetchModels = async () => {
|
|
|
|
|
|
try {
|
|
|
|
|
|
let res = await API.get(`/api/channel/models`);
|
2025-06-24 00:25:29 +08:00
|
|
|
|
const localModelOptions = res.data.data.map((model) => {
|
|
|
|
|
|
const id = (model.id || '').trim();
|
|
|
|
|
|
return {
|
|
|
|
|
|
key: id,
|
|
|
|
|
|
label: id,
|
|
|
|
|
|
value: id,
|
|
|
|
|
|
};
|
|
|
|
|
|
});
|
2024-03-23 21:24:39 +08:00
|
|
|
|
setOriginModelOptions(localModelOptions);
|
|
|
|
|
|
setFullModels(res.data.data.map((model) => model.id));
|
|
|
|
|
|
setBasicModels(
|
|
|
|
|
|
res.data.data
|
|
|
|
|
|
.filter((model) => {
|
2024-11-29 23:58:31 +08:00
|
|
|
|
return model.id.startsWith('gpt-') || model.id.startsWith('text-');
|
2024-03-23 21:24:39 +08:00
|
|
|
|
})
|
2025-04-04 12:00:38 +08:00
|
|
|
|
.map((model) => model.id),
|
2024-03-23 21:24:39 +08:00
|
|
|
|
);
|
|
|
|
|
|
} catch (error) {
|
|
|
|
|
|
showError(error.message);
|
|
|
|
|
|
}
|
|
|
|
|
|
};
|
2023-12-05 18:15:40 +08:00
|
|
|
|
|
2024-03-23 21:24:39 +08:00
|
|
|
|
const fetchGroups = async () => {
|
|
|
|
|
|
try {
|
|
|
|
|
|
let res = await API.get(`/api/group/`);
|
2024-03-25 14:10:57 +08:00
|
|
|
|
if (res === undefined) {
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
2024-03-23 21:24:39 +08:00
|
|
|
|
setGroupOptions(
|
|
|
|
|
|
res.data.data.map((group) => ({
|
|
|
|
|
|
label: group,
|
2025-04-04 12:00:38 +08:00
|
|
|
|
value: group,
|
|
|
|
|
|
})),
|
2024-03-23 21:24:39 +08:00
|
|
|
|
);
|
|
|
|
|
|
} catch (error) {
|
|
|
|
|
|
showError(error.message);
|
|
|
|
|
|
}
|
|
|
|
|
|
};
|
2023-12-05 18:15:40 +08:00
|
|
|
|
|
✨ feat(web): add model prefill group quick-add buttons to channel models selector
- Added support to fetch and render “model prefill groups” in `EditChannelModal.jsx`
- Users can now click a group button to instantly merge that group’s models into the models Select
- Mirrors the prefill-group UX used for tags/endpoints in `EditModelModal.jsx`
Details
- UI/UX:
- Renders one button per model group inside the models field’s extra actions
- Clicking a button merges its items into the selected models (trimmed, deduplicated), updating immediately
- Non-destructive and works alongside existing actions (fill related/all models, fetch upstream, clear, copy)
- API:
- GET `/api/prefill_group?type=model`
- Handles `items` as either an array or a JSON string array for robustness
- If request fails or returns no groups, buttons are simply not shown
- i18n:
- Reuses existing i18n; group names come from backend and are displayed as-is
- Performance:
- Simple set merge; negligible overhead
- Backward compatibility:
- No changes required on the backend or elsewhere; feature is additive
- Testing (manual):
1) Open channel modal (new or edit) and navigate to the Models section
2) Confirm model group buttons render when groups are configured
3) Click a group button → models Select updates with merged models (no duplicates)
4) Verify other actions (fill related/all, fetch upstream, clear, copy) still work
5) Close/reopen modal → state resets as expected
Implementation
- `web/src/components/table/channels/modals/EditChannelModal.jsx`
- Added `modelGroups` state and `fetchModelGroups()` (GET `/api/prefill_group?type=model`)
- Invoked `fetchModelGroups()` when the modal opens
- Rendered group buttons in the models Select `extraText`, merging group items into current selection
Chore
- Verified no new linter errors were introduced.
2025-08-08 04:48:18 +08:00
|
|
|
|
const fetchModelGroups = async () => {
|
|
|
|
|
|
try {
|
|
|
|
|
|
const res = await API.get('/api/prefill_group?type=model');
|
|
|
|
|
|
if (res?.data?.success) {
|
|
|
|
|
|
setModelGroups(res.data.data || []);
|
|
|
|
|
|
}
|
|
|
|
|
|
} catch (error) {
|
|
|
|
|
|
// ignore
|
|
|
|
|
|
}
|
|
|
|
|
|
};
|
|
|
|
|
|
|
2025-08-25 14:45:48 +08:00
|
|
|
|
// 使用TwoFactorAuthModal的验证函数
|
|
|
|
|
|
const handleVerify2FA = async () => {
|
|
|
|
|
|
if (!verifyCode) {
|
|
|
|
|
|
showError(t('请输入验证码或备用码'));
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
setVerifyLoading(true);
|
|
|
|
|
|
try {
|
|
|
|
|
|
const res = await API.post(`/api/channel/${channelId}/key`, {
|
2025-08-30 21:15:10 +08:00
|
|
|
|
code: verifyCode,
|
2025-08-25 14:45:48 +08:00
|
|
|
|
});
|
|
|
|
|
|
if (res.data.success) {
|
|
|
|
|
|
// 验证成功,显示密钥
|
|
|
|
|
|
updateTwoFAState({
|
|
|
|
|
|
showModal: true,
|
|
|
|
|
|
showKey: true,
|
2025-08-30 21:15:10 +08:00
|
|
|
|
keyData: res.data.data.key,
|
2025-08-25 14:45:48 +08:00
|
|
|
|
});
|
|
|
|
|
|
reset2FAVerifyState();
|
|
|
|
|
|
showSuccess(t('验证成功'));
|
|
|
|
|
|
} else {
|
|
|
|
|
|
showError(res.data.message);
|
|
|
|
|
|
}
|
|
|
|
|
|
} catch (error) {
|
|
|
|
|
|
showError(t('获取密钥失败'));
|
|
|
|
|
|
} finally {
|
|
|
|
|
|
setVerifyLoading(false);
|
|
|
|
|
|
}
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// 显示2FA验证模态框 - 使用TwoFactorAuthModal
|
|
|
|
|
|
const handleShow2FAModal = () => {
|
|
|
|
|
|
setShow2FAVerifyModal(true);
|
|
|
|
|
|
};
|
|
|
|
|
|
|
2025-06-24 00:02:22 +08:00
|
|
|
|
useEffect(() => {
|
|
|
|
|
|
const modelMap = new Map();
|
|
|
|
|
|
|
2025-07-13 19:32:01 +08:00
|
|
|
|
originModelOptions.forEach((option) => {
|
2025-06-24 00:25:29 +08:00
|
|
|
|
const v = (option.value || '').trim();
|
|
|
|
|
|
if (!modelMap.has(v)) {
|
|
|
|
|
|
modelMap.set(v, option);
|
|
|
|
|
|
}
|
2025-06-24 00:02:22 +08:00
|
|
|
|
});
|
|
|
|
|
|
|
2025-07-13 19:32:01 +08:00
|
|
|
|
inputs.models.forEach((model) => {
|
2025-06-24 00:25:29 +08:00
|
|
|
|
const v = (model || '').trim();
|
|
|
|
|
|
if (!modelMap.has(v)) {
|
|
|
|
|
|
modelMap.set(v, {
|
|
|
|
|
|
key: v,
|
|
|
|
|
|
label: v,
|
|
|
|
|
|
value: v,
|
2025-06-24 00:02:22 +08:00
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
|
2025-07-13 19:32:01 +08:00
|
|
|
|
const categories = getModelCategories(t);
|
|
|
|
|
|
const optionsWithIcon = Array.from(modelMap.values()).map((opt) => {
|
|
|
|
|
|
const modelName = opt.value;
|
|
|
|
|
|
let icon = null;
|
|
|
|
|
|
for (const [key, category] of Object.entries(categories)) {
|
|
|
|
|
|
if (key !== 'all' && category.filter({ model_name: modelName })) {
|
|
|
|
|
|
icon = category.icon;
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
return {
|
|
|
|
|
|
...opt,
|
|
|
|
|
|
label: (
|
2025-08-30 21:15:10 +08:00
|
|
|
|
<span className='flex items-center gap-1'>
|
2025-07-13 19:32:01 +08:00
|
|
|
|
{icon}
|
|
|
|
|
|
{modelName}
|
|
|
|
|
|
</span>
|
|
|
|
|
|
),
|
|
|
|
|
|
};
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
setModelOptions(optionsWithIcon);
|
|
|
|
|
|
}, [originModelOptions, inputs.models, t]);
|
2023-07-22 18:56:36 +08:00
|
|
|
|
|
2024-03-23 21:24:39 +08:00
|
|
|
|
useEffect(() => {
|
|
|
|
|
|
fetchModels().then();
|
|
|
|
|
|
fetchGroups().then();
|
✨ refactor(EditChannel&EditToken): refactor Channel & Token edit pages with Semi Form and UX enhancements
Overview
• Migrated both `EditChannel.js` and `EditToken.js` to fully leverage Semi UI `Form.*` components, removing legacy `Input/Select/TextArea` + manual labels.
• Unified data-loading strategy: when the drawer becomes visible we load (or reset) data via `props.visible + id` effect and `formApi.setValues()`, guaranteeing fields are always populated; form resets on close.
• Fixed blank-form bug when opening the same record twice.
Key improvements
1. Validation
• `type`, `models` always required.
• `key` required only while creating (not on edit).
2. Batch key creation
• Checkbox moved into `extraText`; hidden when editing or when channel type = 41.
3. Layout & UI
• `Row / Col` (12 + 12) for “Priority” and “Weight”.
• Placeholders revised; model selector now shows creation hint; removed obsolete banner.
• Help / extraText used for long hints, template buttons (`model_mapping`, `status_code_mapping`, `param_override`, etc.), and API address notice.
• Added `showClear`, `min`, rounded card class names for consistency.
4. Reusable helpers
• `batchAllowed`, `batchExtra` utilities.
• `getInitValues()` + centralized `inputs`→form synchronization.
5. Token editor aligned to the same pattern (`props.visiable` watcher).
Result
Cleaner code, consistent UX, instant field population on every open, and clearer validation/error feedback across both editors.
2025-07-04 05:36:10 +08:00
|
|
|
|
if (!isEdit) {
|
2024-03-23 21:24:39 +08:00
|
|
|
|
setInputs(originInputs);
|
✨ refactor(EditChannel&EditToken): refactor Channel & Token edit pages with Semi Form and UX enhancements
Overview
• Migrated both `EditChannel.js` and `EditToken.js` to fully leverage Semi UI `Form.*` components, removing legacy `Input/Select/TextArea` + manual labels.
• Unified data-loading strategy: when the drawer becomes visible we load (or reset) data via `props.visible + id` effect and `formApi.setValues()`, guaranteeing fields are always populated; form resets on close.
• Fixed blank-form bug when opening the same record twice.
Key improvements
1. Validation
• `type`, `models` always required.
• `key` required only while creating (not on edit).
2. Batch key creation
• Checkbox moved into `extraText`; hidden when editing or when channel type = 41.
3. Layout & UI
• `Row / Col` (12 + 12) for “Priority” and “Weight”.
• Placeholders revised; model selector now shows creation hint; removed obsolete banner.
• Help / extraText used for long hints, template buttons (`model_mapping`, `status_code_mapping`, `param_override`, etc.), and API address notice.
• Added `showClear`, `min`, rounded card class names for consistency.
4. Reusable helpers
• `batchAllowed`, `batchExtra` utilities.
• `getInitValues()` + centralized `inputs`→form synchronization.
5. Token editor aligned to the same pattern (`props.visiable` watcher).
Result
Cleaner code, consistent UX, instant field population on every open, and clearer validation/error feedback across both editors.
2025-07-04 05:36:10 +08:00
|
|
|
|
if (formApiRef.current) {
|
|
|
|
|
|
formApiRef.current.setValues(originInputs);
|
|
|
|
|
|
}
|
2024-05-12 19:07:33 +08:00
|
|
|
|
let localModels = getChannelModels(inputs.type);
|
|
|
|
|
|
setBasicModels(localModels);
|
|
|
|
|
|
setInputs((inputs) => ({ ...inputs, models: localModels }));
|
2024-03-23 21:24:39 +08:00
|
|
|
|
}
|
|
|
|
|
|
}, [props.editingChannel.id]);
|
2023-04-23 12:43:10 +08:00
|
|
|
|
|
✨ refactor(EditChannel&EditToken): refactor Channel & Token edit pages with Semi Form and UX enhancements
Overview
• Migrated both `EditChannel.js` and `EditToken.js` to fully leverage Semi UI `Form.*` components, removing legacy `Input/Select/TextArea` + manual labels.
• Unified data-loading strategy: when the drawer becomes visible we load (or reset) data via `props.visible + id` effect and `formApi.setValues()`, guaranteeing fields are always populated; form resets on close.
• Fixed blank-form bug when opening the same record twice.
Key improvements
1. Validation
• `type`, `models` always required.
• `key` required only while creating (not on edit).
2. Batch key creation
• Checkbox moved into `extraText`; hidden when editing or when channel type = 41.
3. Layout & UI
• `Row / Col` (12 + 12) for “Priority” and “Weight”.
• Placeholders revised; model selector now shows creation hint; removed obsolete banner.
• Help / extraText used for long hints, template buttons (`model_mapping`, `status_code_mapping`, `param_override`, etc.), and API address notice.
• Added `showClear`, `min`, rounded card class names for consistency.
4. Reusable helpers
• `batchAllowed`, `batchExtra` utilities.
• `getInitValues()` + centralized `inputs`→form synchronization.
5. Token editor aligned to the same pattern (`props.visiable` watcher).
Result
Cleaner code, consistent UX, instant field population on every open, and clearer validation/error feedback across both editors.
2025-07-04 05:36:10 +08:00
|
|
|
|
useEffect(() => {
|
|
|
|
|
|
if (formApiRef.current) {
|
|
|
|
|
|
formApiRef.current.setValues(inputs);
|
|
|
|
|
|
}
|
|
|
|
|
|
}, [inputs]);
|
|
|
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
|
if (props.visible) {
|
|
|
|
|
|
if (isEdit) {
|
|
|
|
|
|
loadChannel();
|
|
|
|
|
|
} else {
|
|
|
|
|
|
formApiRef.current?.setValues(getInitValues());
|
|
|
|
|
|
}
|
✨ feat(web): add model prefill group quick-add buttons to channel models selector
- Added support to fetch and render “model prefill groups” in `EditChannelModal.jsx`
- Users can now click a group button to instantly merge that group’s models into the models Select
- Mirrors the prefill-group UX used for tags/endpoints in `EditModelModal.jsx`
Details
- UI/UX:
- Renders one button per model group inside the models field’s extra actions
- Clicking a button merges its items into the selected models (trimmed, deduplicated), updating immediately
- Non-destructive and works alongside existing actions (fill related/all models, fetch upstream, clear, copy)
- API:
- GET `/api/prefill_group?type=model`
- Handles `items` as either an array or a JSON string array for robustness
- If request fails or returns no groups, buttons are simply not shown
- i18n:
- Reuses existing i18n; group names come from backend and are displayed as-is
- Performance:
- Simple set merge; negligible overhead
- Backward compatibility:
- No changes required on the backend or elsewhere; feature is additive
- Testing (manual):
1) Open channel modal (new or edit) and navigate to the Models section
2) Confirm model group buttons render when groups are configured
3) Click a group button → models Select updates with merged models (no duplicates)
4) Verify other actions (fill related/all, fetch upstream, clear, copy) still work
5) Close/reopen modal → state resets as expected
Implementation
- `web/src/components/table/channels/modals/EditChannelModal.jsx`
- Added `modelGroups` state and `fetchModelGroups()` (GET `/api/prefill_group?type=model`)
- Invoked `fetchModelGroups()` when the modal opens
- Rendered group buttons in the models Select `extraText`, merging group items into current selection
Chore
- Verified no new linter errors were introduced.
2025-08-08 04:48:18 +08:00
|
|
|
|
fetchModelGroups();
|
2025-07-17 19:53:33 +08:00
|
|
|
|
// 重置手动输入模式状态
|
|
|
|
|
|
setUseManualInput(false);
|
2025-09-19 18:09:26 +08:00
|
|
|
|
// 重置导航状态
|
|
|
|
|
|
setCurrentSectionIndex(0);
|
✨ refactor(EditChannel&EditToken): refactor Channel & Token edit pages with Semi Form and UX enhancements
Overview
• Migrated both `EditChannel.js` and `EditToken.js` to fully leverage Semi UI `Form.*` components, removing legacy `Input/Select/TextArea` + manual labels.
• Unified data-loading strategy: when the drawer becomes visible we load (or reset) data via `props.visible + id` effect and `formApi.setValues()`, guaranteeing fields are always populated; form resets on close.
• Fixed blank-form bug when opening the same record twice.
Key improvements
1. Validation
• `type`, `models` always required.
• `key` required only while creating (not on edit).
2. Batch key creation
• Checkbox moved into `extraText`; hidden when editing or when channel type = 41.
3. Layout & UI
• `Row / Col` (12 + 12) for “Priority” and “Weight”.
• Placeholders revised; model selector now shows creation hint; removed obsolete banner.
• Help / extraText used for long hints, template buttons (`model_mapping`, `status_code_mapping`, `param_override`, etc.), and API address notice.
• Added `showClear`, `min`, rounded card class names for consistency.
4. Reusable helpers
• `batchAllowed`, `batchExtra` utilities.
• `getInitValues()` + centralized `inputs`→form synchronization.
5. Token editor aligned to the same pattern (`props.visiable` watcher).
Result
Cleaner code, consistent UX, instant field population on every open, and clearer validation/error feedback across both editors.
2025-07-04 05:36:10 +08:00
|
|
|
|
} else {
|
2025-08-25 14:45:48 +08:00
|
|
|
|
// 统一的模态框关闭重置逻辑
|
|
|
|
|
|
resetModalState();
|
✨ refactor(EditChannel&EditToken): refactor Channel & Token edit pages with Semi Form and UX enhancements
Overview
• Migrated both `EditChannel.js` and `EditToken.js` to fully leverage Semi UI `Form.*` components, removing legacy `Input/Select/TextArea` + manual labels.
• Unified data-loading strategy: when the drawer becomes visible we load (or reset) data via `props.visible + id` effect and `formApi.setValues()`, guaranteeing fields are always populated; form resets on close.
• Fixed blank-form bug when opening the same record twice.
Key improvements
1. Validation
• `type`, `models` always required.
• `key` required only while creating (not on edit).
2. Batch key creation
• Checkbox moved into `extraText`; hidden when editing or when channel type = 41.
3. Layout & UI
• `Row / Col` (12 + 12) for “Priority” and “Weight”.
• Placeholders revised; model selector now shows creation hint; removed obsolete banner.
• Help / extraText used for long hints, template buttons (`model_mapping`, `status_code_mapping`, `param_override`, etc.), and API address notice.
• Added `showClear`, `min`, rounded card class names for consistency.
4. Reusable helpers
• `batchAllowed`, `batchExtra` utilities.
• `getInitValues()` + centralized `inputs`→form synchronization.
5. Token editor aligned to the same pattern (`props.visiable` watcher).
Result
Cleaner code, consistent UX, instant field population on every open, and clearer validation/error feedback across both editors.
2025-07-04 05:36:10 +08:00
|
|
|
|
}
|
|
|
|
|
|
}, [props.visible, channelId]);
|
|
|
|
|
|
|
2025-08-25 14:45:48 +08:00
|
|
|
|
// 统一的模态框重置函数
|
|
|
|
|
|
const resetModalState = () => {
|
|
|
|
|
|
formApiRef.current?.reset();
|
|
|
|
|
|
// 重置渠道设置状态
|
|
|
|
|
|
setChannelSettings({
|
|
|
|
|
|
force_format: false,
|
|
|
|
|
|
thinking_to_content: false,
|
|
|
|
|
|
proxy: '',
|
|
|
|
|
|
pass_through_body_enabled: false,
|
|
|
|
|
|
system_prompt: '',
|
|
|
|
|
|
system_prompt_override: false,
|
|
|
|
|
|
});
|
|
|
|
|
|
// 重置密钥模式状态
|
|
|
|
|
|
setKeyMode('append');
|
|
|
|
|
|
// 清空表单中的key_mode字段
|
|
|
|
|
|
if (formApiRef.current) {
|
|
|
|
|
|
formApiRef.current.setValue('key_mode', undefined);
|
|
|
|
|
|
}
|
|
|
|
|
|
// 重置本地输入,避免下次打开残留上一次的 JSON 字段值
|
|
|
|
|
|
setInputs(getInitValues());
|
|
|
|
|
|
// 重置2FA状态
|
|
|
|
|
|
resetTwoFAState();
|
|
|
|
|
|
// 重置2FA验证状态
|
|
|
|
|
|
reset2FAVerifyState();
|
|
|
|
|
|
};
|
|
|
|
|
|
|
2025-07-07 01:12:01 +08:00
|
|
|
|
const handleVertexUploadChange = ({ fileList }) => {
|
2025-07-15 12:02:04 +08:00
|
|
|
|
vertexErroredNames.current.clear();
|
2025-07-07 01:12:01 +08:00
|
|
|
|
(async () => {
|
2025-07-15 12:02:04 +08:00
|
|
|
|
let validFiles = [];
|
|
|
|
|
|
let keys = [];
|
2025-07-07 01:12:01 +08:00
|
|
|
|
const errorNames = [];
|
|
|
|
|
|
for (const item of fileList) {
|
|
|
|
|
|
const fileObj = item.fileInstance;
|
|
|
|
|
|
if (!fileObj) continue;
|
|
|
|
|
|
try {
|
|
|
|
|
|
const txt = await fileObj.text();
|
|
|
|
|
|
keys.push(JSON.parse(txt));
|
2025-07-15 12:02:04 +08:00
|
|
|
|
validFiles.push(item);
|
2025-07-07 01:12:01 +08:00
|
|
|
|
} catch (err) {
|
|
|
|
|
|
if (!vertexErroredNames.current.has(item.name)) {
|
|
|
|
|
|
errorNames.push(item.name);
|
|
|
|
|
|
vertexErroredNames.current.add(item.name);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-07-15 12:02:04 +08:00
|
|
|
|
// 非批量模式下只保留一个文件(最新选择的),避免重复叠加
|
|
|
|
|
|
if (!batch && validFiles.length > 1) {
|
|
|
|
|
|
validFiles = [validFiles[validFiles.length - 1]];
|
|
|
|
|
|
keys = [keys[keys.length - 1]];
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-07-07 01:12:01 +08:00
|
|
|
|
setVertexKeys(keys);
|
|
|
|
|
|
setVertexFileList(validFiles);
|
|
|
|
|
|
if (formApiRef.current) {
|
|
|
|
|
|
formApiRef.current.setValue('vertex_files', validFiles);
|
|
|
|
|
|
}
|
|
|
|
|
|
setInputs((prev) => ({ ...prev, vertex_files: validFiles }));
|
|
|
|
|
|
|
|
|
|
|
|
if (errorNames.length > 0) {
|
2025-08-30 21:15:10 +08:00
|
|
|
|
showError(
|
|
|
|
|
|
t('以下文件解析失败,已忽略:{{list}}', {
|
|
|
|
|
|
list: errorNames.join(', '),
|
|
|
|
|
|
}),
|
|
|
|
|
|
);
|
2025-07-07 01:12:01 +08:00
|
|
|
|
}
|
|
|
|
|
|
})();
|
|
|
|
|
|
};
|
|
|
|
|
|
|
2024-03-23 21:24:39 +08:00
|
|
|
|
const submit = async () => {
|
✨ refactor(EditChannel&EditToken): refactor Channel & Token edit pages with Semi Form and UX enhancements
Overview
• Migrated both `EditChannel.js` and `EditToken.js` to fully leverage Semi UI `Form.*` components, removing legacy `Input/Select/TextArea` + manual labels.
• Unified data-loading strategy: when the drawer becomes visible we load (or reset) data via `props.visible + id` effect and `formApi.setValues()`, guaranteeing fields are always populated; form resets on close.
• Fixed blank-form bug when opening the same record twice.
Key improvements
1. Validation
• `type`, `models` always required.
• `key` required only while creating (not on edit).
2. Batch key creation
• Checkbox moved into `extraText`; hidden when editing or when channel type = 41.
3. Layout & UI
• `Row / Col` (12 + 12) for “Priority” and “Weight”.
• Placeholders revised; model selector now shows creation hint; removed obsolete banner.
• Help / extraText used for long hints, template buttons (`model_mapping`, `status_code_mapping`, `param_override`, etc.), and API address notice.
• Added `showClear`, `min`, rounded card class names for consistency.
4. Reusable helpers
• `batchAllowed`, `batchExtra` utilities.
• `getInitValues()` + centralized `inputs`→form synchronization.
5. Token editor aligned to the same pattern (`props.visiable` watcher).
Result
Cleaner code, consistent UX, instant field population on every open, and clearer validation/error feedback across both editors.
2025-07-04 05:36:10 +08:00
|
|
|
|
const formValues = formApiRef.current ? formApiRef.current.getValues() : {};
|
|
|
|
|
|
let localInputs = { ...formValues };
|
|
|
|
|
|
|
2025-07-11 21:12:17 +08:00
|
|
|
|
if (localInputs.type === 41) {
|
2025-09-12 19:11:17 +08:00
|
|
|
|
const keyType = localInputs.vertex_key_type || 'json';
|
|
|
|
|
|
if (keyType === 'api_key') {
|
|
|
|
|
|
// 直接作为普通字符串密钥处理
|
|
|
|
|
|
if (!isEdit && (!localInputs.key || localInputs.key.trim() === '')) {
|
2025-07-17 19:53:33 +08:00
|
|
|
|
showInfo(t('请输入密钥!'));
|
2025-07-13 00:09:27 +08:00
|
|
|
|
return;
|
|
|
|
|
|
}
|
2025-07-11 21:12:17 +08:00
|
|
|
|
} else {
|
2025-09-12 19:11:17 +08:00
|
|
|
|
// JSON 服务账号密钥
|
|
|
|
|
|
if (useManualInput) {
|
|
|
|
|
|
if (localInputs.key && localInputs.key.trim() !== '') {
|
|
|
|
|
|
try {
|
|
|
|
|
|
const parsedKey = JSON.parse(localInputs.key);
|
|
|
|
|
|
localInputs.key = JSON.stringify(parsedKey);
|
|
|
|
|
|
} catch (err) {
|
|
|
|
|
|
showError(t('密钥格式无效,请输入有效的 JSON 格式密钥'));
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
} else if (!isEdit) {
|
|
|
|
|
|
showInfo(t('请输入密钥!'));
|
2025-07-17 19:53:33 +08:00
|
|
|
|
return;
|
|
|
|
|
|
}
|
2025-07-13 00:09:27 +08:00
|
|
|
|
} else {
|
2025-09-12 19:11:17 +08:00
|
|
|
|
// 文件上传模式
|
|
|
|
|
|
let keys = vertexKeys;
|
|
|
|
|
|
if (keys.length === 0 && vertexFileList.length > 0) {
|
|
|
|
|
|
try {
|
|
|
|
|
|
const parsed = await Promise.all(
|
|
|
|
|
|
vertexFileList.map(async (item) => {
|
|
|
|
|
|
const fileObj = item.fileInstance;
|
|
|
|
|
|
if (!fileObj) return null;
|
|
|
|
|
|
const txt = await fileObj.text();
|
|
|
|
|
|
return JSON.parse(txt);
|
|
|
|
|
|
}),
|
|
|
|
|
|
);
|
|
|
|
|
|
keys = parsed.filter(Boolean);
|
|
|
|
|
|
} catch (err) {
|
|
|
|
|
|
showError(t('解析密钥文件失败: {{msg}}', { msg: err.message }));
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
if (keys.length === 0) {
|
|
|
|
|
|
if (!isEdit) {
|
|
|
|
|
|
showInfo(t('请上传密钥文件!'));
|
|
|
|
|
|
return;
|
|
|
|
|
|
} else {
|
|
|
|
|
|
delete localInputs.key;
|
|
|
|
|
|
}
|
2025-07-17 19:53:33 +08:00
|
|
|
|
} else {
|
2025-09-12 19:11:17 +08:00
|
|
|
|
localInputs.key = batch ? JSON.stringify(keys) : JSON.stringify(keys[0]);
|
2025-07-17 19:53:33 +08:00
|
|
|
|
}
|
2025-07-13 00:09:27 +08:00
|
|
|
|
}
|
2025-07-11 21:12:17 +08:00
|
|
|
|
}
|
2025-07-07 01:12:01 +08:00
|
|
|
|
}
|
2025-07-13 00:09:27 +08:00
|
|
|
|
|
|
|
|
|
|
// 如果是编辑模式且 key 为空字符串,避免提交空值覆盖旧密钥
|
|
|
|
|
|
if (isEdit && (!localInputs.key || localInputs.key.trim() === '')) {
|
|
|
|
|
|
delete localInputs.key;
|
|
|
|
|
|
}
|
2025-07-07 01:12:01 +08:00
|
|
|
|
delete localInputs.vertex_files;
|
|
|
|
|
|
|
✨ refactor(EditChannel&EditToken): refactor Channel & Token edit pages with Semi Form and UX enhancements
Overview
• Migrated both `EditChannel.js` and `EditToken.js` to fully leverage Semi UI `Form.*` components, removing legacy `Input/Select/TextArea` + manual labels.
• Unified data-loading strategy: when the drawer becomes visible we load (or reset) data via `props.visible + id` effect and `formApi.setValues()`, guaranteeing fields are always populated; form resets on close.
• Fixed blank-form bug when opening the same record twice.
Key improvements
1. Validation
• `type`, `models` always required.
• `key` required only while creating (not on edit).
2. Batch key creation
• Checkbox moved into `extraText`; hidden when editing or when channel type = 41.
3. Layout & UI
• `Row / Col` (12 + 12) for “Priority” and “Weight”.
• Placeholders revised; model selector now shows creation hint; removed obsolete banner.
• Help / extraText used for long hints, template buttons (`model_mapping`, `status_code_mapping`, `param_override`, etc.), and API address notice.
• Added `showClear`, `min`, rounded card class names for consistency.
4. Reusable helpers
• `batchAllowed`, `batchExtra` utilities.
• `getInitValues()` + centralized `inputs`→form synchronization.
5. Token editor aligned to the same pattern (`props.visiable` watcher).
Result
Cleaner code, consistent UX, instant field population on every open, and clearer validation/error feedback across both editors.
2025-07-04 05:36:10 +08:00
|
|
|
|
if (!isEdit && (!localInputs.name || !localInputs.key)) {
|
2024-12-13 19:03:14 +08:00
|
|
|
|
showInfo(t('请填写渠道名称和渠道密钥!'));
|
2024-03-23 21:24:39 +08:00
|
|
|
|
return;
|
|
|
|
|
|
}
|
✨ refactor(EditChannel&EditToken): refactor Channel & Token edit pages with Semi Form and UX enhancements
Overview
• Migrated both `EditChannel.js` and `EditToken.js` to fully leverage Semi UI `Form.*` components, removing legacy `Input/Select/TextArea` + manual labels.
• Unified data-loading strategy: when the drawer becomes visible we load (or reset) data via `props.visible + id` effect and `formApi.setValues()`, guaranteeing fields are always populated; form resets on close.
• Fixed blank-form bug when opening the same record twice.
Key improvements
1. Validation
• `type`, `models` always required.
• `key` required only while creating (not on edit).
2. Batch key creation
• Checkbox moved into `extraText`; hidden when editing or when channel type = 41.
3. Layout & UI
• `Row / Col` (12 + 12) for “Priority” and “Weight”.
• Placeholders revised; model selector now shows creation hint; removed obsolete banner.
• Help / extraText used for long hints, template buttons (`model_mapping`, `status_code_mapping`, `param_override`, etc.), and API address notice.
• Added `showClear`, `min`, rounded card class names for consistency.
4. Reusable helpers
• `batchAllowed`, `batchExtra` utilities.
• `getInitValues()` + centralized `inputs`→form synchronization.
5. Token editor aligned to the same pattern (`props.visiable` watcher).
Result
Cleaner code, consistent UX, instant field population on every open, and clearer validation/error feedback across both editors.
2025-07-04 05:36:10 +08:00
|
|
|
|
if (!Array.isArray(localInputs.models) || localInputs.models.length === 0) {
|
2024-12-13 19:03:14 +08:00
|
|
|
|
showInfo(t('请至少选择一个模型!'));
|
2024-03-23 21:24:39 +08:00
|
|
|
|
return;
|
|
|
|
|
|
}
|
2025-09-27 17:03:34 +08:00
|
|
|
|
if (localInputs.type === 45 && (!localInputs.base_url || localInputs.base_url.trim() === '')) {
|
|
|
|
|
|
showInfo(t('请输入API地址!'));
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
2025-08-30 21:15:10 +08:00
|
|
|
|
if (
|
|
|
|
|
|
localInputs.model_mapping &&
|
|
|
|
|
|
localInputs.model_mapping !== '' &&
|
|
|
|
|
|
!verifyJSON(localInputs.model_mapping)
|
|
|
|
|
|
) {
|
2024-12-13 19:03:14 +08:00
|
|
|
|
showInfo(t('模型映射必须是合法的 JSON 格式!'));
|
2024-03-23 21:24:39 +08:00
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
if (localInputs.base_url && localInputs.base_url.endsWith('/')) {
|
|
|
|
|
|
localInputs.base_url = localInputs.base_url.slice(
|
|
|
|
|
|
0,
|
2025-04-04 12:00:38 +08:00
|
|
|
|
localInputs.base_url.length - 1,
|
2024-03-23 21:24:39 +08:00
|
|
|
|
);
|
|
|
|
|
|
}
|
|
|
|
|
|
if (localInputs.type === 18 && localInputs.other === '') {
|
|
|
|
|
|
localInputs.other = 'v2.1';
|
|
|
|
|
|
}
|
2025-07-26 13:33:10 +08:00
|
|
|
|
|
2025-07-26 11:39:09 +08:00
|
|
|
|
// 生成渠道额外设置JSON
|
|
|
|
|
|
const channelExtraSettings = {
|
|
|
|
|
|
force_format: localInputs.force_format || false,
|
|
|
|
|
|
thinking_to_content: localInputs.thinking_to_content || false,
|
|
|
|
|
|
proxy: localInputs.proxy || '',
|
|
|
|
|
|
pass_through_body_enabled: localInputs.pass_through_body_enabled || false,
|
|
|
|
|
|
system_prompt: localInputs.system_prompt || '',
|
2025-08-09 12:53:06 +08:00
|
|
|
|
system_prompt_override: localInputs.system_prompt_override || false,
|
2025-07-26 11:39:09 +08:00
|
|
|
|
};
|
|
|
|
|
|
localInputs.setting = JSON.stringify(channelExtraSettings);
|
2025-07-26 13:33:10 +08:00
|
|
|
|
|
2025-07-26 11:39:09 +08:00
|
|
|
|
// 清理不需要发送到后端的字段
|
|
|
|
|
|
delete localInputs.force_format;
|
|
|
|
|
|
delete localInputs.thinking_to_content;
|
|
|
|
|
|
delete localInputs.proxy;
|
|
|
|
|
|
delete localInputs.pass_through_body_enabled;
|
|
|
|
|
|
delete localInputs.system_prompt;
|
2025-08-09 12:53:06 +08:00
|
|
|
|
delete localInputs.system_prompt_override;
|
2025-09-12 19:11:17 +08:00
|
|
|
|
// 顶层的 vertex_key_type 不应发送给后端
|
|
|
|
|
|
delete localInputs.vertex_key_type;
|
2025-07-26 13:33:10 +08:00
|
|
|
|
|
2024-03-23 21:24:39 +08:00
|
|
|
|
let res;
|
✨ refactor(EditChannel&EditToken): refactor Channel & Token edit pages with Semi Form and UX enhancements
Overview
• Migrated both `EditChannel.js` and `EditToken.js` to fully leverage Semi UI `Form.*` components, removing legacy `Input/Select/TextArea` + manual labels.
• Unified data-loading strategy: when the drawer becomes visible we load (or reset) data via `props.visible + id` effect and `formApi.setValues()`, guaranteeing fields are always populated; form resets on close.
• Fixed blank-form bug when opening the same record twice.
Key improvements
1. Validation
• `type`, `models` always required.
• `key` required only while creating (not on edit).
2. Batch key creation
• Checkbox moved into `extraText`; hidden when editing or when channel type = 41.
3. Layout & UI
• `Row / Col` (12 + 12) for “Priority” and “Weight”.
• Placeholders revised; model selector now shows creation hint; removed obsolete banner.
• Help / extraText used for long hints, template buttons (`model_mapping`, `status_code_mapping`, `param_override`, etc.), and API address notice.
• Added `showClear`, `min`, rounded card class names for consistency.
4. Reusable helpers
• `batchAllowed`, `batchExtra` utilities.
• `getInitValues()` + centralized `inputs`→form synchronization.
5. Token editor aligned to the same pattern (`props.visiable` watcher).
Result
Cleaner code, consistent UX, instant field population on every open, and clearer validation/error feedback across both editors.
2025-07-04 05:36:10 +08:00
|
|
|
|
localInputs.auto_ban = localInputs.auto_ban ? 1 : 0;
|
2024-03-23 21:24:39 +08:00
|
|
|
|
localInputs.models = localInputs.models.join(',');
|
✨ refactor(EditChannel&EditToken): refactor Channel & Token edit pages with Semi Form and UX enhancements
Overview
• Migrated both `EditChannel.js` and `EditToken.js` to fully leverage Semi UI `Form.*` components, removing legacy `Input/Select/TextArea` + manual labels.
• Unified data-loading strategy: when the drawer becomes visible we load (or reset) data via `props.visible + id` effect and `formApi.setValues()`, guaranteeing fields are always populated; form resets on close.
• Fixed blank-form bug when opening the same record twice.
Key improvements
1. Validation
• `type`, `models` always required.
• `key` required only while creating (not on edit).
2. Batch key creation
• Checkbox moved into `extraText`; hidden when editing or when channel type = 41.
3. Layout & UI
• `Row / Col` (12 + 12) for “Priority” and “Weight”.
• Placeholders revised; model selector now shows creation hint; removed obsolete banner.
• Help / extraText used for long hints, template buttons (`model_mapping`, `status_code_mapping`, `param_override`, etc.), and API address notice.
• Added `showClear`, `min`, rounded card class names for consistency.
4. Reusable helpers
• `batchAllowed`, `batchExtra` utilities.
• `getInitValues()` + centralized `inputs`→form synchronization.
5. Token editor aligned to the same pattern (`props.visiable` watcher).
Result
Cleaner code, consistent UX, instant field population on every open, and clearer validation/error feedback across both editors.
2025-07-04 05:36:10 +08:00
|
|
|
|
localInputs.group = (localInputs.groups || []).join(',');
|
2025-07-07 01:12:01 +08:00
|
|
|
|
|
|
|
|
|
|
let mode = 'single';
|
|
|
|
|
|
if (batch) {
|
|
|
|
|
|
mode = multiToSingle ? 'multi_to_single' : 'batch';
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-03-23 21:24:39 +08:00
|
|
|
|
if (isEdit) {
|
|
|
|
|
|
res = await API.put(`/api/channel/`, {
|
|
|
|
|
|
...localInputs,
|
2025-04-04 12:00:38 +08:00
|
|
|
|
id: parseInt(channelId),
|
2025-08-02 10:57:03 +08:00
|
|
|
|
key_mode: isMultiKeyChannel ? keyMode : undefined, // 只在多key模式下传递
|
2024-03-23 21:24:39 +08:00
|
|
|
|
});
|
|
|
|
|
|
} else {
|
2025-07-07 01:12:01 +08:00
|
|
|
|
res = await API.post(`/api/channel/`, {
|
|
|
|
|
|
mode: mode,
|
|
|
|
|
|
multi_key_mode: mode === 'multi_to_single' ? multiKeyMode : undefined,
|
|
|
|
|
|
channel: localInputs,
|
|
|
|
|
|
});
|
2024-03-23 21:24:39 +08:00
|
|
|
|
}
|
|
|
|
|
|
const { success, message } = res.data;
|
|
|
|
|
|
if (success) {
|
|
|
|
|
|
if (isEdit) {
|
2024-12-13 19:03:14 +08:00
|
|
|
|
showSuccess(t('渠道更新成功!'));
|
2024-03-23 21:24:39 +08:00
|
|
|
|
} else {
|
2024-12-13 19:03:14 +08:00
|
|
|
|
showSuccess(t('渠道创建成功!'));
|
2024-03-23 21:24:39 +08:00
|
|
|
|
setInputs(originInputs);
|
|
|
|
|
|
}
|
|
|
|
|
|
props.refresh();
|
|
|
|
|
|
props.handleClose();
|
|
|
|
|
|
} else {
|
|
|
|
|
|
showError(message);
|
|
|
|
|
|
}
|
|
|
|
|
|
};
|
2023-09-25 18:44:10 +08:00
|
|
|
|
|
2024-05-05 02:06:40 +08:00
|
|
|
|
const addCustomModels = () => {
|
2024-03-23 21:24:39 +08:00
|
|
|
|
if (customModel.trim() === '') return;
|
2024-05-18 16:06:12 +08:00
|
|
|
|
const modelArray = customModel.split(',').map((model) => model.trim());
|
2024-05-21 17:57:19 +08:00
|
|
|
|
|
2024-03-23 21:24:39 +08:00
|
|
|
|
let localModels = [...inputs.models];
|
2024-05-05 02:06:40 +08:00
|
|
|
|
let localModelOptions = [...modelOptions];
|
2025-06-13 13:49:15 +08:00
|
|
|
|
const addedModels = [];
|
2024-05-05 02:06:40 +08:00
|
|
|
|
|
2024-05-18 16:06:12 +08:00
|
|
|
|
modelArray.forEach((model) => {
|
2024-05-05 02:06:40 +08:00
|
|
|
|
if (model && !localModels.includes(model)) {
|
2024-12-13 19:03:14 +08:00
|
|
|
|
localModels.push(model);
|
2024-05-18 16:06:12 +08:00
|
|
|
|
localModelOptions.push({
|
2024-05-05 02:06:40 +08:00
|
|
|
|
key: model,
|
2025-06-24 00:25:29 +08:00
|
|
|
|
label: model,
|
2025-04-04 12:00:38 +08:00
|
|
|
|
value: model,
|
2024-05-05 02:06:40 +08:00
|
|
|
|
});
|
2025-06-13 13:49:15 +08:00
|
|
|
|
addedModels.push(model);
|
2024-05-05 02:06:40 +08:00
|
|
|
|
}
|
2024-03-23 21:24:39 +08:00
|
|
|
|
});
|
2024-05-05 02:06:40 +08:00
|
|
|
|
|
|
|
|
|
|
setModelOptions(localModelOptions);
|
2024-03-23 21:24:39 +08:00
|
|
|
|
setCustomModel('');
|
|
|
|
|
|
handleInputChange('models', localModels);
|
2025-06-13 13:49:15 +08:00
|
|
|
|
|
|
|
|
|
|
if (addedModels.length > 0) {
|
|
|
|
|
|
showSuccess(
|
|
|
|
|
|
t('已新增 {{count}} 个模型:{{list}}', {
|
|
|
|
|
|
count: addedModels.length,
|
|
|
|
|
|
list: addedModels.join(', '),
|
2025-08-30 21:15:10 +08:00
|
|
|
|
}),
|
2025-06-13 13:49:15 +08:00
|
|
|
|
);
|
|
|
|
|
|
} else {
|
|
|
|
|
|
showInfo(t('未发现新增模型'));
|
|
|
|
|
|
}
|
2024-03-23 21:24:39 +08:00
|
|
|
|
};
|
2023-04-23 12:43:10 +08:00
|
|
|
|
|
2025-07-07 01:53:19 +08:00
|
|
|
|
const batchAllowed = !isEdit || isMultiKeyChannel;
|
✨ refactor(EditChannel&EditToken): refactor Channel & Token edit pages with Semi Form and UX enhancements
Overview
• Migrated both `EditChannel.js` and `EditToken.js` to fully leverage Semi UI `Form.*` components, removing legacy `Input/Select/TextArea` + manual labels.
• Unified data-loading strategy: when the drawer becomes visible we load (or reset) data via `props.visible + id` effect and `formApi.setValues()`, guaranteeing fields are always populated; form resets on close.
• Fixed blank-form bug when opening the same record twice.
Key improvements
1. Validation
• `type`, `models` always required.
• `key` required only while creating (not on edit).
2. Batch key creation
• Checkbox moved into `extraText`; hidden when editing or when channel type = 41.
3. Layout & UI
• `Row / Col` (12 + 12) for “Priority” and “Weight”.
• Placeholders revised; model selector now shows creation hint; removed obsolete banner.
• Help / extraText used for long hints, template buttons (`model_mapping`, `status_code_mapping`, `param_override`, etc.), and API address notice.
• Added `showClear`, `min`, rounded card class names for consistency.
4. Reusable helpers
• `batchAllowed`, `batchExtra` utilities.
• `getInitValues()` + centralized `inputs`→form synchronization.
5. Token editor aligned to the same pattern (`props.visiable` watcher).
Result
Cleaner code, consistent UX, instant field population on every open, and clearer validation/error feedback across both editors.
2025-07-04 05:36:10 +08:00
|
|
|
|
const batchExtra = batchAllowed ? (
|
2025-07-07 01:12:01 +08:00
|
|
|
|
<Space>
|
2025-08-02 10:57:03 +08:00
|
|
|
|
{!isEdit && (
|
|
|
|
|
|
<Checkbox
|
|
|
|
|
|
disabled={isEdit}
|
|
|
|
|
|
checked={batch}
|
|
|
|
|
|
onChange={(e) => {
|
|
|
|
|
|
const checked = e.target.checked;
|
|
|
|
|
|
|
|
|
|
|
|
if (!checked && vertexFileList.length > 1) {
|
|
|
|
|
|
Modal.confirm({
|
|
|
|
|
|
title: t('切换为单密钥模式'),
|
2025-08-30 21:15:10 +08:00
|
|
|
|
content: t(
|
|
|
|
|
|
'将仅保留第一个密钥文件,其余文件将被移除,是否继续?',
|
|
|
|
|
|
),
|
2025-08-02 10:57:03 +08:00
|
|
|
|
onOk: () => {
|
|
|
|
|
|
const firstFile = vertexFileList[0];
|
|
|
|
|
|
const firstKey = vertexKeys[0] ? [vertexKeys[0]] : [];
|
|
|
|
|
|
|
|
|
|
|
|
setVertexFileList([firstFile]);
|
|
|
|
|
|
setVertexKeys(firstKey);
|
|
|
|
|
|
|
|
|
|
|
|
formApiRef.current?.setValue('vertex_files', [firstFile]);
|
|
|
|
|
|
setInputs((prev) => ({ ...prev, vertex_files: [firstFile] }));
|
|
|
|
|
|
|
|
|
|
|
|
setBatch(false);
|
|
|
|
|
|
setMultiToSingle(false);
|
|
|
|
|
|
setMultiKeyMode('random');
|
|
|
|
|
|
},
|
|
|
|
|
|
onCancel: () => {
|
|
|
|
|
|
setBatch(true);
|
|
|
|
|
|
},
|
|
|
|
|
|
centered: true,
|
|
|
|
|
|
});
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
2025-07-15 12:02:04 +08:00
|
|
|
|
|
2025-08-02 10:57:03 +08:00
|
|
|
|
setBatch(checked);
|
|
|
|
|
|
if (!checked) {
|
|
|
|
|
|
setMultiToSingle(false);
|
|
|
|
|
|
setMultiKeyMode('random');
|
|
|
|
|
|
} else {
|
|
|
|
|
|
// 批量模式下禁用手动输入,并清空手动输入的内容
|
|
|
|
|
|
setUseManualInput(false);
|
|
|
|
|
|
if (inputs.type === 41) {
|
|
|
|
|
|
// 清空手动输入的密钥内容
|
|
|
|
|
|
if (formApiRef.current) {
|
|
|
|
|
|
formApiRef.current.setValue('key', '');
|
|
|
|
|
|
}
|
|
|
|
|
|
handleInputChange('key', '');
|
2025-07-17 19:53:33 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2025-08-02 10:57:03 +08:00
|
|
|
|
}}
|
|
|
|
|
|
>
|
|
|
|
|
|
{t('批量创建')}
|
|
|
|
|
|
</Checkbox>
|
|
|
|
|
|
)}
|
2025-07-23 22:00:30 +08:00
|
|
|
|
{batch && (
|
2025-08-30 21:15:10 +08:00
|
|
|
|
<Checkbox
|
|
|
|
|
|
disabled={isEdit}
|
|
|
|
|
|
checked={multiToSingle}
|
|
|
|
|
|
onChange={() => {
|
|
|
|
|
|
setMultiToSingle((prev) => !prev);
|
|
|
|
|
|
setInputs((prev) => {
|
|
|
|
|
|
const newInputs = { ...prev };
|
|
|
|
|
|
if (!multiToSingle) {
|
|
|
|
|
|
newInputs.multi_key_mode = multiKeyMode;
|
|
|
|
|
|
} else {
|
|
|
|
|
|
delete newInputs.multi_key_mode;
|
|
|
|
|
|
}
|
|
|
|
|
|
return newInputs;
|
|
|
|
|
|
});
|
|
|
|
|
|
}}
|
|
|
|
|
|
>
|
|
|
|
|
|
{t('密钥聚合模式')}
|
|
|
|
|
|
</Checkbox>
|
2025-07-23 22:00:30 +08:00
|
|
|
|
)}
|
2025-07-07 01:12:01 +08:00
|
|
|
|
</Space>
|
✨ refactor(EditChannel&EditToken): refactor Channel & Token edit pages with Semi Form and UX enhancements
Overview
• Migrated both `EditChannel.js` and `EditToken.js` to fully leverage Semi UI `Form.*` components, removing legacy `Input/Select/TextArea` + manual labels.
• Unified data-loading strategy: when the drawer becomes visible we load (or reset) data via `props.visible + id` effect and `formApi.setValues()`, guaranteeing fields are always populated; form resets on close.
• Fixed blank-form bug when opening the same record twice.
Key improvements
1. Validation
• `type`, `models` always required.
• `key` required only while creating (not on edit).
2. Batch key creation
• Checkbox moved into `extraText`; hidden when editing or when channel type = 41.
3. Layout & UI
• `Row / Col` (12 + 12) for “Priority” and “Weight”.
• Placeholders revised; model selector now shows creation hint; removed obsolete banner.
• Help / extraText used for long hints, template buttons (`model_mapping`, `status_code_mapping`, `param_override`, etc.), and API address notice.
• Added `showClear`, `min`, rounded card class names for consistency.
4. Reusable helpers
• `batchAllowed`, `batchExtra` utilities.
• `getInitValues()` + centralized `inputs`→form synchronization.
5. Token editor aligned to the same pattern (`props.visiable` watcher).
Result
Cleaner code, consistent UX, instant field population on every open, and clearer validation/error feedback across both editors.
2025-07-04 05:36:10 +08:00
|
|
|
|
) : null;
|
|
|
|
|
|
|
2025-07-12 00:02:12 +08:00
|
|
|
|
const channelOptionList = useMemo(
|
|
|
|
|
|
() =>
|
|
|
|
|
|
CHANNEL_OPTIONS.map((opt) => ({
|
|
|
|
|
|
...opt,
|
2025-07-17 19:53:33 +08:00
|
|
|
|
// 保持 label 为纯文本以支持搜索
|
|
|
|
|
|
label: opt.label,
|
2025-07-12 00:02:12 +08:00
|
|
|
|
})),
|
|
|
|
|
|
[],
|
|
|
|
|
|
);
|
|
|
|
|
|
|
2025-07-17 19:53:33 +08:00
|
|
|
|
const renderChannelOption = (renderProps) => {
|
|
|
|
|
|
const {
|
|
|
|
|
|
disabled,
|
|
|
|
|
|
selected,
|
|
|
|
|
|
label,
|
|
|
|
|
|
value,
|
|
|
|
|
|
focused,
|
|
|
|
|
|
className,
|
|
|
|
|
|
style,
|
|
|
|
|
|
onMouseEnter,
|
|
|
|
|
|
onClick,
|
|
|
|
|
|
...rest
|
|
|
|
|
|
} = renderProps;
|
2025-07-19 00:58:18 +08:00
|
|
|
|
|
2025-07-17 19:53:33 +08:00
|
|
|
|
const searchWords = channelSearchValue ? [channelSearchValue] : [];
|
2025-07-19 00:58:18 +08:00
|
|
|
|
|
2025-07-17 19:53:33 +08:00
|
|
|
|
// 构建样式类名
|
|
|
|
|
|
const optionClassName = [
|
|
|
|
|
|
'flex items-center gap-3 px-3 py-2 transition-all duration-200 rounded-lg mx-2 my-1',
|
|
|
|
|
|
focused && 'bg-blue-50 shadow-sm',
|
2025-08-30 21:15:10 +08:00
|
|
|
|
selected &&
|
|
|
|
|
|
'bg-blue-100 text-blue-700 shadow-lg ring-2 ring-blue-200 ring-opacity-50',
|
2025-07-17 19:53:33 +08:00
|
|
|
|
disabled && 'opacity-50 cursor-not-allowed',
|
|
|
|
|
|
!disabled && 'hover:bg-gray-50 hover:shadow-md cursor-pointer',
|
2025-08-30 21:15:10 +08:00
|
|
|
|
className,
|
|
|
|
|
|
]
|
|
|
|
|
|
.filter(Boolean)
|
|
|
|
|
|
.join(' ');
|
2025-07-19 00:58:18 +08:00
|
|
|
|
|
2025-07-17 19:53:33 +08:00
|
|
|
|
return (
|
2025-07-19 00:58:18 +08:00
|
|
|
|
<div
|
|
|
|
|
|
style={style}
|
2025-07-17 19:53:33 +08:00
|
|
|
|
className={optionClassName}
|
2025-07-19 00:58:18 +08:00
|
|
|
|
onClick={() => !disabled && onClick()}
|
2025-08-30 21:15:10 +08:00
|
|
|
|
onMouseEnter={(e) => onMouseEnter()}
|
2025-07-17 19:53:33 +08:00
|
|
|
|
>
|
2025-08-30 21:15:10 +08:00
|
|
|
|
<div className='flex items-center gap-3 w-full'>
|
|
|
|
|
|
<div className='flex-shrink-0 w-5 h-5 flex items-center justify-center'>
|
2025-07-17 19:53:33 +08:00
|
|
|
|
{getChannelIcon(value)}
|
|
|
|
|
|
</div>
|
2025-08-30 21:15:10 +08:00
|
|
|
|
<div className='flex-1 min-w-0'>
|
2025-07-19 00:58:18 +08:00
|
|
|
|
<Highlight
|
|
|
|
|
|
sourceString={label}
|
2025-07-17 19:53:33 +08:00
|
|
|
|
searchWords={searchWords}
|
2025-08-30 21:15:10 +08:00
|
|
|
|
className='text-sm font-medium truncate'
|
2025-07-17 19:53:33 +08:00
|
|
|
|
/>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
{selected && (
|
2025-08-30 21:15:10 +08:00
|
|
|
|
<div className='flex-shrink-0 text-blue-600'>
|
|
|
|
|
|
<svg
|
|
|
|
|
|
width='16'
|
|
|
|
|
|
height='16'
|
|
|
|
|
|
viewBox='0 0 16 16'
|
|
|
|
|
|
fill='currentColor'
|
|
|
|
|
|
>
|
|
|
|
|
|
<path d='M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z' />
|
2025-07-17 19:53:33 +08:00
|
|
|
|
</svg>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
)}
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
);
|
|
|
|
|
|
};
|
|
|
|
|
|
|
2024-03-23 21:24:39 +08:00
|
|
|
|
return (
|
|
|
|
|
|
<>
|
|
|
|
|
|
<SideSheet
|
|
|
|
|
|
placement={isEdit ? 'right' : 'left'}
|
|
|
|
|
|
title={
|
2025-05-25 12:53:00 +08:00
|
|
|
|
<Space>
|
2025-08-30 21:15:10 +08:00
|
|
|
|
<Tag color='blue' shape='circle'>
|
|
|
|
|
|
{isEdit ? t('编辑') : t('新建')}
|
|
|
|
|
|
</Tag>
|
|
|
|
|
|
<Title heading={4} className='m-0'>
|
2025-05-25 12:53:00 +08:00
|
|
|
|
{isEdit ? t('更新渠道信息') : t('创建新的渠道')}
|
|
|
|
|
|
</Title>
|
|
|
|
|
|
</Space>
|
2023-12-05 18:15:40 +08:00
|
|
|
|
}
|
🎨 style: unify card header UI, switch to Avatar icons & remove oversized props
Summary
• Replaced gradient header blocks with compact, neutral headers wrapped in `Avatar` across the following pages:
- Channel / EditChannel.js
- Channel / EditTagModal.js
- Redemption / EditRedemption.js
- Token / EditToken.js
- User / EditUser.js
- User / AddUser.js
Details
1. Added `Avatar` import and substituted raw icon elements, assigning semantic colors (`blue`, `green`, `purple`, `orange`, etc.) and consistent 16 px icons for a cleaner look.
2. Removed gradient backgrounds, decorative “blur-ball” shapes, and extra paddings from header containers to achieve a tight, flat design.
3. Stripped all `size="large"` attributes from `Button`, `Input`, `Select`, `DatePicker`, `AutoComplete`, and `Avatar` components, allowing default sizing for better visual density.
4. Eliminated redundant `bodyStyle` background overrides in some `SideSheet` components.
5. No business logic touched; all changes are purely presentational.
Result
The editing and creation dialogs now share a unified, compact style consistent with the latest design language, improving readability and user experience without altering functionality.
2025-06-26 16:05:13 +08:00
|
|
|
|
bodyStyle={{ padding: '0' }}
|
2024-03-23 21:24:39 +08:00
|
|
|
|
visible={props.visible}
|
📱 refactor(web): remove legacy isMobile util and migrate to useIsMobile hook
BREAKING CHANGE:
helpers/utils.js no longer exports `isMobile()`.
Any external code that relied on this function must switch to the `useIsMobile` React hook.
Summary
-------
1. Deleted the obsolete `isMobile()` function from helpers/utils.js.
2. Introduced `MOBILE_BREAKPOINT` constant and `matchMedia`-based detection for non-React contexts.
3. Reworked toast positioning logic in utils.js to rely on `matchMedia`.
4. Updated render.js:
• Removed isMobile import.
• Added MOBILE_BREAKPOINT detection in `truncateText`.
5. Migrated every page/component to the `useIsMobile` hook:
• Layout: HeaderBar, PageLayout, SiderBar
• Pages: Home, Detail, Playground, User (Add/Edit), Token, Channel, Redemption, Ratio Sync
• Components: ChannelsTable, ChannelSelectorModal, ConflictConfirmModal
6. Purged all remaining `isMobile()` calls and legacy imports.
7. Added missing `const isMobile = useIsMobile()` declarations where required.
Benefits
--------
• Unifies mobile detection with a React-friendly hook.
• Eliminates duplicated logic and improves maintainability.
• Keeps non-React helpers lightweight by using `matchMedia` directly.
2025-07-16 02:54:58 +08:00
|
|
|
|
width={isMobile ? '100%' : 600}
|
2024-03-23 21:24:39 +08:00
|
|
|
|
footer={
|
2025-09-19 18:09:26 +08:00
|
|
|
|
<div className='flex justify-between items-center bg-white'>
|
|
|
|
|
|
<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>
|
2024-03-23 21:24:39 +08:00
|
|
|
|
<Space>
|
2025-05-25 12:53:00 +08:00
|
|
|
|
<Button
|
2025-08-30 21:15:10 +08:00
|
|
|
|
theme='solid'
|
✨ refactor(EditChannel&EditToken): refactor Channel & Token edit pages with Semi Form and UX enhancements
Overview
• Migrated both `EditChannel.js` and `EditToken.js` to fully leverage Semi UI `Form.*` components, removing legacy `Input/Select/TextArea` + manual labels.
• Unified data-loading strategy: when the drawer becomes visible we load (or reset) data via `props.visible + id` effect and `formApi.setValues()`, guaranteeing fields are always populated; form resets on close.
• Fixed blank-form bug when opening the same record twice.
Key improvements
1. Validation
• `type`, `models` always required.
• `key` required only while creating (not on edit).
2. Batch key creation
• Checkbox moved into `extraText`; hidden when editing or when channel type = 41.
3. Layout & UI
• `Row / Col` (12 + 12) for “Priority” and “Weight”.
• Placeholders revised; model selector now shows creation hint; removed obsolete banner.
• Help / extraText used for long hints, template buttons (`model_mapping`, `status_code_mapping`, `param_override`, etc.), and API address notice.
• Added `showClear`, `min`, rounded card class names for consistency.
4. Reusable helpers
• `batchAllowed`, `batchExtra` utilities.
• `getInitValues()` + centralized `inputs`→form synchronization.
5. Token editor aligned to the same pattern (`props.visiable` watcher).
Result
Cleaner code, consistent UX, instant field population on every open, and clearer validation/error feedback across both editors.
2025-07-04 05:36:10 +08:00
|
|
|
|
onClick={() => formApiRef.current?.submitForm()}
|
2025-05-25 12:53:00 +08:00
|
|
|
|
icon={<IconSave />}
|
|
|
|
|
|
>
|
2024-12-13 19:03:14 +08:00
|
|
|
|
{t('提交')}
|
2024-03-23 21:24:39 +08:00
|
|
|
|
</Button>
|
|
|
|
|
|
<Button
|
2025-08-30 21:15:10 +08:00
|
|
|
|
theme='light'
|
|
|
|
|
|
type='primary'
|
2024-03-23 21:24:39 +08:00
|
|
|
|
onClick={handleCancel}
|
2025-05-25 12:53:00 +08:00
|
|
|
|
icon={<IconClose />}
|
2024-03-23 21:24:39 +08:00
|
|
|
|
>
|
2024-12-13 19:03:14 +08:00
|
|
|
|
{t('取消')}
|
2024-03-23 21:24:39 +08:00
|
|
|
|
</Button>
|
|
|
|
|
|
</Space>
|
|
|
|
|
|
</div>
|
2023-12-05 18:15:40 +08:00
|
|
|
|
}
|
2024-03-23 21:24:39 +08:00
|
|
|
|
closeIcon={null}
|
|
|
|
|
|
onCancel={() => handleCancel()}
|
|
|
|
|
|
>
|
✨ refactor(EditChannel&EditToken): refactor Channel & Token edit pages with Semi Form and UX enhancements
Overview
• Migrated both `EditChannel.js` and `EditToken.js` to fully leverage Semi UI `Form.*` components, removing legacy `Input/Select/TextArea` + manual labels.
• Unified data-loading strategy: when the drawer becomes visible we load (or reset) data via `props.visible + id` effect and `formApi.setValues()`, guaranteeing fields are always populated; form resets on close.
• Fixed blank-form bug when opening the same record twice.
Key improvements
1. Validation
• `type`, `models` always required.
• `key` required only while creating (not on edit).
2. Batch key creation
• Checkbox moved into `extraText`; hidden when editing or when channel type = 41.
3. Layout & UI
• `Row / Col` (12 + 12) for “Priority” and “Weight”.
• Placeholders revised; model selector now shows creation hint; removed obsolete banner.
• Help / extraText used for long hints, template buttons (`model_mapping`, `status_code_mapping`, `param_override`, etc.), and API address notice.
• Added `showClear`, `min`, rounded card class names for consistency.
4. Reusable helpers
• `batchAllowed`, `batchExtra` utilities.
• `getInitValues()` + centralized `inputs`→form synchronization.
5. Token editor aligned to the same pattern (`props.visiable` watcher).
Result
Cleaner code, consistent UX, instant field population on every open, and clearer validation/error feedback across both editors.
2025-07-04 05:36:10 +08:00
|
|
|
|
<Form
|
|
|
|
|
|
key={isEdit ? 'edit' : 'new'}
|
|
|
|
|
|
initValues={originInputs}
|
|
|
|
|
|
getFormApi={(api) => (formApiRef.current = api)}
|
|
|
|
|
|
onSubmit={submit}
|
|
|
|
|
|
>
|
|
|
|
|
|
{() => (
|
|
|
|
|
|
<Spin spinning={loading}>
|
2025-09-19 18:09:26 +08:00
|
|
|
|
<div
|
|
|
|
|
|
className='p-2'
|
|
|
|
|
|
ref={formContainerRef}
|
|
|
|
|
|
>
|
|
|
|
|
|
<div ref={el => formSectionRefs.current.basicInfo = el}>
|
|
|
|
|
|
<Card className='!rounded-2xl shadow-sm border-0 mb-6'>
|
|
|
|
|
|
{/* Header: Basic Info */}
|
|
|
|
|
|
<div className='flex items-center mb-2'>
|
2025-08-30 21:15:10 +08:00
|
|
|
|
<Avatar
|
|
|
|
|
|
size='small'
|
|
|
|
|
|
color='blue'
|
|
|
|
|
|
className='mr-2 shadow-md'
|
|
|
|
|
|
>
|
✨ refactor(EditChannel&EditToken): refactor Channel & Token edit pages with Semi Form and UX enhancements
Overview
• Migrated both `EditChannel.js` and `EditToken.js` to fully leverage Semi UI `Form.*` components, removing legacy `Input/Select/TextArea` + manual labels.
• Unified data-loading strategy: when the drawer becomes visible we load (or reset) data via `props.visible + id` effect and `formApi.setValues()`, guaranteeing fields are always populated; form resets on close.
• Fixed blank-form bug when opening the same record twice.
Key improvements
1. Validation
• `type`, `models` always required.
• `key` required only while creating (not on edit).
2. Batch key creation
• Checkbox moved into `extraText`; hidden when editing or when channel type = 41.
3. Layout & UI
• `Row / Col` (12 + 12) for “Priority” and “Weight”.
• Placeholders revised; model selector now shows creation hint; removed obsolete banner.
• Help / extraText used for long hints, template buttons (`model_mapping`, `status_code_mapping`, `param_override`, etc.), and API address notice.
• Added `showClear`, `min`, rounded card class names for consistency.
4. Reusable helpers
• `batchAllowed`, `batchExtra` utilities.
• `getInitValues()` + centralized `inputs`→form synchronization.
5. Token editor aligned to the same pattern (`props.visiable` watcher).
Result
Cleaner code, consistent UX, instant field population on every open, and clearer validation/error feedback across both editors.
2025-07-04 05:36:10 +08:00
|
|
|
|
<IconServer size={16} />
|
|
|
|
|
|
</Avatar>
|
|
|
|
|
|
<div>
|
2025-08-30 21:15:10 +08:00
|
|
|
|
<Text className='text-lg font-medium'>
|
|
|
|
|
|
{t('基本信息')}
|
|
|
|
|
|
</Text>
|
|
|
|
|
|
<div className='text-xs text-gray-600'>
|
|
|
|
|
|
{t('渠道的基本配置信息')}
|
|
|
|
|
|
</div>
|
✨ refactor(EditChannel&EditToken): refactor Channel & Token edit pages with Semi Form and UX enhancements
Overview
• Migrated both `EditChannel.js` and `EditToken.js` to fully leverage Semi UI `Form.*` components, removing legacy `Input/Select/TextArea` + manual labels.
• Unified data-loading strategy: when the drawer becomes visible we load (or reset) data via `props.visible + id` effect and `formApi.setValues()`, guaranteeing fields are always populated; form resets on close.
• Fixed blank-form bug when opening the same record twice.
Key improvements
1. Validation
• `type`, `models` always required.
• `key` required only while creating (not on edit).
2. Batch key creation
• Checkbox moved into `extraText`; hidden when editing or when channel type = 41.
3. Layout & UI
• `Row / Col` (12 + 12) for “Priority” and “Weight”.
• Placeholders revised; model selector now shows creation hint; removed obsolete banner.
• Help / extraText used for long hints, template buttons (`model_mapping`, `status_code_mapping`, `param_override`, etc.), and API address notice.
• Added `showClear`, `min`, rounded card class names for consistency.
4. Reusable helpers
• `batchAllowed`, `batchExtra` utilities.
• `getInitValues()` + centralized `inputs`→form synchronization.
5. Token editor aligned to the same pattern (`props.visiable` watcher).
Result
Cleaner code, consistent UX, instant field population on every open, and clearer validation/error feedback across both editors.
2025-07-04 05:36:10 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
2025-05-25 12:53:00 +08:00
|
|
|
|
|
✨ refactor(EditChannel&EditToken): refactor Channel & Token edit pages with Semi Form and UX enhancements
Overview
• Migrated both `EditChannel.js` and `EditToken.js` to fully leverage Semi UI `Form.*` components, removing legacy `Input/Select/TextArea` + manual labels.
• Unified data-loading strategy: when the drawer becomes visible we load (or reset) data via `props.visible + id` effect and `formApi.setValues()`, guaranteeing fields are always populated; form resets on close.
• Fixed blank-form bug when opening the same record twice.
Key improvements
1. Validation
• `type`, `models` always required.
• `key` required only while creating (not on edit).
2. Batch key creation
• Checkbox moved into `extraText`; hidden when editing or when channel type = 41.
3. Layout & UI
• `Row / Col` (12 + 12) for “Priority” and “Weight”.
• Placeholders revised; model selector now shows creation hint; removed obsolete banner.
• Help / extraText used for long hints, template buttons (`model_mapping`, `status_code_mapping`, `param_override`, etc.), and API address notice.
• Added `showClear`, `min`, rounded card class names for consistency.
4. Reusable helpers
• `batchAllowed`, `batchExtra` utilities.
• `getInitValues()` + centralized `inputs`→form synchronization.
5. Token editor aligned to the same pattern (`props.visiable` watcher).
Result
Cleaner code, consistent UX, instant field population on every open, and clearer validation/error feedback across both editors.
2025-07-04 05:36:10 +08:00
|
|
|
|
<Form.Select
|
|
|
|
|
|
field='type'
|
|
|
|
|
|
label={t('类型')}
|
|
|
|
|
|
placeholder={t('请选择渠道类型')}
|
|
|
|
|
|
rules={[{ required: true, message: t('请选择渠道类型') }]}
|
2025-07-12 00:02:12 +08:00
|
|
|
|
optionList={channelOptionList}
|
2025-05-25 12:53:00 +08:00
|
|
|
|
style={{ width: '100%' }}
|
2025-07-27 00:01:12 +08:00
|
|
|
|
filter={selectFilter}
|
2025-07-19 13:28:09 +08:00
|
|
|
|
autoClearSearchValue={false}
|
2025-05-25 12:53:00 +08:00
|
|
|
|
searchPosition='dropdown'
|
2025-07-17 19:53:33 +08:00
|
|
|
|
onSearch={(value) => setChannelSearchValue(value)}
|
|
|
|
|
|
renderOptionItem={renderChannelOption}
|
✨ refactor(EditChannel&EditToken): refactor Channel & Token edit pages with Semi Form and UX enhancements
Overview
• Migrated both `EditChannel.js` and `EditToken.js` to fully leverage Semi UI `Form.*` components, removing legacy `Input/Select/TextArea` + manual labels.
• Unified data-loading strategy: when the drawer becomes visible we load (or reset) data via `props.visible + id` effect and `formApi.setValues()`, guaranteeing fields are always populated; form resets on close.
• Fixed blank-form bug when opening the same record twice.
Key improvements
1. Validation
• `type`, `models` always required.
• `key` required only while creating (not on edit).
2. Batch key creation
• Checkbox moved into `extraText`; hidden when editing or when channel type = 41.
3. Layout & UI
• `Row / Col` (12 + 12) for “Priority” and “Weight”.
• Placeholders revised; model selector now shows creation hint; removed obsolete banner.
• Help / extraText used for long hints, template buttons (`model_mapping`, `status_code_mapping`, `param_override`, etc.), and API address notice.
• Added `showClear`, `min`, rounded card class names for consistency.
4. Reusable helpers
• `batchAllowed`, `batchExtra` utilities.
• `getInitValues()` + centralized `inputs`→form synchronization.
5. Token editor aligned to the same pattern (`props.visiable` watcher).
Result
Cleaner code, consistent UX, instant field population on every open, and clearer validation/error feedback across both editors.
2025-07-04 05:36:10 +08:00
|
|
|
|
onChange={(value) => handleInputChange('type', value)}
|
2025-05-25 12:53:00 +08:00
|
|
|
|
/>
|
|
|
|
|
|
|
✨ refactor(EditChannel&EditToken): refactor Channel & Token edit pages with Semi Form and UX enhancements
Overview
• Migrated both `EditChannel.js` and `EditToken.js` to fully leverage Semi UI `Form.*` components, removing legacy `Input/Select/TextArea` + manual labels.
• Unified data-loading strategy: when the drawer becomes visible we load (or reset) data via `props.visible + id` effect and `formApi.setValues()`, guaranteeing fields are always populated; form resets on close.
• Fixed blank-form bug when opening the same record twice.
Key improvements
1. Validation
• `type`, `models` always required.
• `key` required only while creating (not on edit).
2. Batch key creation
• Checkbox moved into `extraText`; hidden when editing or when channel type = 41.
3. Layout & UI
• `Row / Col` (12 + 12) for “Priority” and “Weight”.
• Placeholders revised; model selector now shows creation hint; removed obsolete banner.
• Help / extraText used for long hints, template buttons (`model_mapping`, `status_code_mapping`, `param_override`, etc.), and API address notice.
• Added `showClear`, `min`, rounded card class names for consistency.
4. Reusable helpers
• `batchAllowed`, `batchExtra` utilities.
• `getInitValues()` + centralized `inputs`→form synchronization.
5. Token editor aligned to the same pattern (`props.visiable` watcher).
Result
Cleaner code, consistent UX, instant field population on every open, and clearer validation/error feedback across both editors.
2025-07-04 05:36:10 +08:00
|
|
|
|
<Form.Input
|
|
|
|
|
|
field='name'
|
|
|
|
|
|
label={t('名称')}
|
2025-05-25 12:53:00 +08:00
|
|
|
|
placeholder={t('请为渠道命名')}
|
✨ refactor(EditChannel&EditToken): refactor Channel & Token edit pages with Semi Form and UX enhancements
Overview
• Migrated both `EditChannel.js` and `EditToken.js` to fully leverage Semi UI `Form.*` components, removing legacy `Input/Select/TextArea` + manual labels.
• Unified data-loading strategy: when the drawer becomes visible we load (or reset) data via `props.visible + id` effect and `formApi.setValues()`, guaranteeing fields are always populated; form resets on close.
• Fixed blank-form bug when opening the same record twice.
Key improvements
1. Validation
• `type`, `models` always required.
• `key` required only while creating (not on edit).
2. Batch key creation
• Checkbox moved into `extraText`; hidden when editing or when channel type = 41.
3. Layout & UI
• `Row / Col` (12 + 12) for “Priority” and “Weight”.
• Placeholders revised; model selector now shows creation hint; removed obsolete banner.
• Help / extraText used for long hints, template buttons (`model_mapping`, `status_code_mapping`, `param_override`, etc.), and API address notice.
• Added `showClear`, `min`, rounded card class names for consistency.
4. Reusable helpers
• `batchAllowed`, `batchExtra` utilities.
• `getInitValues()` + centralized `inputs`→form synchronization.
5. Token editor aligned to the same pattern (`props.visiable` watcher).
Result
Cleaner code, consistent UX, instant field population on every open, and clearer validation/error feedback across both editors.
2025-07-04 05:36:10 +08:00
|
|
|
|
rules={[{ required: true, message: t('请为渠道命名') }]}
|
|
|
|
|
|
showClear
|
|
|
|
|
|
onChange={(value) => handleInputChange('name', value)}
|
2025-05-25 12:53:00 +08:00
|
|
|
|
autoComplete='new-password'
|
|
|
|
|
|
/>
|
|
|
|
|
|
|
2025-09-12 19:11:17 +08:00
|
|
|
|
{inputs.type === 41 && (
|
|
|
|
|
|
<Form.Select
|
|
|
|
|
|
field='vertex_key_type'
|
|
|
|
|
|
label={t('密钥格式')}
|
|
|
|
|
|
placeholder={t('请选择密钥格式')}
|
|
|
|
|
|
optionList={[
|
|
|
|
|
|
{ label: 'JSON', value: 'json' },
|
|
|
|
|
|
{ label: 'API Key', value: 'api_key' },
|
|
|
|
|
|
]}
|
|
|
|
|
|
style={{ width: '100%' }}
|
|
|
|
|
|
value={inputs.vertex_key_type || 'json'}
|
|
|
|
|
|
onChange={(value) => {
|
|
|
|
|
|
// 更新设置中的 vertex_key_type
|
|
|
|
|
|
handleChannelOtherSettingsChange('vertex_key_type', value);
|
|
|
|
|
|
// 切换为 api_key 时,关闭批量与手动/文件切换,并清理已选文件
|
|
|
|
|
|
if (value === 'api_key') {
|
|
|
|
|
|
setBatch(false);
|
|
|
|
|
|
setUseManualInput(false);
|
|
|
|
|
|
setVertexKeys([]);
|
|
|
|
|
|
setVertexFileList([]);
|
|
|
|
|
|
if (formApiRef.current) {
|
|
|
|
|
|
formApiRef.current.setValue('vertex_files', []);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}}
|
|
|
|
|
|
extraText={
|
|
|
|
|
|
inputs.vertex_key_type === 'api_key'
|
|
|
|
|
|
? t('API Key 模式下不支持批量创建')
|
|
|
|
|
|
: t('JSON 模式支持手动输入或上传服务账号 JSON')
|
|
|
|
|
|
}
|
|
|
|
|
|
/>
|
|
|
|
|
|
)}
|
2025-05-25 12:53:00 +08:00
|
|
|
|
{batch ? (
|
2025-09-12 19:11:17 +08:00
|
|
|
|
inputs.type === 41 && (inputs.vertex_key_type || 'json') === 'json' ? (
|
2025-07-07 01:12:01 +08:00
|
|
|
|
<Form.Upload
|
|
|
|
|
|
field='vertex_files'
|
|
|
|
|
|
label={t('密钥文件 (.json)')}
|
|
|
|
|
|
accept='.json'
|
|
|
|
|
|
multiple
|
|
|
|
|
|
draggable
|
|
|
|
|
|
dragIcon={<IconBolt />}
|
|
|
|
|
|
dragMainText={t('点击上传文件或拖拽文件到这里')}
|
|
|
|
|
|
dragSubText={t('仅支持 JSON 文件,支持多文件')}
|
|
|
|
|
|
style={{ marginTop: 10 }}
|
|
|
|
|
|
uploadTrigger='custom'
|
|
|
|
|
|
beforeUpload={() => false}
|
|
|
|
|
|
onChange={handleVertexUploadChange}
|
|
|
|
|
|
fileList={vertexFileList}
|
2025-08-30 21:15:10 +08:00
|
|
|
|
rules={
|
|
|
|
|
|
isEdit
|
|
|
|
|
|
? []
|
|
|
|
|
|
: [{ required: true, message: t('请上传密钥文件') }]
|
|
|
|
|
|
}
|
2025-07-07 01:12:01 +08:00
|
|
|
|
extraText={batchExtra}
|
|
|
|
|
|
/>
|
|
|
|
|
|
) : (
|
|
|
|
|
|
<Form.TextArea
|
|
|
|
|
|
field='key'
|
|
|
|
|
|
label={t('密钥')}
|
|
|
|
|
|
placeholder={t('请输入密钥,一行一个')}
|
2025-08-30 21:15:10 +08:00
|
|
|
|
rules={
|
|
|
|
|
|
isEdit
|
|
|
|
|
|
? []
|
|
|
|
|
|
: [{ required: true, message: t('请输入密钥') }]
|
|
|
|
|
|
}
|
2025-07-07 01:12:01 +08:00
|
|
|
|
autosize
|
|
|
|
|
|
autoComplete='new-password'
|
|
|
|
|
|
onChange={(value) => handleInputChange('key', value)}
|
2025-08-02 10:57:03 +08:00
|
|
|
|
extraText={
|
2025-08-30 21:15:10 +08:00
|
|
|
|
<div className='flex items-center gap-2'>
|
|
|
|
|
|
{isEdit &&
|
|
|
|
|
|
isMultiKeyChannel &&
|
|
|
|
|
|
keyMode === 'append' && (
|
|
|
|
|
|
<Text type='warning' size='small'>
|
|
|
|
|
|
{t(
|
|
|
|
|
|
'追加模式:新密钥将添加到现有密钥列表的末尾',
|
|
|
|
|
|
)}
|
|
|
|
|
|
</Text>
|
|
|
|
|
|
)}
|
2025-08-25 14:45:48 +08:00
|
|
|
|
{isEdit && (
|
|
|
|
|
|
<Button
|
2025-08-30 21:15:10 +08:00
|
|
|
|
size='small'
|
|
|
|
|
|
type='primary'
|
|
|
|
|
|
theme='outline'
|
2025-08-25 14:45:48 +08:00
|
|
|
|
onClick={handleShow2FAModal}
|
|
|
|
|
|
>
|
|
|
|
|
|
{t('查看密钥')}
|
|
|
|
|
|
</Button>
|
|
|
|
|
|
)}
|
2025-08-02 10:57:03 +08:00
|
|
|
|
{batchExtra}
|
|
|
|
|
|
</div>
|
|
|
|
|
|
}
|
2025-07-07 01:12:01 +08:00
|
|
|
|
showClear
|
|
|
|
|
|
/>
|
|
|
|
|
|
)
|
2025-05-25 12:53:00 +08:00
|
|
|
|
) : (
|
2025-04-27 17:20:49 +08:00
|
|
|
|
<>
|
2025-09-12 19:11:17 +08:00
|
|
|
|
{inputs.type === 41 && (inputs.vertex_key_type || 'json') === 'json' ? (
|
2025-07-17 19:53:33 +08:00
|
|
|
|
<>
|
|
|
|
|
|
{!batch && (
|
2025-08-30 21:15:10 +08:00
|
|
|
|
<div className='flex items-center justify-between mb-3'>
|
|
|
|
|
|
<Text className='text-sm font-medium'>
|
|
|
|
|
|
{t('密钥输入方式')}
|
|
|
|
|
|
</Text>
|
2025-07-17 19:53:33 +08:00
|
|
|
|
<Space>
|
|
|
|
|
|
<Button
|
2025-08-30 21:15:10 +08:00
|
|
|
|
size='small'
|
|
|
|
|
|
type={
|
|
|
|
|
|
!useManualInput ? 'primary' : 'tertiary'
|
|
|
|
|
|
}
|
2025-07-17 19:53:33 +08:00
|
|
|
|
onClick={() => {
|
|
|
|
|
|
setUseManualInput(false);
|
|
|
|
|
|
// 切换到文件上传模式时清空手动输入的密钥
|
|
|
|
|
|
if (formApiRef.current) {
|
|
|
|
|
|
formApiRef.current.setValue('key', '');
|
|
|
|
|
|
}
|
|
|
|
|
|
handleInputChange('key', '');
|
|
|
|
|
|
}}
|
|
|
|
|
|
>
|
|
|
|
|
|
{t('文件上传')}
|
|
|
|
|
|
</Button>
|
|
|
|
|
|
<Button
|
2025-08-30 21:15:10 +08:00
|
|
|
|
size='small'
|
2025-07-17 19:53:33 +08:00
|
|
|
|
type={useManualInput ? 'primary' : 'tertiary'}
|
|
|
|
|
|
onClick={() => {
|
|
|
|
|
|
setUseManualInput(true);
|
|
|
|
|
|
// 切换到手动输入模式时清空文件上传相关状态
|
|
|
|
|
|
setVertexKeys([]);
|
|
|
|
|
|
setVertexFileList([]);
|
|
|
|
|
|
if (formApiRef.current) {
|
2025-08-30 21:15:10 +08:00
|
|
|
|
formApiRef.current.setValue(
|
|
|
|
|
|
'vertex_files',
|
|
|
|
|
|
[],
|
|
|
|
|
|
);
|
2025-07-17 19:53:33 +08:00
|
|
|
|
}
|
2025-08-30 21:15:10 +08:00
|
|
|
|
setInputs((prev) => ({
|
|
|
|
|
|
...prev,
|
|
|
|
|
|
vertex_files: [],
|
|
|
|
|
|
}));
|
2025-07-17 19:53:33 +08:00
|
|
|
|
}}
|
|
|
|
|
|
>
|
|
|
|
|
|
{t('手动输入')}
|
|
|
|
|
|
</Button>
|
|
|
|
|
|
</Space>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
)}
|
2025-07-19 00:58:18 +08:00
|
|
|
|
|
2025-07-17 19:53:33 +08:00
|
|
|
|
{batch && (
|
|
|
|
|
|
<Banner
|
|
|
|
|
|
type='info'
|
2025-08-30 21:15:10 +08:00
|
|
|
|
description={t(
|
|
|
|
|
|
'批量创建模式下仅支持文件上传,不支持手动输入',
|
|
|
|
|
|
)}
|
2025-07-17 19:53:33 +08:00
|
|
|
|
className='!rounded-lg mb-3'
|
|
|
|
|
|
/>
|
|
|
|
|
|
)}
|
2025-07-19 00:58:18 +08:00
|
|
|
|
|
2025-07-17 19:53:33 +08:00
|
|
|
|
{useManualInput && !batch ? (
|
|
|
|
|
|
<Form.TextArea
|
|
|
|
|
|
field='key'
|
2025-08-30 21:15:10 +08:00
|
|
|
|
label={
|
|
|
|
|
|
isEdit
|
|
|
|
|
|
? t('密钥(编辑模式下,保存的密钥不会显示)')
|
|
|
|
|
|
: t('密钥')
|
|
|
|
|
|
}
|
|
|
|
|
|
placeholder={t(
|
|
|
|
|
|
'请输入 JSON 格式的密钥内容,例如:\n{\n "type": "service_account",\n "project_id": "your-project-id",\n "private_key_id": "...",\n "private_key": "...",\n "client_email": "...",\n "client_id": "...",\n "auth_uri": "...",\n "token_uri": "...",\n "auth_provider_x509_cert_url": "...",\n "client_x509_cert_url": "..."\n}',
|
|
|
|
|
|
)}
|
|
|
|
|
|
rules={
|
|
|
|
|
|
isEdit
|
|
|
|
|
|
? []
|
|
|
|
|
|
: [
|
|
|
|
|
|
{
|
|
|
|
|
|
required: true,
|
|
|
|
|
|
message: t('请输入密钥'),
|
|
|
|
|
|
},
|
|
|
|
|
|
]
|
|
|
|
|
|
}
|
2025-07-17 19:53:33 +08:00
|
|
|
|
autoComplete='new-password'
|
2025-08-30 21:15:10 +08:00
|
|
|
|
onChange={(value) =>
|
|
|
|
|
|
handleInputChange('key', value)
|
|
|
|
|
|
}
|
2025-07-17 19:53:33 +08:00
|
|
|
|
extraText={
|
2025-08-30 21:15:10 +08:00
|
|
|
|
<div className='flex items-center gap-2'>
|
|
|
|
|
|
<Text type='tertiary' size='small'>
|
2025-07-17 19:53:33 +08:00
|
|
|
|
{t('请输入完整的 JSON 格式密钥内容')}
|
|
|
|
|
|
</Text>
|
2025-08-30 21:15:10 +08:00
|
|
|
|
{isEdit &&
|
|
|
|
|
|
isMultiKeyChannel &&
|
|
|
|
|
|
keyMode === 'append' && (
|
|
|
|
|
|
<Text type='warning' size='small'>
|
|
|
|
|
|
{t(
|
|
|
|
|
|
'追加模式:新密钥将添加到现有密钥列表的末尾',
|
|
|
|
|
|
)}
|
|
|
|
|
|
</Text>
|
|
|
|
|
|
)}
|
2025-08-25 14:45:48 +08:00
|
|
|
|
{isEdit && (
|
|
|
|
|
|
<Button
|
2025-08-30 21:15:10 +08:00
|
|
|
|
size='small'
|
|
|
|
|
|
type='primary'
|
|
|
|
|
|
theme='outline'
|
2025-08-25 14:45:48 +08:00
|
|
|
|
onClick={handleShow2FAModal}
|
|
|
|
|
|
>
|
|
|
|
|
|
{t('查看密钥')}
|
|
|
|
|
|
</Button>
|
|
|
|
|
|
)}
|
2025-07-17 19:53:33 +08:00
|
|
|
|
{batchExtra}
|
|
|
|
|
|
</div>
|
|
|
|
|
|
}
|
|
|
|
|
|
autosize
|
|
|
|
|
|
showClear
|
|
|
|
|
|
/>
|
|
|
|
|
|
) : (
|
|
|
|
|
|
<Form.Upload
|
|
|
|
|
|
field='vertex_files'
|
|
|
|
|
|
label={t('密钥文件 (.json)')}
|
|
|
|
|
|
accept='.json'
|
|
|
|
|
|
draggable
|
|
|
|
|
|
dragIcon={<IconBolt />}
|
|
|
|
|
|
dragMainText={t('点击上传文件或拖拽文件到这里')}
|
|
|
|
|
|
dragSubText={t('仅支持 JSON 文件')}
|
|
|
|
|
|
style={{ marginTop: 10 }}
|
|
|
|
|
|
uploadTrigger='custom'
|
|
|
|
|
|
beforeUpload={() => false}
|
|
|
|
|
|
onChange={handleVertexUploadChange}
|
|
|
|
|
|
fileList={vertexFileList}
|
2025-08-30 21:15:10 +08:00
|
|
|
|
rules={
|
|
|
|
|
|
isEdit
|
|
|
|
|
|
? []
|
|
|
|
|
|
: [
|
|
|
|
|
|
{
|
|
|
|
|
|
required: true,
|
|
|
|
|
|
message: t('请上传密钥文件'),
|
|
|
|
|
|
},
|
|
|
|
|
|
]
|
|
|
|
|
|
}
|
2025-07-17 19:53:33 +08:00
|
|
|
|
extraText={batchExtra}
|
|
|
|
|
|
/>
|
|
|
|
|
|
)}
|
|
|
|
|
|
</>
|
2025-05-25 12:53:00 +08:00
|
|
|
|
) : (
|
✨ refactor(EditChannel&EditToken): refactor Channel & Token edit pages with Semi Form and UX enhancements
Overview
• Migrated both `EditChannel.js` and `EditToken.js` to fully leverage Semi UI `Form.*` components, removing legacy `Input/Select/TextArea` + manual labels.
• Unified data-loading strategy: when the drawer becomes visible we load (or reset) data via `props.visible + id` effect and `formApi.setValues()`, guaranteeing fields are always populated; form resets on close.
• Fixed blank-form bug when opening the same record twice.
Key improvements
1. Validation
• `type`, `models` always required.
• `key` required only while creating (not on edit).
2. Batch key creation
• Checkbox moved into `extraText`; hidden when editing or when channel type = 41.
3. Layout & UI
• `Row / Col` (12 + 12) for “Priority” and “Weight”.
• Placeholders revised; model selector now shows creation hint; removed obsolete banner.
• Help / extraText used for long hints, template buttons (`model_mapping`, `status_code_mapping`, `param_override`, etc.), and API address notice.
• Added `showClear`, `min`, rounded card class names for consistency.
4. Reusable helpers
• `batchAllowed`, `batchExtra` utilities.
• `getInitValues()` + centralized `inputs`→form synchronization.
5. Token editor aligned to the same pattern (`props.visiable` watcher).
Result
Cleaner code, consistent UX, instant field population on every open, and clearer validation/error feedback across both editors.
2025-07-04 05:36:10 +08:00
|
|
|
|
<Form.Input
|
|
|
|
|
|
field='key'
|
2025-08-30 21:15:10 +08:00
|
|
|
|
label={
|
|
|
|
|
|
isEdit
|
|
|
|
|
|
? t('密钥(编辑模式下,保存的密钥不会显示)')
|
|
|
|
|
|
: t('密钥')
|
|
|
|
|
|
}
|
2025-05-25 12:53:00 +08:00
|
|
|
|
placeholder={t(type2secretPrompt(inputs.type))}
|
2025-08-30 21:15:10 +08:00
|
|
|
|
rules={
|
|
|
|
|
|
isEdit
|
|
|
|
|
|
? []
|
|
|
|
|
|
: [{ required: true, message: t('请输入密钥') }]
|
|
|
|
|
|
}
|
2025-05-25 12:53:00 +08:00
|
|
|
|
autoComplete='new-password'
|
✨ refactor(EditChannel&EditToken): refactor Channel & Token edit pages with Semi Form and UX enhancements
Overview
• Migrated both `EditChannel.js` and `EditToken.js` to fully leverage Semi UI `Form.*` components, removing legacy `Input/Select/TextArea` + manual labels.
• Unified data-loading strategy: when the drawer becomes visible we load (or reset) data via `props.visible + id` effect and `formApi.setValues()`, guaranteeing fields are always populated; form resets on close.
• Fixed blank-form bug when opening the same record twice.
Key improvements
1. Validation
• `type`, `models` always required.
• `key` required only while creating (not on edit).
2. Batch key creation
• Checkbox moved into `extraText`; hidden when editing or when channel type = 41.
3. Layout & UI
• `Row / Col` (12 + 12) for “Priority” and “Weight”.
• Placeholders revised; model selector now shows creation hint; removed obsolete banner.
• Help / extraText used for long hints, template buttons (`model_mapping`, `status_code_mapping`, `param_override`, etc.), and API address notice.
• Added `showClear`, `min`, rounded card class names for consistency.
4. Reusable helpers
• `batchAllowed`, `batchExtra` utilities.
• `getInitValues()` + centralized `inputs`→form synchronization.
5. Token editor aligned to the same pattern (`props.visiable` watcher).
Result
Cleaner code, consistent UX, instant field population on every open, and clearer validation/error feedback across both editors.
2025-07-04 05:36:10 +08:00
|
|
|
|
onChange={(value) => handleInputChange('key', value)}
|
2025-08-02 10:57:03 +08:00
|
|
|
|
extraText={
|
2025-08-30 21:15:10 +08:00
|
|
|
|
<div className='flex items-center gap-2'>
|
|
|
|
|
|
{isEdit &&
|
|
|
|
|
|
isMultiKeyChannel &&
|
|
|
|
|
|
keyMode === 'append' && (
|
|
|
|
|
|
<Text type='warning' size='small'>
|
|
|
|
|
|
{t(
|
|
|
|
|
|
'追加模式:新密钥将添加到现有密钥列表的末尾',
|
|
|
|
|
|
)}
|
|
|
|
|
|
</Text>
|
|
|
|
|
|
)}
|
2025-08-25 14:45:48 +08:00
|
|
|
|
{isEdit && (
|
|
|
|
|
|
<Button
|
2025-08-30 21:15:10 +08:00
|
|
|
|
size='small'
|
|
|
|
|
|
type='primary'
|
|
|
|
|
|
theme='outline'
|
2025-08-25 14:45:48 +08:00
|
|
|
|
onClick={handleShow2FAModal}
|
|
|
|
|
|
>
|
|
|
|
|
|
{t('查看密钥')}
|
|
|
|
|
|
</Button>
|
|
|
|
|
|
)}
|
2025-08-02 10:57:03 +08:00
|
|
|
|
{batchExtra}
|
|
|
|
|
|
</div>
|
|
|
|
|
|
}
|
2025-07-07 01:12:01 +08:00
|
|
|
|
showClear
|
2025-05-25 12:53:00 +08:00
|
|
|
|
/>
|
2025-05-09 18:11:37 +08:00
|
|
|
|
)}
|
2025-04-27 17:20:49 +08:00
|
|
|
|
</>
|
2025-04-04 12:00:38 +08:00
|
|
|
|
)}
|
2025-07-07 01:12:01 +08:00
|
|
|
|
|
2025-08-06 03:29:45 +08:00
|
|
|
|
{isEdit && isMultiKeyChannel && (
|
|
|
|
|
|
<Form.Select
|
|
|
|
|
|
field='key_mode'
|
|
|
|
|
|
label={t('密钥更新模式')}
|
|
|
|
|
|
placeholder={t('请选择密钥更新模式')}
|
|
|
|
|
|
optionList={[
|
|
|
|
|
|
{ label: t('追加到现有密钥'), value: 'append' },
|
|
|
|
|
|
{ label: t('覆盖现有密钥'), value: 'replace' },
|
|
|
|
|
|
]}
|
|
|
|
|
|
style={{ width: '100%' }}
|
|
|
|
|
|
value={keyMode}
|
|
|
|
|
|
onChange={(value) => setKeyMode(value)}
|
|
|
|
|
|
extraText={
|
2025-08-30 21:15:10 +08:00
|
|
|
|
<Text type='tertiary' size='small'>
|
2025-08-06 03:29:45 +08:00
|
|
|
|
{keyMode === 'replace'
|
|
|
|
|
|
? t('覆盖模式:将完全替换现有的所有密钥')
|
2025-08-30 21:15:10 +08:00
|
|
|
|
: t('追加模式:将新密钥添加到现有密钥列表末尾')}
|
2025-08-06 03:29:45 +08:00
|
|
|
|
</Text>
|
|
|
|
|
|
}
|
|
|
|
|
|
/>
|
2025-08-02 10:57:03 +08:00
|
|
|
|
)}
|
2025-07-07 01:12:01 +08:00
|
|
|
|
{batch && multiToSingle && (
|
2025-07-11 21:12:17 +08:00
|
|
|
|
<>
|
|
|
|
|
|
<Form.Select
|
|
|
|
|
|
field='multi_key_mode'
|
|
|
|
|
|
label={t('密钥聚合模式')}
|
|
|
|
|
|
placeholder={t('请选择多密钥使用策略')}
|
|
|
|
|
|
optionList={[
|
|
|
|
|
|
{ label: t('随机'), value: 'random' },
|
|
|
|
|
|
{ label: t('轮询'), value: 'polling' },
|
|
|
|
|
|
]}
|
|
|
|
|
|
style={{ width: '100%' }}
|
|
|
|
|
|
value={inputs.multi_key_mode || 'random'}
|
|
|
|
|
|
onChange={(value) => {
|
|
|
|
|
|
setMultiKeyMode(value);
|
|
|
|
|
|
handleInputChange('multi_key_mode', value);
|
|
|
|
|
|
}}
|
|
|
|
|
|
/>
|
|
|
|
|
|
{inputs.multi_key_mode === 'polling' && (
|
|
|
|
|
|
<Banner
|
|
|
|
|
|
type='warning'
|
2025-08-30 21:15:10 +08:00
|
|
|
|
description={t(
|
|
|
|
|
|
'轮询模式必须搭配Redis和内存缓存功能使用,否则性能将大幅降低,并且无法实现轮询功能',
|
|
|
|
|
|
)}
|
2025-07-11 21:12:17 +08:00
|
|
|
|
className='!rounded-lg mt-2'
|
2025-05-25 12:53:00 +08:00
|
|
|
|
/>
|
2025-05-09 18:11:37 +08:00
|
|
|
|
)}
|
2025-04-27 17:20:49 +08:00
|
|
|
|
</>
|
2025-04-04 12:00:38 +08:00
|
|
|
|
)}
|
2025-07-11 23:47:13 +08:00
|
|
|
|
|
|
|
|
|
|
{inputs.type === 18 && (
|
|
|
|
|
|
<Form.Input
|
|
|
|
|
|
field='other'
|
|
|
|
|
|
label={t('模型版本')}
|
2025-08-30 21:15:10 +08:00
|
|
|
|
placeholder={
|
|
|
|
|
|
'请输入星火大模型版本,注意是接口地址中的版本号,例如:v2.1'
|
|
|
|
|
|
}
|
2025-07-11 23:47:13 +08:00
|
|
|
|
onChange={(value) => handleInputChange('other', value)}
|
|
|
|
|
|
showClear
|
|
|
|
|
|
/>
|
|
|
|
|
|
)}
|
|
|
|
|
|
|
|
|
|
|
|
{inputs.type === 41 && (
|
2025-07-31 12:54:07 +08:00
|
|
|
|
<JSONEditor
|
2025-08-10 12:22:18 +08:00
|
|
|
|
key={`region-${isEdit ? channelId : 'new'}`}
|
2025-07-11 23:47:13 +08:00
|
|
|
|
field='other'
|
|
|
|
|
|
label={t('部署地区')}
|
|
|
|
|
|
placeholder={t(
|
2025-08-30 21:15:10 +08:00
|
|
|
|
'请输入部署地区,例如:us-central1\n支持使用模型映射格式\n{\n "default": "us-central1",\n "claude-3-5-sonnet-20240620": "europe-west1"\n}',
|
2025-07-11 23:47:13 +08:00
|
|
|
|
)}
|
2025-07-31 12:54:07 +08:00
|
|
|
|
value={inputs.other || ''}
|
2025-07-11 23:47:13 +08:00
|
|
|
|
onChange={(value) => handleInputChange('other', value)}
|
2025-07-07 01:12:01 +08:00
|
|
|
|
rules={[{ required: true, message: t('请填写部署地区') }]}
|
2025-07-31 12:54:07 +08:00
|
|
|
|
template={REGION_EXAMPLE}
|
|
|
|
|
|
templateLabel={t('填入模板')}
|
2025-08-30 21:15:10 +08:00
|
|
|
|
editorType='region'
|
2025-07-31 12:54:07 +08:00
|
|
|
|
formApi={formApiRef.current}
|
2025-08-08 04:09:53 +08:00
|
|
|
|
extraText={t('设置默认地区和特定模型的专用地区')}
|
2025-07-11 23:47:13 +08:00
|
|
|
|
/>
|
|
|
|
|
|
)}
|
|
|
|
|
|
|
|
|
|
|
|
{inputs.type === 21 && (
|
|
|
|
|
|
<Form.Input
|
|
|
|
|
|
field='other'
|
|
|
|
|
|
label={t('知识库 ID')}
|
|
|
|
|
|
placeholder={'请输入知识库 ID,例如:123456'}
|
|
|
|
|
|
onChange={(value) => handleInputChange('other', value)}
|
|
|
|
|
|
showClear
|
|
|
|
|
|
/>
|
|
|
|
|
|
)}
|
|
|
|
|
|
|
|
|
|
|
|
{inputs.type === 39 && (
|
|
|
|
|
|
<Form.Input
|
|
|
|
|
|
field='other'
|
|
|
|
|
|
label='Account ID'
|
2025-08-30 21:15:10 +08:00
|
|
|
|
placeholder={
|
|
|
|
|
|
'请输入Account ID,例如:d6b5da8hk1awo8nap34ube6gh'
|
|
|
|
|
|
}
|
2025-07-11 23:47:13 +08:00
|
|
|
|
onChange={(value) => handleInputChange('other', value)}
|
|
|
|
|
|
showClear
|
|
|
|
|
|
/>
|
|
|
|
|
|
)}
|
|
|
|
|
|
|
|
|
|
|
|
{inputs.type === 49 && (
|
|
|
|
|
|
<Form.Input
|
|
|
|
|
|
field='other'
|
|
|
|
|
|
label={t('智能体ID')}
|
|
|
|
|
|
placeholder={'请输入智能体ID,例如:7342866812345'}
|
|
|
|
|
|
onChange={(value) => handleInputChange('other', value)}
|
|
|
|
|
|
showClear
|
|
|
|
|
|
/>
|
|
|
|
|
|
)}
|
|
|
|
|
|
|
|
|
|
|
|
{inputs.type === 1 && (
|
|
|
|
|
|
<Form.Input
|
|
|
|
|
|
field='openai_organization'
|
|
|
|
|
|
label={t('组织')}
|
|
|
|
|
|
placeholder={t('请输入组织org-xxx')}
|
|
|
|
|
|
showClear
|
|
|
|
|
|
helpText={t('组织,不填则为默认组织')}
|
2025-08-30 21:15:10 +08:00
|
|
|
|
onChange={(value) =>
|
|
|
|
|
|
handleInputChange('openai_organization', value)
|
|
|
|
|
|
}
|
2025-07-11 23:47:13 +08:00
|
|
|
|
/>
|
|
|
|
|
|
)}
|
2025-09-19 18:09:26 +08:00
|
|
|
|
</Card>
|
|
|
|
|
|
</div>
|
2025-05-25 12:53:00 +08:00
|
|
|
|
|
✨ refactor(EditChannel&EditToken): refactor Channel & Token edit pages with Semi Form and UX enhancements
Overview
• Migrated both `EditChannel.js` and `EditToken.js` to fully leverage Semi UI `Form.*` components, removing legacy `Input/Select/TextArea` + manual labels.
• Unified data-loading strategy: when the drawer becomes visible we load (or reset) data via `props.visible + id` effect and `formApi.setValues()`, guaranteeing fields are always populated; form resets on close.
• Fixed blank-form bug when opening the same record twice.
Key improvements
1. Validation
• `type`, `models` always required.
• `key` required only while creating (not on edit).
2. Batch key creation
• Checkbox moved into `extraText`; hidden when editing or when channel type = 41.
3. Layout & UI
• `Row / Col` (12 + 12) for “Priority” and “Weight”.
• Placeholders revised; model selector now shows creation hint; removed obsolete banner.
• Help / extraText used for long hints, template buttons (`model_mapping`, `status_code_mapping`, `param_override`, etc.), and API address notice.
• Added `showClear`, `min`, rounded card class names for consistency.
4. Reusable helpers
• `batchAllowed`, `batchExtra` utilities.
• `getInitValues()` + centralized `inputs`→form synchronization.
5. Token editor aligned to the same pattern (`props.visiable` watcher).
Result
Cleaner code, consistent UX, instant field population on every open, and clearer validation/error feedback across both editors.
2025-07-04 05:36:10 +08:00
|
|
|
|
{/* API Configuration Card */}
|
🐛 fix(EditChannelModal): hide empty “API Config” card for VolcEngine Ark/Doubao (type 45)
The VolcEngine Ark/Doubao channel now has a hard-coded base URL inside the backend, so it no longer requires any API-address settings on the front-end side.
Previously, the input field was hidden but the surrounding “API Config” card still rendered, leaving a blank, confusing section.
Changes made
• Added `showApiConfigCard` flag (true when `inputs.type !== 45`) right after the state declarations.
• Wrapped the entire “API Config” card in a conditional render driven by this flag.
• Removed the duplicate declaration of `showApiConfigCard` further down in the component to avoid shadowing and improve readability.
Scope verification
• Checked all other channel types: every remaining type either displays a dedicated API-related input/banner (3, 8, 22, 36, 37, 40, …) or falls back to the generic “custom API address” field.
• Therefore, only type 45 requires the card to be fully hidden.
Result
The “Edit Channel” modal now shows no empty card for the VolcEngine Ark/Doubao channel, leading to a cleaner and more intuitive UI while preserving behaviour for all other channels.
2025-07-22 21:31:37 +08:00
|
|
|
|
{showApiConfigCard && (
|
2025-09-19 18:09:26 +08:00
|
|
|
|
<div ref={el => formSectionRefs.current.apiConfig = el}>
|
|
|
|
|
|
<Card className='!rounded-2xl shadow-sm border-0 mb-6'>
|
|
|
|
|
|
{/* Header: API Config */}
|
|
|
|
|
|
<div className='flex items-center mb-2'>
|
2025-08-30 21:15:10 +08:00
|
|
|
|
<Avatar
|
|
|
|
|
|
size='small'
|
|
|
|
|
|
color='green'
|
|
|
|
|
|
className='mr-2 shadow-md'
|
|
|
|
|
|
>
|
🐛 fix(EditChannelModal): hide empty “API Config” card for VolcEngine Ark/Doubao (type 45)
The VolcEngine Ark/Doubao channel now has a hard-coded base URL inside the backend, so it no longer requires any API-address settings on the front-end side.
Previously, the input field was hidden but the surrounding “API Config” card still rendered, leaving a blank, confusing section.
Changes made
• Added `showApiConfigCard` flag (true when `inputs.type !== 45`) right after the state declarations.
• Wrapped the entire “API Config” card in a conditional render driven by this flag.
• Removed the duplicate declaration of `showApiConfigCard` further down in the component to avoid shadowing and improve readability.
Scope verification
• Checked all other channel types: every remaining type either displays a dedicated API-related input/banner (3, 8, 22, 36, 37, 40, …) or falls back to the generic “custom API address” field.
• Therefore, only type 45 requires the card to be fully hidden.
Result
The “Edit Channel” modal now shows no empty card for the VolcEngine Ark/Doubao channel, leading to a cleaner and more intuitive UI while preserving behaviour for all other channels.
2025-07-22 21:31:37 +08:00
|
|
|
|
<IconGlobe size={16} />
|
|
|
|
|
|
</Avatar>
|
|
|
|
|
|
<div>
|
2025-08-30 21:15:10 +08:00
|
|
|
|
<Text className='text-lg font-medium'>
|
|
|
|
|
|
{t('API 配置')}
|
|
|
|
|
|
</Text>
|
|
|
|
|
|
<div className='text-xs text-gray-600'>
|
|
|
|
|
|
{t('API 地址和相关配置')}
|
|
|
|
|
|
</div>
|
🐛 fix(EditChannelModal): hide empty “API Config” card for VolcEngine Ark/Doubao (type 45)
The VolcEngine Ark/Doubao channel now has a hard-coded base URL inside the backend, so it no longer requires any API-address settings on the front-end side.
Previously, the input field was hidden but the surrounding “API Config” card still rendered, leaving a blank, confusing section.
Changes made
• Added `showApiConfigCard` flag (true when `inputs.type !== 45`) right after the state declarations.
• Wrapped the entire “API Config” card in a conditional render driven by this flag.
• Removed the duplicate declaration of `showApiConfigCard` further down in the component to avoid shadowing and improve readability.
Scope verification
• Checked all other channel types: every remaining type either displays a dedicated API-related input/banner (3, 8, 22, 36, 37, 40, …) or falls back to the generic “custom API address” field.
• Therefore, only type 45 requires the card to be fully hidden.
Result
The “Edit Channel” modal now shows no empty card for the VolcEngine Ark/Doubao channel, leading to a cleaner and more intuitive UI while preserving behaviour for all other channels.
2025-07-22 21:31:37 +08:00
|
|
|
|
</div>
|
✨ refactor(EditChannel&EditToken): refactor Channel & Token edit pages with Semi Form and UX enhancements
Overview
• Migrated both `EditChannel.js` and `EditToken.js` to fully leverage Semi UI `Form.*` components, removing legacy `Input/Select/TextArea` + manual labels.
• Unified data-loading strategy: when the drawer becomes visible we load (or reset) data via `props.visible + id` effect and `formApi.setValues()`, guaranteeing fields are always populated; form resets on close.
• Fixed blank-form bug when opening the same record twice.
Key improvements
1. Validation
• `type`, `models` always required.
• `key` required only while creating (not on edit).
2. Batch key creation
• Checkbox moved into `extraText`; hidden when editing or when channel type = 41.
3. Layout & UI
• `Row / Col` (12 + 12) for “Priority” and “Weight”.
• Placeholders revised; model selector now shows creation hint; removed obsolete banner.
• Help / extraText used for long hints, template buttons (`model_mapping`, `status_code_mapping`, `param_override`, etc.), and API address notice.
• Added `showClear`, `min`, rounded card class names for consistency.
4. Reusable helpers
• `batchAllowed`, `batchExtra` utilities.
• `getInitValues()` + centralized `inputs`→form synchronization.
5. Token editor aligned to the same pattern (`props.visiable` watcher).
Result
Cleaner code, consistent UX, instant field population on every open, and clearer validation/error feedback across both editors.
2025-07-04 05:36:10 +08:00
|
|
|
|
</div>
|
2025-05-25 12:53:00 +08:00
|
|
|
|
|
🐛 fix(EditChannelModal): hide empty “API Config” card for VolcEngine Ark/Doubao (type 45)
The VolcEngine Ark/Doubao channel now has a hard-coded base URL inside the backend, so it no longer requires any API-address settings on the front-end side.
Previously, the input field was hidden but the surrounding “API Config” card still rendered, leaving a blank, confusing section.
Changes made
• Added `showApiConfigCard` flag (true when `inputs.type !== 45`) right after the state declarations.
• Wrapped the entire “API Config” card in a conditional render driven by this flag.
• Removed the duplicate declaration of `showApiConfigCard` further down in the component to avoid shadowing and improve readability.
Scope verification
• Checked all other channel types: every remaining type either displays a dedicated API-related input/banner (3, 8, 22, 36, 37, 40, …) or falls back to the generic “custom API address” field.
• Therefore, only type 45 requires the card to be fully hidden.
Result
The “Edit Channel” modal now shows no empty card for the VolcEngine Ark/Doubao channel, leading to a cleaner and more intuitive UI while preserving behaviour for all other channels.
2025-07-22 21:31:37 +08:00
|
|
|
|
{inputs.type === 40 && (
|
|
|
|
|
|
<Banner
|
|
|
|
|
|
type='info'
|
|
|
|
|
|
description={
|
|
|
|
|
|
<div>
|
|
|
|
|
|
<Text strong>{t('邀请链接')}:</Text>
|
|
|
|
|
|
<Text
|
|
|
|
|
|
link
|
|
|
|
|
|
underline
|
2025-08-30 21:15:10 +08:00
|
|
|
|
className='ml-2 cursor-pointer'
|
|
|
|
|
|
onClick={() =>
|
|
|
|
|
|
window.open(
|
|
|
|
|
|
'https://cloud.siliconflow.cn/i/hij0YNTZ',
|
|
|
|
|
|
)
|
|
|
|
|
|
}
|
🐛 fix(EditChannelModal): hide empty “API Config” card for VolcEngine Ark/Doubao (type 45)
The VolcEngine Ark/Doubao channel now has a hard-coded base URL inside the backend, so it no longer requires any API-address settings on the front-end side.
Previously, the input field was hidden but the surrounding “API Config” card still rendered, leaving a blank, confusing section.
Changes made
• Added `showApiConfigCard` flag (true when `inputs.type !== 45`) right after the state declarations.
• Wrapped the entire “API Config” card in a conditional render driven by this flag.
• Removed the duplicate declaration of `showApiConfigCard` further down in the component to avoid shadowing and improve readability.
Scope verification
• Checked all other channel types: every remaining type either displays a dedicated API-related input/banner (3, 8, 22, 36, 37, 40, …) or falls back to the generic “custom API address” field.
• Therefore, only type 45 requires the card to be fully hidden.
Result
The “Edit Channel” modal now shows no empty card for the VolcEngine Ark/Doubao channel, leading to a cleaner and more intuitive UI while preserving behaviour for all other channels.
2025-07-22 21:31:37 +08:00
|
|
|
|
>
|
|
|
|
|
|
https://cloud.siliconflow.cn/i/hij0YNTZ
|
|
|
|
|
|
</Text>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
}
|
|
|
|
|
|
className='!rounded-lg'
|
|
|
|
|
|
/>
|
|
|
|
|
|
)}
|
|
|
|
|
|
|
|
|
|
|
|
{inputs.type === 3 && (
|
|
|
|
|
|
<>
|
|
|
|
|
|
<Banner
|
|
|
|
|
|
type='warning'
|
2025-08-30 21:15:10 +08:00
|
|
|
|
description={t(
|
|
|
|
|
|
'2025年5月10日后添加的渠道,不需要再在部署的时候移除模型名称中的"."',
|
|
|
|
|
|
)}
|
🐛 fix(EditChannelModal): hide empty “API Config” card for VolcEngine Ark/Doubao (type 45)
The VolcEngine Ark/Doubao channel now has a hard-coded base URL inside the backend, so it no longer requires any API-address settings on the front-end side.
Previously, the input field was hidden but the surrounding “API Config” card still rendered, leaving a blank, confusing section.
Changes made
• Added `showApiConfigCard` flag (true when `inputs.type !== 45`) right after the state declarations.
• Wrapped the entire “API Config” card in a conditional render driven by this flag.
• Removed the duplicate declaration of `showApiConfigCard` further down in the component to avoid shadowing and improve readability.
Scope verification
• Checked all other channel types: every remaining type either displays a dedicated API-related input/banner (3, 8, 22, 36, 37, 40, …) or falls back to the generic “custom API address” field.
• Therefore, only type 45 requires the card to be fully hidden.
Result
The “Edit Channel” modal now shows no empty card for the VolcEngine Ark/Doubao channel, leading to a cleaner and more intuitive UI while preserving behaviour for all other channels.
2025-07-22 21:31:37 +08:00
|
|
|
|
className='!rounded-lg'
|
|
|
|
|
|
/>
|
✨ refactor(EditChannel&EditToken): refactor Channel & Token edit pages with Semi Form and UX enhancements
Overview
• Migrated both `EditChannel.js` and `EditToken.js` to fully leverage Semi UI `Form.*` components, removing legacy `Input/Select/TextArea` + manual labels.
• Unified data-loading strategy: when the drawer becomes visible we load (or reset) data via `props.visible + id` effect and `formApi.setValues()`, guaranteeing fields are always populated; form resets on close.
• Fixed blank-form bug when opening the same record twice.
Key improvements
1. Validation
• `type`, `models` always required.
• `key` required only while creating (not on edit).
2. Batch key creation
• Checkbox moved into `extraText`; hidden when editing or when channel type = 41.
3. Layout & UI
• `Row / Col` (12 + 12) for “Priority” and “Weight”.
• Placeholders revised; model selector now shows creation hint; removed obsolete banner.
• Help / extraText used for long hints, template buttons (`model_mapping`, `status_code_mapping`, `param_override`, etc.), and API address notice.
• Added `showClear`, `min`, rounded card class names for consistency.
4. Reusable helpers
• `batchAllowed`, `batchExtra` utilities.
• `getInitValues()` + centralized `inputs`→form synchronization.
5. Token editor aligned to the same pattern (`props.visiable` watcher).
Result
Cleaner code, consistent UX, instant field population on every open, and clearer validation/error feedback across both editors.
2025-07-04 05:36:10 +08:00
|
|
|
|
<div>
|
🐛 fix(EditChannelModal): hide empty “API Config” card for VolcEngine Ark/Doubao (type 45)
The VolcEngine Ark/Doubao channel now has a hard-coded base URL inside the backend, so it no longer requires any API-address settings on the front-end side.
Previously, the input field was hidden but the surrounding “API Config” card still rendered, leaving a blank, confusing section.
Changes made
• Added `showApiConfigCard` flag (true when `inputs.type !== 45`) right after the state declarations.
• Wrapped the entire “API Config” card in a conditional render driven by this flag.
• Removed the duplicate declaration of `showApiConfigCard` further down in the component to avoid shadowing and improve readability.
Scope verification
• Checked all other channel types: every remaining type either displays a dedicated API-related input/banner (3, 8, 22, 36, 37, 40, …) or falls back to the generic “custom API address” field.
• Therefore, only type 45 requires the card to be fully hidden.
Result
The “Edit Channel” modal now shows no empty card for the VolcEngine Ark/Doubao channel, leading to a cleaner and more intuitive UI while preserving behaviour for all other channels.
2025-07-22 21:31:37 +08:00
|
|
|
|
<Form.Input
|
|
|
|
|
|
field='base_url'
|
|
|
|
|
|
label='AZURE_OPENAI_ENDPOINT'
|
2025-08-30 21:15:10 +08:00
|
|
|
|
placeholder={t(
|
|
|
|
|
|
'请输入 AZURE_OPENAI_ENDPOINT,例如:https://docs-test-001.openai.azure.com',
|
|
|
|
|
|
)}
|
|
|
|
|
|
onChange={(value) =>
|
|
|
|
|
|
handleInputChange('base_url', value)
|
|
|
|
|
|
}
|
🐛 fix(EditChannelModal): hide empty “API Config” card for VolcEngine Ark/Doubao (type 45)
The VolcEngine Ark/Doubao channel now has a hard-coded base URL inside the backend, so it no longer requires any API-address settings on the front-end side.
Previously, the input field was hidden but the surrounding “API Config” card still rendered, leaving a blank, confusing section.
Changes made
• Added `showApiConfigCard` flag (true when `inputs.type !== 45`) right after the state declarations.
• Wrapped the entire “API Config” card in a conditional render driven by this flag.
• Removed the duplicate declaration of `showApiConfigCard` further down in the component to avoid shadowing and improve readability.
Scope verification
• Checked all other channel types: every remaining type either displays a dedicated API-related input/banner (3, 8, 22, 36, 37, 40, …) or falls back to the generic “custom API address” field.
• Therefore, only type 45 requires the card to be fully hidden.
Result
The “Edit Channel” modal now shows no empty card for the VolcEngine Ark/Doubao channel, leading to a cleaner and more intuitive UI while preserving behaviour for all other channels.
2025-07-22 21:31:37 +08:00
|
|
|
|
showClear
|
|
|
|
|
|
/>
|
✨ refactor(EditChannel&EditToken): refactor Channel & Token edit pages with Semi Form and UX enhancements
Overview
• Migrated both `EditChannel.js` and `EditToken.js` to fully leverage Semi UI `Form.*` components, removing legacy `Input/Select/TextArea` + manual labels.
• Unified data-loading strategy: when the drawer becomes visible we load (or reset) data via `props.visible + id` effect and `formApi.setValues()`, guaranteeing fields are always populated; form resets on close.
• Fixed blank-form bug when opening the same record twice.
Key improvements
1. Validation
• `type`, `models` always required.
• `key` required only while creating (not on edit).
2. Batch key creation
• Checkbox moved into `extraText`; hidden when editing or when channel type = 41.
3. Layout & UI
• `Row / Col` (12 + 12) for “Priority” and “Weight”.
• Placeholders revised; model selector now shows creation hint; removed obsolete banner.
• Help / extraText used for long hints, template buttons (`model_mapping`, `status_code_mapping`, `param_override`, etc.), and API address notice.
• Added `showClear`, `min`, rounded card class names for consistency.
4. Reusable helpers
• `batchAllowed`, `batchExtra` utilities.
• `getInitValues()` + centralized `inputs`→form synchronization.
5. Token editor aligned to the same pattern (`props.visiable` watcher).
Result
Cleaner code, consistent UX, instant field population on every open, and clearer validation/error feedback across both editors.
2025-07-04 05:36:10 +08:00
|
|
|
|
</div>
|
🐛 fix(EditChannelModal): hide empty “API Config” card for VolcEngine Ark/Doubao (type 45)
The VolcEngine Ark/Doubao channel now has a hard-coded base URL inside the backend, so it no longer requires any API-address settings on the front-end side.
Previously, the input field was hidden but the surrounding “API Config” card still rendered, leaving a blank, confusing section.
Changes made
• Added `showApiConfigCard` flag (true when `inputs.type !== 45`) right after the state declarations.
• Wrapped the entire “API Config” card in a conditional render driven by this flag.
• Removed the duplicate declaration of `showApiConfigCard` further down in the component to avoid shadowing and improve readability.
Scope verification
• Checked all other channel types: every remaining type either displays a dedicated API-related input/banner (3, 8, 22, 36, 37, 40, …) or falls back to the generic “custom API address” field.
• Therefore, only type 45 requires the card to be fully hidden.
Result
The “Edit Channel” modal now shows no empty card for the VolcEngine Ark/Doubao channel, leading to a cleaner and more intuitive UI while preserving behaviour for all other channels.
2025-07-22 21:31:37 +08:00
|
|
|
|
<div>
|
|
|
|
|
|
<Form.Input
|
|
|
|
|
|
field='other'
|
|
|
|
|
|
label={t('默认 API 版本')}
|
2025-08-30 21:15:10 +08:00
|
|
|
|
placeholder={t(
|
|
|
|
|
|
'请输入默认 API 版本,例如:2025-04-01-preview',
|
|
|
|
|
|
)}
|
|
|
|
|
|
onChange={(value) =>
|
|
|
|
|
|
handleInputChange('other', value)
|
|
|
|
|
|
}
|
🐛 fix(EditChannelModal): hide empty “API Config” card for VolcEngine Ark/Doubao (type 45)
The VolcEngine Ark/Doubao channel now has a hard-coded base URL inside the backend, so it no longer requires any API-address settings on the front-end side.
Previously, the input field was hidden but the surrounding “API Config” card still rendered, leaving a blank, confusing section.
Changes made
• Added `showApiConfigCard` flag (true when `inputs.type !== 45`) right after the state declarations.
• Wrapped the entire “API Config” card in a conditional render driven by this flag.
• Removed the duplicate declaration of `showApiConfigCard` further down in the component to avoid shadowing and improve readability.
Scope verification
• Checked all other channel types: every remaining type either displays a dedicated API-related input/banner (3, 8, 22, 36, 37, 40, …) or falls back to the generic “custom API address” field.
• Therefore, only type 45 requires the card to be fully hidden.
Result
The “Edit Channel” modal now shows no empty card for the VolcEngine Ark/Doubao channel, leading to a cleaner and more intuitive UI while preserving behaviour for all other channels.
2025-07-22 21:31:37 +08:00
|
|
|
|
showClear
|
|
|
|
|
|
/>
|
|
|
|
|
|
</div>
|
2025-08-10 20:21:30 +08:00
|
|
|
|
<div>
|
|
|
|
|
|
<Form.Input
|
|
|
|
|
|
field='azure_responses_version'
|
2025-08-30 21:15:10 +08:00
|
|
|
|
label={t(
|
|
|
|
|
|
'默认 Responses API 版本,为空则使用上方版本',
|
|
|
|
|
|
)}
|
2025-08-10 20:21:30 +08:00
|
|
|
|
placeholder={t('例如:preview')}
|
2025-08-30 21:15:10 +08:00
|
|
|
|
onChange={(value) =>
|
|
|
|
|
|
handleChannelOtherSettingsChange(
|
|
|
|
|
|
'azure_responses_version',
|
|
|
|
|
|
value,
|
|
|
|
|
|
)
|
|
|
|
|
|
}
|
2025-08-10 20:21:30 +08:00
|
|
|
|
showClear
|
|
|
|
|
|
/>
|
|
|
|
|
|
</div>
|
🐛 fix(EditChannelModal): hide empty “API Config” card for VolcEngine Ark/Doubao (type 45)
The VolcEngine Ark/Doubao channel now has a hard-coded base URL inside the backend, so it no longer requires any API-address settings on the front-end side.
Previously, the input field was hidden but the surrounding “API Config” card still rendered, leaving a blank, confusing section.
Changes made
• Added `showApiConfigCard` flag (true when `inputs.type !== 45`) right after the state declarations.
• Wrapped the entire “API Config” card in a conditional render driven by this flag.
• Removed the duplicate declaration of `showApiConfigCard` further down in the component to avoid shadowing and improve readability.
Scope verification
• Checked all other channel types: every remaining type either displays a dedicated API-related input/banner (3, 8, 22, 36, 37, 40, …) or falls back to the generic “custom API address” field.
• Therefore, only type 45 requires the card to be fully hidden.
Result
The “Edit Channel” modal now shows no empty card for the VolcEngine Ark/Doubao channel, leading to a cleaner and more intuitive UI while preserving behaviour for all other channels.
2025-07-22 21:31:37 +08:00
|
|
|
|
</>
|
|
|
|
|
|
)}
|
2025-05-25 12:53:00 +08:00
|
|
|
|
|
🐛 fix(EditChannelModal): hide empty “API Config” card for VolcEngine Ark/Doubao (type 45)
The VolcEngine Ark/Doubao channel now has a hard-coded base URL inside the backend, so it no longer requires any API-address settings on the front-end side.
Previously, the input field was hidden but the surrounding “API Config” card still rendered, leaving a blank, confusing section.
Changes made
• Added `showApiConfigCard` flag (true when `inputs.type !== 45`) right after the state declarations.
• Wrapped the entire “API Config” card in a conditional render driven by this flag.
• Removed the duplicate declaration of `showApiConfigCard` further down in the component to avoid shadowing and improve readability.
Scope verification
• Checked all other channel types: every remaining type either displays a dedicated API-related input/banner (3, 8, 22, 36, 37, 40, …) or falls back to the generic “custom API address” field.
• Therefore, only type 45 requires the card to be fully hidden.
Result
The “Edit Channel” modal now shows no empty card for the VolcEngine Ark/Doubao channel, leading to a cleaner and more intuitive UI while preserving behaviour for all other channels.
2025-07-22 21:31:37 +08:00
|
|
|
|
{inputs.type === 8 && (
|
|
|
|
|
|
<>
|
|
|
|
|
|
<Banner
|
|
|
|
|
|
type='warning'
|
2025-08-30 21:15:10 +08:00
|
|
|
|
description={t(
|
|
|
|
|
|
'如果你对接的是上游One API或者New API等转发项目,请使用OpenAI类型,不要使用此类型,除非你知道你在做什么。',
|
|
|
|
|
|
)}
|
🐛 fix(EditChannelModal): hide empty “API Config” card for VolcEngine Ark/Doubao (type 45)
The VolcEngine Ark/Doubao channel now has a hard-coded base URL inside the backend, so it no longer requires any API-address settings on the front-end side.
Previously, the input field was hidden but the surrounding “API Config” card still rendered, leaving a blank, confusing section.
Changes made
• Added `showApiConfigCard` flag (true when `inputs.type !== 45`) right after the state declarations.
• Wrapped the entire “API Config” card in a conditional render driven by this flag.
• Removed the duplicate declaration of `showApiConfigCard` further down in the component to avoid shadowing and improve readability.
Scope verification
• Checked all other channel types: every remaining type either displays a dedicated API-related input/banner (3, 8, 22, 36, 37, 40, …) or falls back to the generic “custom API address” field.
• Therefore, only type 45 requires the card to be fully hidden.
Result
The “Edit Channel” modal now shows no empty card for the VolcEngine Ark/Doubao channel, leading to a cleaner and more intuitive UI while preserving behaviour for all other channels.
2025-07-22 21:31:37 +08:00
|
|
|
|
className='!rounded-lg'
|
|
|
|
|
|
/>
|
|
|
|
|
|
<div>
|
|
|
|
|
|
<Form.Input
|
|
|
|
|
|
field='base_url'
|
|
|
|
|
|
label={t('完整的 Base URL,支持变量{model}')}
|
2025-08-30 21:15:10 +08:00
|
|
|
|
placeholder={t(
|
|
|
|
|
|
'请输入完整的URL,例如:https://api.openai.com/v1/chat/completions',
|
|
|
|
|
|
)}
|
|
|
|
|
|
onChange={(value) =>
|
|
|
|
|
|
handleInputChange('base_url', value)
|
|
|
|
|
|
}
|
🐛 fix(EditChannelModal): hide empty “API Config” card for VolcEngine Ark/Doubao (type 45)
The VolcEngine Ark/Doubao channel now has a hard-coded base URL inside the backend, so it no longer requires any API-address settings on the front-end side.
Previously, the input field was hidden but the surrounding “API Config” card still rendered, leaving a blank, confusing section.
Changes made
• Added `showApiConfigCard` flag (true when `inputs.type !== 45`) right after the state declarations.
• Wrapped the entire “API Config” card in a conditional render driven by this flag.
• Removed the duplicate declaration of `showApiConfigCard` further down in the component to avoid shadowing and improve readability.
Scope verification
• Checked all other channel types: every remaining type either displays a dedicated API-related input/banner (3, 8, 22, 36, 37, 40, …) or falls back to the generic “custom API address” field.
• Therefore, only type 45 requires the card to be fully hidden.
Result
The “Edit Channel” modal now shows no empty card for the VolcEngine Ark/Doubao channel, leading to a cleaner and more intuitive UI while preserving behaviour for all other channels.
2025-07-22 21:31:37 +08:00
|
|
|
|
showClear
|
|
|
|
|
|
/>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</>
|
|
|
|
|
|
)}
|
|
|
|
|
|
|
|
|
|
|
|
{inputs.type === 37 && (
|
✨ refactor(EditChannel&EditToken): refactor Channel & Token edit pages with Semi Form and UX enhancements
Overview
• Migrated both `EditChannel.js` and `EditToken.js` to fully leverage Semi UI `Form.*` components, removing legacy `Input/Select/TextArea` + manual labels.
• Unified data-loading strategy: when the drawer becomes visible we load (or reset) data via `props.visible + id` effect and `formApi.setValues()`, guaranteeing fields are always populated; form resets on close.
• Fixed blank-form bug when opening the same record twice.
Key improvements
1. Validation
• `type`, `models` always required.
• `key` required only while creating (not on edit).
2. Batch key creation
• Checkbox moved into `extraText`; hidden when editing or when channel type = 41.
3. Layout & UI
• `Row / Col` (12 + 12) for “Priority” and “Weight”.
• Placeholders revised; model selector now shows creation hint; removed obsolete banner.
• Help / extraText used for long hints, template buttons (`model_mapping`, `status_code_mapping`, `param_override`, etc.), and API address notice.
• Added `showClear`, `min`, rounded card class names for consistency.
4. Reusable helpers
• `batchAllowed`, `batchExtra` utilities.
• `getInitValues()` + centralized `inputs`→form synchronization.
5. Token editor aligned to the same pattern (`props.visiable` watcher).
Result
Cleaner code, consistent UX, instant field population on every open, and clearer validation/error feedback across both editors.
2025-07-04 05:36:10 +08:00
|
|
|
|
<Banner
|
|
|
|
|
|
type='warning'
|
2025-08-30 21:15:10 +08:00
|
|
|
|
description={t(
|
|
|
|
|
|
'Dify渠道只适配chatflow和agent,并且agent不支持图片!',
|
|
|
|
|
|
)}
|
✨ refactor(EditChannel&EditToken): refactor Channel & Token edit pages with Semi Form and UX enhancements
Overview
• Migrated both `EditChannel.js` and `EditToken.js` to fully leverage Semi UI `Form.*` components, removing legacy `Input/Select/TextArea` + manual labels.
• Unified data-loading strategy: when the drawer becomes visible we load (or reset) data via `props.visible + id` effect and `formApi.setValues()`, guaranteeing fields are always populated; form resets on close.
• Fixed blank-form bug when opening the same record twice.
Key improvements
1. Validation
• `type`, `models` always required.
• `key` required only while creating (not on edit).
2. Batch key creation
• Checkbox moved into `extraText`; hidden when editing or when channel type = 41.
3. Layout & UI
• `Row / Col` (12 + 12) for “Priority” and “Weight”.
• Placeholders revised; model selector now shows creation hint; removed obsolete banner.
• Help / extraText used for long hints, template buttons (`model_mapping`, `status_code_mapping`, `param_override`, etc.), and API address notice.
• Added `showClear`, `min`, rounded card class names for consistency.
4. Reusable helpers
• `batchAllowed`, `batchExtra` utilities.
• `getInitValues()` + centralized `inputs`→form synchronization.
5. Token editor aligned to the same pattern (`props.visiable` watcher).
Result
Cleaner code, consistent UX, instant field population on every open, and clearer validation/error feedback across both editors.
2025-07-04 05:36:10 +08:00
|
|
|
|
className='!rounded-lg'
|
|
|
|
|
|
/>
|
🐛 fix(EditChannelModal): hide empty “API Config” card for VolcEngine Ark/Doubao (type 45)
The VolcEngine Ark/Doubao channel now has a hard-coded base URL inside the backend, so it no longer requires any API-address settings on the front-end side.
Previously, the input field was hidden but the surrounding “API Config” card still rendered, leaving a blank, confusing section.
Changes made
• Added `showApiConfigCard` flag (true when `inputs.type !== 45`) right after the state declarations.
• Wrapped the entire “API Config” card in a conditional render driven by this flag.
• Removed the duplicate declaration of `showApiConfigCard` further down in the component to avoid shadowing and improve readability.
Scope verification
• Checked all other channel types: every remaining type either displays a dedicated API-related input/banner (3, 8, 22, 36, 37, 40, …) or falls back to the generic “custom API address” field.
• Therefore, only type 45 requires the card to be fully hidden.
Result
The “Edit Channel” modal now shows no empty card for the VolcEngine Ark/Doubao channel, leading to a cleaner and more intuitive UI while preserving behaviour for all other channels.
2025-07-22 21:31:37 +08:00
|
|
|
|
)}
|
|
|
|
|
|
|
2025-08-30 21:15:10 +08:00
|
|
|
|
{inputs.type !== 3 &&
|
|
|
|
|
|
inputs.type !== 8 &&
|
|
|
|
|
|
inputs.type !== 22 &&
|
|
|
|
|
|
inputs.type !== 36 &&
|
|
|
|
|
|
inputs.type !== 45 && (
|
|
|
|
|
|
<div>
|
|
|
|
|
|
<Form.Input
|
|
|
|
|
|
field='base_url'
|
|
|
|
|
|
label={t('API地址')}
|
|
|
|
|
|
placeholder={t(
|
|
|
|
|
|
'此项可选,用于通过自定义API地址来进行 API 调用,末尾不要带/v1和/',
|
|
|
|
|
|
)}
|
|
|
|
|
|
onChange={(value) =>
|
|
|
|
|
|
handleInputChange('base_url', value)
|
|
|
|
|
|
}
|
|
|
|
|
|
showClear
|
|
|
|
|
|
extraText={t(
|
|
|
|
|
|
'对于官方渠道,new-api已经内置地址,除非是第三方代理站点或者Azure的特殊接入地址,否则不需要填写',
|
|
|
|
|
|
)}
|
|
|
|
|
|
/>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
)}
|
🐛 fix(EditChannelModal): hide empty “API Config” card for VolcEngine Ark/Doubao (type 45)
The VolcEngine Ark/Doubao channel now has a hard-coded base URL inside the backend, so it no longer requires any API-address settings on the front-end side.
Previously, the input field was hidden but the surrounding “API Config” card still rendered, leaving a blank, confusing section.
Changes made
• Added `showApiConfigCard` flag (true when `inputs.type !== 45`) right after the state declarations.
• Wrapped the entire “API Config” card in a conditional render driven by this flag.
• Removed the duplicate declaration of `showApiConfigCard` further down in the component to avoid shadowing and improve readability.
Scope verification
• Checked all other channel types: every remaining type either displays a dedicated API-related input/banner (3, 8, 22, 36, 37, 40, …) or falls back to the generic “custom API address” field.
• Therefore, only type 45 requires the card to be fully hidden.
Result
The “Edit Channel” modal now shows no empty card for the VolcEngine Ark/Doubao channel, leading to a cleaner and more intuitive UI while preserving behaviour for all other channels.
2025-07-22 21:31:37 +08:00
|
|
|
|
|
|
|
|
|
|
{inputs.type === 22 && (
|
✨ refactor(EditChannel&EditToken): refactor Channel & Token edit pages with Semi Form and UX enhancements
Overview
• Migrated both `EditChannel.js` and `EditToken.js` to fully leverage Semi UI `Form.*` components, removing legacy `Input/Select/TextArea` + manual labels.
• Unified data-loading strategy: when the drawer becomes visible we load (or reset) data via `props.visible + id` effect and `formApi.setValues()`, guaranteeing fields are always populated; form resets on close.
• Fixed blank-form bug when opening the same record twice.
Key improvements
1. Validation
• `type`, `models` always required.
• `key` required only while creating (not on edit).
2. Batch key creation
• Checkbox moved into `extraText`; hidden when editing or when channel type = 41.
3. Layout & UI
• `Row / Col` (12 + 12) for “Priority” and “Weight”.
• Placeholders revised; model selector now shows creation hint; removed obsolete banner.
• Help / extraText used for long hints, template buttons (`model_mapping`, `status_code_mapping`, `param_override`, etc.), and API address notice.
• Added `showClear`, `min`, rounded card class names for consistency.
4. Reusable helpers
• `batchAllowed`, `batchExtra` utilities.
• `getInitValues()` + centralized `inputs`→form synchronization.
5. Token editor aligned to the same pattern (`props.visiable` watcher).
Result
Cleaner code, consistent UX, instant field population on every open, and clearer validation/error feedback across both editors.
2025-07-04 05:36:10 +08:00
|
|
|
|
<div>
|
|
|
|
|
|
<Form.Input
|
🐛 fix(EditChannelModal): hide empty “API Config” card for VolcEngine Ark/Doubao (type 45)
The VolcEngine Ark/Doubao channel now has a hard-coded base URL inside the backend, so it no longer requires any API-address settings on the front-end side.
Previously, the input field was hidden but the surrounding “API Config” card still rendered, leaving a blank, confusing section.
Changes made
• Added `showApiConfigCard` flag (true when `inputs.type !== 45`) right after the state declarations.
• Wrapped the entire “API Config” card in a conditional render driven by this flag.
• Removed the duplicate declaration of `showApiConfigCard` further down in the component to avoid shadowing and improve readability.
Scope verification
• Checked all other channel types: every remaining type either displays a dedicated API-related input/banner (3, 8, 22, 36, 37, 40, …) or falls back to the generic “custom API address” field.
• Therefore, only type 45 requires the card to be fully hidden.
Result
The “Edit Channel” modal now shows no empty card for the VolcEngine Ark/Doubao channel, leading to a cleaner and more intuitive UI while preserving behaviour for all other channels.
2025-07-22 21:31:37 +08:00
|
|
|
|
field='base_url'
|
|
|
|
|
|
label={t('私有部署地址')}
|
2025-08-30 21:15:10 +08:00
|
|
|
|
placeholder={t(
|
|
|
|
|
|
'请输入私有部署地址,格式为:https://fastgpt.run/api/openapi',
|
|
|
|
|
|
)}
|
|
|
|
|
|
onChange={(value) =>
|
|
|
|
|
|
handleInputChange('base_url', value)
|
|
|
|
|
|
}
|
✨ refactor(EditChannel&EditToken): refactor Channel & Token edit pages with Semi Form and UX enhancements
Overview
• Migrated both `EditChannel.js` and `EditToken.js` to fully leverage Semi UI `Form.*` components, removing legacy `Input/Select/TextArea` + manual labels.
• Unified data-loading strategy: when the drawer becomes visible we load (or reset) data via `props.visible + id` effect and `formApi.setValues()`, guaranteeing fields are always populated; form resets on close.
• Fixed blank-form bug when opening the same record twice.
Key improvements
1. Validation
• `type`, `models` always required.
• `key` required only while creating (not on edit).
2. Batch key creation
• Checkbox moved into `extraText`; hidden when editing or when channel type = 41.
3. Layout & UI
• `Row / Col` (12 + 12) for “Priority” and “Weight”.
• Placeholders revised; model selector now shows creation hint; removed obsolete banner.
• Help / extraText used for long hints, template buttons (`model_mapping`, `status_code_mapping`, `param_override`, etc.), and API address notice.
• Added `showClear`, `min`, rounded card class names for consistency.
4. Reusable helpers
• `batchAllowed`, `batchExtra` utilities.
• `getInitValues()` + centralized `inputs`→form synchronization.
5. Token editor aligned to the same pattern (`props.visiable` watcher).
Result
Cleaner code, consistent UX, instant field population on every open, and clearer validation/error feedback across both editors.
2025-07-04 05:36:10 +08:00
|
|
|
|
showClear
|
|
|
|
|
|
/>
|
|
|
|
|
|
</div>
|
🐛 fix(EditChannelModal): hide empty “API Config” card for VolcEngine Ark/Doubao (type 45)
The VolcEngine Ark/Doubao channel now has a hard-coded base URL inside the backend, so it no longer requires any API-address settings on the front-end side.
Previously, the input field was hidden but the surrounding “API Config” card still rendered, leaving a blank, confusing section.
Changes made
• Added `showApiConfigCard` flag (true when `inputs.type !== 45`) right after the state declarations.
• Wrapped the entire “API Config” card in a conditional render driven by this flag.
• Removed the duplicate declaration of `showApiConfigCard` further down in the component to avoid shadowing and improve readability.
Scope verification
• Checked all other channel types: every remaining type either displays a dedicated API-related input/banner (3, 8, 22, 36, 37, 40, …) or falls back to the generic “custom API address” field.
• Therefore, only type 45 requires the card to be fully hidden.
Result
The “Edit Channel” modal now shows no empty card for the VolcEngine Ark/Doubao channel, leading to a cleaner and more intuitive UI while preserving behaviour for all other channels.
2025-07-22 21:31:37 +08:00
|
|
|
|
)}
|
2025-05-25 12:53:00 +08:00
|
|
|
|
|
🐛 fix(EditChannelModal): hide empty “API Config” card for VolcEngine Ark/Doubao (type 45)
The VolcEngine Ark/Doubao channel now has a hard-coded base URL inside the backend, so it no longer requires any API-address settings on the front-end side.
Previously, the input field was hidden but the surrounding “API Config” card still rendered, leaving a blank, confusing section.
Changes made
• Added `showApiConfigCard` flag (true when `inputs.type !== 45`) right after the state declarations.
• Wrapped the entire “API Config” card in a conditional render driven by this flag.
• Removed the duplicate declaration of `showApiConfigCard` further down in the component to avoid shadowing and improve readability.
Scope verification
• Checked all other channel types: every remaining type either displays a dedicated API-related input/banner (3, 8, 22, 36, 37, 40, …) or falls back to the generic “custom API address” field.
• Therefore, only type 45 requires the card to be fully hidden.
Result
The “Edit Channel” modal now shows no empty card for the VolcEngine Ark/Doubao channel, leading to a cleaner and more intuitive UI while preserving behaviour for all other channels.
2025-07-22 21:31:37 +08:00
|
|
|
|
{inputs.type === 36 && (
|
✨ refactor(EditChannel&EditToken): refactor Channel & Token edit pages with Semi Form and UX enhancements
Overview
• Migrated both `EditChannel.js` and `EditToken.js` to fully leverage Semi UI `Form.*` components, removing legacy `Input/Select/TextArea` + manual labels.
• Unified data-loading strategy: when the drawer becomes visible we load (or reset) data via `props.visible + id` effect and `formApi.setValues()`, guaranteeing fields are always populated; form resets on close.
• Fixed blank-form bug when opening the same record twice.
Key improvements
1. Validation
• `type`, `models` always required.
• `key` required only while creating (not on edit).
2. Batch key creation
• Checkbox moved into `extraText`; hidden when editing or when channel type = 41.
3. Layout & UI
• `Row / Col` (12 + 12) for “Priority” and “Weight”.
• Placeholders revised; model selector now shows creation hint; removed obsolete banner.
• Help / extraText used for long hints, template buttons (`model_mapping`, `status_code_mapping`, `param_override`, etc.), and API address notice.
• Added `showClear`, `min`, rounded card class names for consistency.
4. Reusable helpers
• `batchAllowed`, `batchExtra` utilities.
• `getInitValues()` + centralized `inputs`→form synchronization.
5. Token editor aligned to the same pattern (`props.visiable` watcher).
Result
Cleaner code, consistent UX, instant field population on every open, and clearer validation/error feedback across both editors.
2025-07-04 05:36:10 +08:00
|
|
|
|
<div>
|
|
|
|
|
|
<Form.Input
|
|
|
|
|
|
field='base_url'
|
2025-08-30 21:15:10 +08:00
|
|
|
|
label={t(
|
|
|
|
|
|
'注意非Chat API,请务必填写正确的API地址,否则可能导致无法使用',
|
|
|
|
|
|
)}
|
|
|
|
|
|
placeholder={t(
|
|
|
|
|
|
'请输入到 /suno 前的路径,通常就是域名,例如:https://api.example.com',
|
|
|
|
|
|
)}
|
|
|
|
|
|
onChange={(value) =>
|
|
|
|
|
|
handleInputChange('base_url', value)
|
|
|
|
|
|
}
|
✨ refactor(EditChannel&EditToken): refactor Channel & Token edit pages with Semi Form and UX enhancements
Overview
• Migrated both `EditChannel.js` and `EditToken.js` to fully leverage Semi UI `Form.*` components, removing legacy `Input/Select/TextArea` + manual labels.
• Unified data-loading strategy: when the drawer becomes visible we load (or reset) data via `props.visible + id` effect and `formApi.setValues()`, guaranteeing fields are always populated; form resets on close.
• Fixed blank-form bug when opening the same record twice.
Key improvements
1. Validation
• `type`, `models` always required.
• `key` required only while creating (not on edit).
2. Batch key creation
• Checkbox moved into `extraText`; hidden when editing or when channel type = 41.
3. Layout & UI
• `Row / Col` (12 + 12) for “Priority” and “Weight”.
• Placeholders revised; model selector now shows creation hint; removed obsolete banner.
• Help / extraText used for long hints, template buttons (`model_mapping`, `status_code_mapping`, `param_override`, etc.), and API address notice.
• Added `showClear`, `min`, rounded card class names for consistency.
4. Reusable helpers
• `batchAllowed`, `batchExtra` utilities.
• `getInitValues()` + centralized `inputs`→form synchronization.
5. Token editor aligned to the same pattern (`props.visiable` watcher).
Result
Cleaner code, consistent UX, instant field population on every open, and clearer validation/error feedback across both editors.
2025-07-04 05:36:10 +08:00
|
|
|
|
showClear
|
|
|
|
|
|
/>
|
|
|
|
|
|
</div>
|
🐛 fix(EditChannelModal): hide empty “API Config” card for VolcEngine Ark/Doubao (type 45)
The VolcEngine Ark/Doubao channel now has a hard-coded base URL inside the backend, so it no longer requires any API-address settings on the front-end side.
Previously, the input field was hidden but the surrounding “API Config” card still rendered, leaving a blank, confusing section.
Changes made
• Added `showApiConfigCard` flag (true when `inputs.type !== 45`) right after the state declarations.
• Wrapped the entire “API Config” card in a conditional render driven by this flag.
• Removed the duplicate declaration of `showApiConfigCard` further down in the component to avoid shadowing and improve readability.
Scope verification
• Checked all other channel types: every remaining type either displays a dedicated API-related input/banner (3, 8, 22, 36, 37, 40, …) or falls back to the generic “custom API address” field.
• Therefore, only type 45 requires the card to be fully hidden.
Result
The “Edit Channel” modal now shows no empty card for the VolcEngine Ark/Doubao channel, leading to a cleaner and more intuitive UI while preserving behaviour for all other channels.
2025-07-22 21:31:37 +08:00
|
|
|
|
)}
|
2025-09-27 16:40:18 +08:00
|
|
|
|
|
|
|
|
|
|
{inputs.type === 45 && (
|
|
|
|
|
|
<div>
|
|
|
|
|
|
<Form.Select
|
|
|
|
|
|
field='base_url'
|
|
|
|
|
|
label={t('API地址')}
|
|
|
|
|
|
placeholder={t('请选择API地址')}
|
|
|
|
|
|
onChange={(value) =>
|
|
|
|
|
|
handleInputChange('base_url', value)
|
|
|
|
|
|
}
|
|
|
|
|
|
optionList={[
|
|
|
|
|
|
{
|
|
|
|
|
|
value: 'https://ark.cn-beijing.volces.com',
|
|
|
|
|
|
label: 'https://ark.cn-beijing.volces.com'
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
value: 'https://ark.ap-southeast.bytepluses.com',
|
|
|
|
|
|
label: 'https://ark.ap-southeast.bytepluses.com'
|
|
|
|
|
|
}
|
|
|
|
|
|
]}
|
|
|
|
|
|
defaultValue='https://ark.cn-beijing.volces.com'
|
|
|
|
|
|
/>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
)}
|
2025-09-19 18:09:26 +08:00
|
|
|
|
</Card>
|
|
|
|
|
|
</div>
|
🐛 fix(EditChannelModal): hide empty “API Config” card for VolcEngine Ark/Doubao (type 45)
The VolcEngine Ark/Doubao channel now has a hard-coded base URL inside the backend, so it no longer requires any API-address settings on the front-end side.
Previously, the input field was hidden but the surrounding “API Config” card still rendered, leaving a blank, confusing section.
Changes made
• Added `showApiConfigCard` flag (true when `inputs.type !== 45`) right after the state declarations.
• Wrapped the entire “API Config” card in a conditional render driven by this flag.
• Removed the duplicate declaration of `showApiConfigCard` further down in the component to avoid shadowing and improve readability.
Scope verification
• Checked all other channel types: every remaining type either displays a dedicated API-related input/banner (3, 8, 22, 36, 37, 40, …) or falls back to the generic “custom API address” field.
• Therefore, only type 45 requires the card to be fully hidden.
Result
The “Edit Channel” modal now shows no empty card for the VolcEngine Ark/Doubao channel, leading to a cleaner and more intuitive UI while preserving behaviour for all other channels.
2025-07-22 21:31:37 +08:00
|
|
|
|
)}
|
2025-05-25 12:53:00 +08:00
|
|
|
|
|
✨ refactor(EditChannel&EditToken): refactor Channel & Token edit pages with Semi Form and UX enhancements
Overview
• Migrated both `EditChannel.js` and `EditToken.js` to fully leverage Semi UI `Form.*` components, removing legacy `Input/Select/TextArea` + manual labels.
• Unified data-loading strategy: when the drawer becomes visible we load (or reset) data via `props.visible + id` effect and `formApi.setValues()`, guaranteeing fields are always populated; form resets on close.
• Fixed blank-form bug when opening the same record twice.
Key improvements
1. Validation
• `type`, `models` always required.
• `key` required only while creating (not on edit).
2. Batch key creation
• Checkbox moved into `extraText`; hidden when editing or when channel type = 41.
3. Layout & UI
• `Row / Col` (12 + 12) for “Priority” and “Weight”.
• Placeholders revised; model selector now shows creation hint; removed obsolete banner.
• Help / extraText used for long hints, template buttons (`model_mapping`, `status_code_mapping`, `param_override`, etc.), and API address notice.
• Added `showClear`, `min`, rounded card class names for consistency.
4. Reusable helpers
• `batchAllowed`, `batchExtra` utilities.
• `getInitValues()` + centralized `inputs`→form synchronization.
5. Token editor aligned to the same pattern (`props.visiable` watcher).
Result
Cleaner code, consistent UX, instant field population on every open, and clearer validation/error feedback across both editors.
2025-07-04 05:36:10 +08:00
|
|
|
|
{/* Model Configuration Card */}
|
2025-09-19 18:09:26 +08:00
|
|
|
|
<div ref={el => formSectionRefs.current.modelConfig = el}>
|
|
|
|
|
|
<Card className='!rounded-2xl shadow-sm border-0 mb-6'>
|
|
|
|
|
|
{/* Header: Model Config */}
|
|
|
|
|
|
<div className='flex items-center mb-2'>
|
2025-08-30 21:15:10 +08:00
|
|
|
|
<Avatar
|
|
|
|
|
|
size='small'
|
|
|
|
|
|
color='purple'
|
|
|
|
|
|
className='mr-2 shadow-md'
|
|
|
|
|
|
>
|
✨ refactor(EditChannel&EditToken): refactor Channel & Token edit pages with Semi Form and UX enhancements
Overview
• Migrated both `EditChannel.js` and `EditToken.js` to fully leverage Semi UI `Form.*` components, removing legacy `Input/Select/TextArea` + manual labels.
• Unified data-loading strategy: when the drawer becomes visible we load (or reset) data via `props.visible + id` effect and `formApi.setValues()`, guaranteeing fields are always populated; form resets on close.
• Fixed blank-form bug when opening the same record twice.
Key improvements
1. Validation
• `type`, `models` always required.
• `key` required only while creating (not on edit).
2. Batch key creation
• Checkbox moved into `extraText`; hidden when editing or when channel type = 41.
3. Layout & UI
• `Row / Col` (12 + 12) for “Priority” and “Weight”.
• Placeholders revised; model selector now shows creation hint; removed obsolete banner.
• Help / extraText used for long hints, template buttons (`model_mapping`, `status_code_mapping`, `param_override`, etc.), and API address notice.
• Added `showClear`, `min`, rounded card class names for consistency.
4. Reusable helpers
• `batchAllowed`, `batchExtra` utilities.
• `getInitValues()` + centralized `inputs`→form synchronization.
5. Token editor aligned to the same pattern (`props.visiable` watcher).
Result
Cleaner code, consistent UX, instant field population on every open, and clearer validation/error feedback across both editors.
2025-07-04 05:36:10 +08:00
|
|
|
|
<IconCode size={16} />
|
|
|
|
|
|
</Avatar>
|
|
|
|
|
|
<div>
|
2025-08-30 21:15:10 +08:00
|
|
|
|
<Text className='text-lg font-medium'>
|
|
|
|
|
|
{t('模型配置')}
|
|
|
|
|
|
</Text>
|
|
|
|
|
|
<div className='text-xs text-gray-600'>
|
|
|
|
|
|
{t('模型选择和映射设置')}
|
|
|
|
|
|
</div>
|
✨ refactor(EditChannel&EditToken): refactor Channel & Token edit pages with Semi Form and UX enhancements
Overview
• Migrated both `EditChannel.js` and `EditToken.js` to fully leverage Semi UI `Form.*` components, removing legacy `Input/Select/TextArea` + manual labels.
• Unified data-loading strategy: when the drawer becomes visible we load (or reset) data via `props.visible + id` effect and `formApi.setValues()`, guaranteeing fields are always populated; form resets on close.
• Fixed blank-form bug when opening the same record twice.
Key improvements
1. Validation
• `type`, `models` always required.
• `key` required only while creating (not on edit).
2. Batch key creation
• Checkbox moved into `extraText`; hidden when editing or when channel type = 41.
3. Layout & UI
• `Row / Col` (12 + 12) for “Priority” and “Weight”.
• Placeholders revised; model selector now shows creation hint; removed obsolete banner.
• Help / extraText used for long hints, template buttons (`model_mapping`, `status_code_mapping`, `param_override`, etc.), and API address notice.
• Added `showClear`, `min`, rounded card class names for consistency.
4. Reusable helpers
• `batchAllowed`, `batchExtra` utilities.
• `getInitValues()` + centralized `inputs`→form synchronization.
5. Token editor aligned to the same pattern (`props.visiable` watcher).
Result
Cleaner code, consistent UX, instant field population on every open, and clearer validation/error feedback across both editors.
2025-07-04 05:36:10 +08:00
|
|
|
|
</div>
|
2025-05-25 12:53:00 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
|
✨ refactor(EditChannel&EditToken): refactor Channel & Token edit pages with Semi Form and UX enhancements
Overview
• Migrated both `EditChannel.js` and `EditToken.js` to fully leverage Semi UI `Form.*` components, removing legacy `Input/Select/TextArea` + manual labels.
• Unified data-loading strategy: when the drawer becomes visible we load (or reset) data via `props.visible + id` effect and `formApi.setValues()`, guaranteeing fields are always populated; form resets on close.
• Fixed blank-form bug when opening the same record twice.
Key improvements
1. Validation
• `type`, `models` always required.
• `key` required only while creating (not on edit).
2. Batch key creation
• Checkbox moved into `extraText`; hidden when editing or when channel type = 41.
3. Layout & UI
• `Row / Col` (12 + 12) for “Priority” and “Weight”.
• Placeholders revised; model selector now shows creation hint; removed obsolete banner.
• Help / extraText used for long hints, template buttons (`model_mapping`, `status_code_mapping`, `param_override`, etc.), and API address notice.
• Added `showClear`, `min`, rounded card class names for consistency.
4. Reusable helpers
• `batchAllowed`, `batchExtra` utilities.
• `getInitValues()` + centralized `inputs`→form synchronization.
5. Token editor aligned to the same pattern (`props.visiable` watcher).
Result
Cleaner code, consistent UX, instant field population on every open, and clearer validation/error feedback across both editors.
2025-07-04 05:36:10 +08:00
|
|
|
|
<Form.Select
|
|
|
|
|
|
field='models'
|
|
|
|
|
|
label={t('模型')}
|
2025-07-11 23:37:47 +08:00
|
|
|
|
placeholder={t('请选择该渠道所支持的模型')}
|
✨ refactor(EditChannel&EditToken): refactor Channel & Token edit pages with Semi Form and UX enhancements
Overview
• Migrated both `EditChannel.js` and `EditToken.js` to fully leverage Semi UI `Form.*` components, removing legacy `Input/Select/TextArea` + manual labels.
• Unified data-loading strategy: when the drawer becomes visible we load (or reset) data via `props.visible + id` effect and `formApi.setValues()`, guaranteeing fields are always populated; form resets on close.
• Fixed blank-form bug when opening the same record twice.
Key improvements
1. Validation
• `type`, `models` always required.
• `key` required only while creating (not on edit).
2. Batch key creation
• Checkbox moved into `extraText`; hidden when editing or when channel type = 41.
3. Layout & UI
• `Row / Col` (12 + 12) for “Priority” and “Weight”.
• Placeholders revised; model selector now shows creation hint; removed obsolete banner.
• Help / extraText used for long hints, template buttons (`model_mapping`, `status_code_mapping`, `param_override`, etc.), and API address notice.
• Added `showClear`, `min`, rounded card class names for consistency.
4. Reusable helpers
• `batchAllowed`, `batchExtra` utilities.
• `getInitValues()` + centralized `inputs`→form synchronization.
5. Token editor aligned to the same pattern (`props.visiable` watcher).
Result
Cleaner code, consistent UX, instant field population on every open, and clearer validation/error feedback across both editors.
2025-07-04 05:36:10 +08:00
|
|
|
|
rules={[{ required: true, message: t('请选择模型') }]}
|
2025-05-25 12:53:00 +08:00
|
|
|
|
multiple
|
2025-07-27 00:01:12 +08:00
|
|
|
|
filter={selectFilter}
|
2025-07-19 13:28:09 +08:00
|
|
|
|
autoClearSearchValue={false}
|
2025-05-25 12:53:00 +08:00
|
|
|
|
searchPosition='dropdown'
|
|
|
|
|
|
optionList={modelOptions}
|
✨ refactor(EditChannel&EditToken): refactor Channel & Token edit pages with Semi Form and UX enhancements
Overview
• Migrated both `EditChannel.js` and `EditToken.js` to fully leverage Semi UI `Form.*` components, removing legacy `Input/Select/TextArea` + manual labels.
• Unified data-loading strategy: when the drawer becomes visible we load (or reset) data via `props.visible + id` effect and `formApi.setValues()`, guaranteeing fields are always populated; form resets on close.
• Fixed blank-form bug when opening the same record twice.
Key improvements
1. Validation
• `type`, `models` always required.
• `key` required only while creating (not on edit).
2. Batch key creation
• Checkbox moved into `extraText`; hidden when editing or when channel type = 41.
3. Layout & UI
• `Row / Col` (12 + 12) for “Priority” and “Weight”.
• Placeholders revised; model selector now shows creation hint; removed obsolete banner.
• Help / extraText used for long hints, template buttons (`model_mapping`, `status_code_mapping`, `param_override`, etc.), and API address notice.
• Added `showClear`, `min`, rounded card class names for consistency.
4. Reusable helpers
• `batchAllowed`, `batchExtra` utilities.
• `getInitValues()` + centralized `inputs`→form synchronization.
5. Token editor aligned to the same pattern (`props.visiable` watcher).
Result
Cleaner code, consistent UX, instant field population on every open, and clearer validation/error feedback across both editors.
2025-07-04 05:36:10 +08:00
|
|
|
|
style={{ width: '100%' }}
|
|
|
|
|
|
onChange={(value) => handleInputChange('models', value)}
|
2025-08-24 01:09:08 +08:00
|
|
|
|
renderSelectedItem={(optionNode) => {
|
|
|
|
|
|
const modelName = String(optionNode?.value ?? '');
|
|
|
|
|
|
return {
|
|
|
|
|
|
isRenderInTag: true,
|
|
|
|
|
|
content: (
|
|
|
|
|
|
<span
|
2025-08-30 21:15:10 +08:00
|
|
|
|
className='cursor-pointer select-none'
|
|
|
|
|
|
role='button'
|
2025-08-24 01:09:08 +08:00
|
|
|
|
tabIndex={0}
|
|
|
|
|
|
title={t('点击复制模型名称')}
|
|
|
|
|
|
onClick={async (e) => {
|
|
|
|
|
|
e.stopPropagation();
|
|
|
|
|
|
const ok = await copy(modelName);
|
|
|
|
|
|
if (ok) {
|
2025-08-30 21:15:10 +08:00
|
|
|
|
showSuccess(
|
|
|
|
|
|
t('已复制:{{name}}', { name: modelName }),
|
|
|
|
|
|
);
|
2025-08-24 01:09:08 +08:00
|
|
|
|
} else {
|
|
|
|
|
|
showError(t('复制失败'));
|
|
|
|
|
|
}
|
|
|
|
|
|
}}
|
|
|
|
|
|
>
|
|
|
|
|
|
{optionNode.label || modelName}
|
|
|
|
|
|
</span>
|
|
|
|
|
|
),
|
|
|
|
|
|
};
|
|
|
|
|
|
}}
|
2025-08-30 21:15:10 +08:00
|
|
|
|
extraText={
|
✨ refactor(EditChannel&EditToken): refactor Channel & Token edit pages with Semi Form and UX enhancements
Overview
• Migrated both `EditChannel.js` and `EditToken.js` to fully leverage Semi UI `Form.*` components, removing legacy `Input/Select/TextArea` + manual labels.
• Unified data-loading strategy: when the drawer becomes visible we load (or reset) data via `props.visible + id` effect and `formApi.setValues()`, guaranteeing fields are always populated; form resets on close.
• Fixed blank-form bug when opening the same record twice.
Key improvements
1. Validation
• `type`, `models` always required.
• `key` required only while creating (not on edit).
2. Batch key creation
• Checkbox moved into `extraText`; hidden when editing or when channel type = 41.
3. Layout & UI
• `Row / Col` (12 + 12) for “Priority” and “Weight”.
• Placeholders revised; model selector now shows creation hint; removed obsolete banner.
• Help / extraText used for long hints, template buttons (`model_mapping`, `status_code_mapping`, `param_override`, etc.), and API address notice.
• Added `showClear`, `min`, rounded card class names for consistency.
4. Reusable helpers
• `batchAllowed`, `batchExtra` utilities.
• `getInitValues()` + centralized `inputs`→form synchronization.
5. Token editor aligned to the same pattern (`props.visiable` watcher).
Result
Cleaner code, consistent UX, instant field population on every open, and clearer validation/error feedback across both editors.
2025-07-04 05:36:10 +08:00
|
|
|
|
<Space wrap>
|
2025-08-30 21:15:10 +08:00
|
|
|
|
<Button
|
|
|
|
|
|
size='small'
|
|
|
|
|
|
type='primary'
|
|
|
|
|
|
onClick={() =>
|
|
|
|
|
|
handleInputChange('models', basicModels)
|
|
|
|
|
|
}
|
|
|
|
|
|
>
|
✨ refactor(EditChannel&EditToken): refactor Channel & Token edit pages with Semi Form and UX enhancements
Overview
• Migrated both `EditChannel.js` and `EditToken.js` to fully leverage Semi UI `Form.*` components, removing legacy `Input/Select/TextArea` + manual labels.
• Unified data-loading strategy: when the drawer becomes visible we load (or reset) data via `props.visible + id` effect and `formApi.setValues()`, guaranteeing fields are always populated; form resets on close.
• Fixed blank-form bug when opening the same record twice.
Key improvements
1. Validation
• `type`, `models` always required.
• `key` required only while creating (not on edit).
2. Batch key creation
• Checkbox moved into `extraText`; hidden when editing or when channel type = 41.
3. Layout & UI
• `Row / Col` (12 + 12) for “Priority” and “Weight”.
• Placeholders revised; model selector now shows creation hint; removed obsolete banner.
• Help / extraText used for long hints, template buttons (`model_mapping`, `status_code_mapping`, `param_override`, etc.), and API address notice.
• Added `showClear`, `min`, rounded card class names for consistency.
4. Reusable helpers
• `batchAllowed`, `batchExtra` utilities.
• `getInitValues()` + centralized `inputs`→form synchronization.
5. Token editor aligned to the same pattern (`props.visiable` watcher).
Result
Cleaner code, consistent UX, instant field population on every open, and clearer validation/error feedback across both editors.
2025-07-04 05:36:10 +08:00
|
|
|
|
{t('填入相关模型')}
|
|
|
|
|
|
</Button>
|
2025-08-30 21:15:10 +08:00
|
|
|
|
<Button
|
|
|
|
|
|
size='small'
|
|
|
|
|
|
type='secondary'
|
|
|
|
|
|
onClick={() =>
|
|
|
|
|
|
handleInputChange('models', fullModels)
|
|
|
|
|
|
}
|
|
|
|
|
|
>
|
✨ refactor(EditChannel&EditToken): refactor Channel & Token edit pages with Semi Form and UX enhancements
Overview
• Migrated both `EditChannel.js` and `EditToken.js` to fully leverage Semi UI `Form.*` components, removing legacy `Input/Select/TextArea` + manual labels.
• Unified data-loading strategy: when the drawer becomes visible we load (or reset) data via `props.visible + id` effect and `formApi.setValues()`, guaranteeing fields are always populated; form resets on close.
• Fixed blank-form bug when opening the same record twice.
Key improvements
1. Validation
• `type`, `models` always required.
• `key` required only while creating (not on edit).
2. Batch key creation
• Checkbox moved into `extraText`; hidden when editing or when channel type = 41.
3. Layout & UI
• `Row / Col` (12 + 12) for “Priority” and “Weight”.
• Placeholders revised; model selector now shows creation hint; removed obsolete banner.
• Help / extraText used for long hints, template buttons (`model_mapping`, `status_code_mapping`, `param_override`, etc.), and API address notice.
• Added `showClear`, `min`, rounded card class names for consistency.
4. Reusable helpers
• `batchAllowed`, `batchExtra` utilities.
• `getInitValues()` + centralized `inputs`→form synchronization.
5. Token editor aligned to the same pattern (`props.visiable` watcher).
Result
Cleaner code, consistent UX, instant field population on every open, and clearer validation/error feedback across both editors.
2025-07-04 05:36:10 +08:00
|
|
|
|
{t('填入所有模型')}
|
|
|
|
|
|
</Button>
|
2025-09-27 01:19:09 +08:00
|
|
|
|
{MODEL_FETCHABLE_TYPES.has(inputs.type) && (
|
|
|
|
|
|
<Button
|
|
|
|
|
|
size='small'
|
|
|
|
|
|
type='tertiary'
|
|
|
|
|
|
onClick={() => fetchUpstreamModelList('models')}
|
|
|
|
|
|
>
|
|
|
|
|
|
{t('获取模型列表')}
|
|
|
|
|
|
</Button>
|
|
|
|
|
|
)}
|
2025-08-30 21:15:10 +08:00
|
|
|
|
<Button
|
|
|
|
|
|
size='small'
|
|
|
|
|
|
type='warning'
|
|
|
|
|
|
onClick={() => handleInputChange('models', [])}
|
|
|
|
|
|
>
|
✨ refactor(EditChannel&EditToken): refactor Channel & Token edit pages with Semi Form and UX enhancements
Overview
• Migrated both `EditChannel.js` and `EditToken.js` to fully leverage Semi UI `Form.*` components, removing legacy `Input/Select/TextArea` + manual labels.
• Unified data-loading strategy: when the drawer becomes visible we load (or reset) data via `props.visible + id` effect and `formApi.setValues()`, guaranteeing fields are always populated; form resets on close.
• Fixed blank-form bug when opening the same record twice.
Key improvements
1. Validation
• `type`, `models` always required.
• `key` required only while creating (not on edit).
2. Batch key creation
• Checkbox moved into `extraText`; hidden when editing or when channel type = 41.
3. Layout & UI
• `Row / Col` (12 + 12) for “Priority” and “Weight”.
• Placeholders revised; model selector now shows creation hint; removed obsolete banner.
• Help / extraText used for long hints, template buttons (`model_mapping`, `status_code_mapping`, `param_override`, etc.), and API address notice.
• Added `showClear`, `min`, rounded card class names for consistency.
4. Reusable helpers
• `batchAllowed`, `batchExtra` utilities.
• `getInitValues()` + centralized `inputs`→form synchronization.
5. Token editor aligned to the same pattern (`props.visiable` watcher).
Result
Cleaner code, consistent UX, instant field population on every open, and clearer validation/error feedback across both editors.
2025-07-04 05:36:10 +08:00
|
|
|
|
{t('清除所有模型')}
|
|
|
|
|
|
</Button>
|
|
|
|
|
|
<Button
|
|
|
|
|
|
size='small'
|
|
|
|
|
|
type='tertiary'
|
|
|
|
|
|
onClick={() => {
|
|
|
|
|
|
if (inputs.models.length === 0) {
|
|
|
|
|
|
showInfo(t('没有模型可以复制'));
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
try {
|
|
|
|
|
|
copy(inputs.models.join(','));
|
|
|
|
|
|
showSuccess(t('模型列表已复制到剪贴板'));
|
|
|
|
|
|
} catch (error) {
|
|
|
|
|
|
showError(t('复制失败'));
|
|
|
|
|
|
}
|
|
|
|
|
|
}}
|
|
|
|
|
|
>
|
|
|
|
|
|
{t('复制所有模型')}
|
|
|
|
|
|
</Button>
|
2025-08-30 21:15:10 +08:00
|
|
|
|
{modelGroups &&
|
|
|
|
|
|
modelGroups.length > 0 &&
|
|
|
|
|
|
modelGroups.map((group) => (
|
|
|
|
|
|
<Button
|
|
|
|
|
|
key={group.id}
|
|
|
|
|
|
size='small'
|
|
|
|
|
|
type='primary'
|
|
|
|
|
|
onClick={() => {
|
|
|
|
|
|
let items = [];
|
|
|
|
|
|
try {
|
|
|
|
|
|
if (Array.isArray(group.items)) {
|
|
|
|
|
|
items = group.items;
|
|
|
|
|
|
} else if (typeof group.items === 'string') {
|
|
|
|
|
|
const parsed = JSON.parse(
|
|
|
|
|
|
group.items || '[]',
|
|
|
|
|
|
);
|
|
|
|
|
|
if (Array.isArray(parsed)) items = parsed;
|
|
|
|
|
|
}
|
|
|
|
|
|
} catch {}
|
|
|
|
|
|
const current =
|
|
|
|
|
|
formApiRef.current?.getValue('models') ||
|
|
|
|
|
|
inputs.models ||
|
|
|
|
|
|
[];
|
|
|
|
|
|
const merged = Array.from(
|
|
|
|
|
|
new Set(
|
|
|
|
|
|
[...current, ...items]
|
|
|
|
|
|
.map((m) => (m || '').trim())
|
|
|
|
|
|
.filter(Boolean),
|
|
|
|
|
|
),
|
|
|
|
|
|
);
|
|
|
|
|
|
handleInputChange('models', merged);
|
|
|
|
|
|
}}
|
|
|
|
|
|
>
|
|
|
|
|
|
{group.name}
|
|
|
|
|
|
</Button>
|
|
|
|
|
|
))}
|
✨ refactor(EditChannel&EditToken): refactor Channel & Token edit pages with Semi Form and UX enhancements
Overview
• Migrated both `EditChannel.js` and `EditToken.js` to fully leverage Semi UI `Form.*` components, removing legacy `Input/Select/TextArea` + manual labels.
• Unified data-loading strategy: when the drawer becomes visible we load (or reset) data via `props.visible + id` effect and `formApi.setValues()`, guaranteeing fields are always populated; form resets on close.
• Fixed blank-form bug when opening the same record twice.
Key improvements
1. Validation
• `type`, `models` always required.
• `key` required only while creating (not on edit).
2. Batch key creation
• Checkbox moved into `extraText`; hidden when editing or when channel type = 41.
3. Layout & UI
• `Row / Col` (12 + 12) for “Priority” and “Weight”.
• Placeholders revised; model selector now shows creation hint; removed obsolete banner.
• Help / extraText used for long hints, template buttons (`model_mapping`, `status_code_mapping`, `param_override`, etc.), and API address notice.
• Added `showClear`, `min`, rounded card class names for consistency.
4. Reusable helpers
• `batchAllowed`, `batchExtra` utilities.
• `getInitValues()` + centralized `inputs`→form synchronization.
5. Token editor aligned to the same pattern (`props.visiable` watcher).
Result
Cleaner code, consistent UX, instant field population on every open, and clearer validation/error feedback across both editors.
2025-07-04 05:36:10 +08:00
|
|
|
|
</Space>
|
2025-08-30 21:15:10 +08:00
|
|
|
|
}
|
2025-05-25 12:53:00 +08:00
|
|
|
|
/>
|
2025-06-27 10:08:44 +08:00
|
|
|
|
|
✨ refactor(EditChannel&EditToken): refactor Channel & Token edit pages with Semi Form and UX enhancements
Overview
• Migrated both `EditChannel.js` and `EditToken.js` to fully leverage Semi UI `Form.*` components, removing legacy `Input/Select/TextArea` + manual labels.
• Unified data-loading strategy: when the drawer becomes visible we load (or reset) data via `props.visible + id` effect and `formApi.setValues()`, guaranteeing fields are always populated; form resets on close.
• Fixed blank-form bug when opening the same record twice.
Key improvements
1. Validation
• `type`, `models` always required.
• `key` required only while creating (not on edit).
2. Batch key creation
• Checkbox moved into `extraText`; hidden when editing or when channel type = 41.
3. Layout & UI
• `Row / Col` (12 + 12) for “Priority” and “Weight”.
• Placeholders revised; model selector now shows creation hint; removed obsolete banner.
• Help / extraText used for long hints, template buttons (`model_mapping`, `status_code_mapping`, `param_override`, etc.), and API address notice.
• Added `showClear`, `min`, rounded card class names for consistency.
4. Reusable helpers
• `batchAllowed`, `batchExtra` utilities.
• `getInitValues()` + centralized `inputs`→form synchronization.
5. Token editor aligned to the same pattern (`props.visiable` watcher).
Result
Cleaner code, consistent UX, instant field population on every open, and clearer validation/error feedback across both editors.
2025-07-04 05:36:10 +08:00
|
|
|
|
<Form.Input
|
|
|
|
|
|
field='custom_model'
|
|
|
|
|
|
label={t('自定义模型名称')}
|
|
|
|
|
|
placeholder={t('输入自定义模型名称')}
|
|
|
|
|
|
onChange={(value) => setCustomModel(value.trim())}
|
|
|
|
|
|
value={customModel}
|
|
|
|
|
|
suffix={
|
2025-08-30 21:15:10 +08:00
|
|
|
|
<Button
|
|
|
|
|
|
size='small'
|
|
|
|
|
|
type='primary'
|
|
|
|
|
|
onClick={addCustomModels}
|
|
|
|
|
|
>
|
2025-05-25 12:53:00 +08:00
|
|
|
|
{t('填入')}
|
|
|
|
|
|
</Button>
|
|
|
|
|
|
}
|
|
|
|
|
|
/>
|
|
|
|
|
|
|
✨ refactor(EditChannel&EditToken): refactor Channel & Token edit pages with Semi Form and UX enhancements
Overview
• Migrated both `EditChannel.js` and `EditToken.js` to fully leverage Semi UI `Form.*` components, removing legacy `Input/Select/TextArea` + manual labels.
• Unified data-loading strategy: when the drawer becomes visible we load (or reset) data via `props.visible + id` effect and `formApi.setValues()`, guaranteeing fields are always populated; form resets on close.
• Fixed blank-form bug when opening the same record twice.
Key improvements
1. Validation
• `type`, `models` always required.
• `key` required only while creating (not on edit).
2. Batch key creation
• Checkbox moved into `extraText`; hidden when editing or when channel type = 41.
3. Layout & UI
• `Row / Col` (12 + 12) for “Priority” and “Weight”.
• Placeholders revised; model selector now shows creation hint; removed obsolete banner.
• Help / extraText used for long hints, template buttons (`model_mapping`, `status_code_mapping`, `param_override`, etc.), and API address notice.
• Added `showClear`, `min`, rounded card class names for consistency.
4. Reusable helpers
• `batchAllowed`, `batchExtra` utilities.
• `getInitValues()` + centralized `inputs`→form synchronization.
5. Token editor aligned to the same pattern (`props.visiable` watcher).
Result
Cleaner code, consistent UX, instant field population on every open, and clearer validation/error feedback across both editors.
2025-07-04 05:36:10 +08:00
|
|
|
|
<Form.Input
|
|
|
|
|
|
field='test_model'
|
|
|
|
|
|
label={t('默认测试模型')}
|
|
|
|
|
|
placeholder={t('不填则为模型列表第一个')}
|
|
|
|
|
|
onChange={(value) => handleInputChange('test_model', value)}
|
|
|
|
|
|
showClear
|
|
|
|
|
|
/>
|
|
|
|
|
|
|
2025-07-31 12:54:07 +08:00
|
|
|
|
<JSONEditor
|
2025-08-10 12:22:18 +08:00
|
|
|
|
key={`model_mapping-${isEdit ? channelId : 'new'}`}
|
✨ refactor(EditChannel&EditToken): refactor Channel & Token edit pages with Semi Form and UX enhancements
Overview
• Migrated both `EditChannel.js` and `EditToken.js` to fully leverage Semi UI `Form.*` components, removing legacy `Input/Select/TextArea` + manual labels.
• Unified data-loading strategy: when the drawer becomes visible we load (or reset) data via `props.visible + id` effect and `formApi.setValues()`, guaranteeing fields are always populated; form resets on close.
• Fixed blank-form bug when opening the same record twice.
Key improvements
1. Validation
• `type`, `models` always required.
• `key` required only while creating (not on edit).
2. Batch key creation
• Checkbox moved into `extraText`; hidden when editing or when channel type = 41.
3. Layout & UI
• `Row / Col` (12 + 12) for “Priority” and “Weight”.
• Placeholders revised; model selector now shows creation hint; removed obsolete banner.
• Help / extraText used for long hints, template buttons (`model_mapping`, `status_code_mapping`, `param_override`, etc.), and API address notice.
• Added `showClear`, `min`, rounded card class names for consistency.
4. Reusable helpers
• `batchAllowed`, `batchExtra` utilities.
• `getInitValues()` + centralized `inputs`→form synchronization.
5. Token editor aligned to the same pattern (`props.visiable` watcher).
Result
Cleaner code, consistent UX, instant field population on every open, and clearer validation/error feedback across both editors.
2025-07-04 05:36:10 +08:00
|
|
|
|
field='model_mapping'
|
|
|
|
|
|
label={t('模型重定向')}
|
2025-05-25 12:53:00 +08:00
|
|
|
|
placeholder={
|
2025-08-30 21:15:10 +08:00
|
|
|
|
t(
|
|
|
|
|
|
'此项可选,用于修改请求体中的模型名称,为一个 JSON 字符串,键为请求中模型名称,值为要替换的模型名称,例如:',
|
|
|
|
|
|
) + `\n${JSON.stringify(MODEL_MAPPING_EXAMPLE, null, 2)}`
|
2025-05-25 12:53:00 +08:00
|
|
|
|
}
|
2025-07-31 12:54:07 +08:00
|
|
|
|
value={inputs.model_mapping || ''}
|
2025-08-30 21:15:10 +08:00
|
|
|
|
onChange={(value) =>
|
|
|
|
|
|
handleInputChange('model_mapping', value)
|
|
|
|
|
|
}
|
2025-07-31 12:54:07 +08:00
|
|
|
|
template={MODEL_MAPPING_EXAMPLE}
|
|
|
|
|
|
templateLabel={t('填入模板')}
|
2025-08-30 21:15:10 +08:00
|
|
|
|
editorType='keyValue'
|
2025-07-31 12:54:07 +08:00
|
|
|
|
formApi={formApiRef.current}
|
2025-08-08 04:09:53 +08:00
|
|
|
|
extraText={t('键为请求中的模型名称,值为要替换的模型名称')}
|
2025-05-25 12:53:00 +08:00
|
|
|
|
/>
|
2025-09-19 18:09:26 +08:00
|
|
|
|
</Card>
|
|
|
|
|
|
</div>
|
2025-05-25 12:53:00 +08:00
|
|
|
|
|
✨ refactor(EditChannel&EditToken): refactor Channel & Token edit pages with Semi Form and UX enhancements
Overview
• Migrated both `EditChannel.js` and `EditToken.js` to fully leverage Semi UI `Form.*` components, removing legacy `Input/Select/TextArea` + manual labels.
• Unified data-loading strategy: when the drawer becomes visible we load (or reset) data via `props.visible + id` effect and `formApi.setValues()`, guaranteeing fields are always populated; form resets on close.
• Fixed blank-form bug when opening the same record twice.
Key improvements
1. Validation
• `type`, `models` always required.
• `key` required only while creating (not on edit).
2. Batch key creation
• Checkbox moved into `extraText`; hidden when editing or when channel type = 41.
3. Layout & UI
• `Row / Col` (12 + 12) for “Priority” and “Weight”.
• Placeholders revised; model selector now shows creation hint; removed obsolete banner.
• Help / extraText used for long hints, template buttons (`model_mapping`, `status_code_mapping`, `param_override`, etc.), and API address notice.
• Added `showClear`, `min`, rounded card class names for consistency.
4. Reusable helpers
• `batchAllowed`, `batchExtra` utilities.
• `getInitValues()` + centralized `inputs`→form synchronization.
5. Token editor aligned to the same pattern (`props.visiable` watcher).
Result
Cleaner code, consistent UX, instant field population on every open, and clearer validation/error feedback across both editors.
2025-07-04 05:36:10 +08:00
|
|
|
|
{/* Advanced Settings Card */}
|
2025-09-19 18:09:26 +08:00
|
|
|
|
<div ref={el => formSectionRefs.current.advancedSettings = el}>
|
|
|
|
|
|
<Card className='!rounded-2xl shadow-sm border-0 mb-6'>
|
|
|
|
|
|
{/* Header: Advanced Settings */}
|
|
|
|
|
|
<div className='flex items-center mb-2'>
|
2025-08-30 21:15:10 +08:00
|
|
|
|
<Avatar
|
|
|
|
|
|
size='small'
|
|
|
|
|
|
color='orange'
|
|
|
|
|
|
className='mr-2 shadow-md'
|
|
|
|
|
|
>
|
✨ refactor(EditChannel&EditToken): refactor Channel & Token edit pages with Semi Form and UX enhancements
Overview
• Migrated both `EditChannel.js` and `EditToken.js` to fully leverage Semi UI `Form.*` components, removing legacy `Input/Select/TextArea` + manual labels.
• Unified data-loading strategy: when the drawer becomes visible we load (or reset) data via `props.visible + id` effect and `formApi.setValues()`, guaranteeing fields are always populated; form resets on close.
• Fixed blank-form bug when opening the same record twice.
Key improvements
1. Validation
• `type`, `models` always required.
• `key` required only while creating (not on edit).
2. Batch key creation
• Checkbox moved into `extraText`; hidden when editing or when channel type = 41.
3. Layout & UI
• `Row / Col` (12 + 12) for “Priority” and “Weight”.
• Placeholders revised; model selector now shows creation hint; removed obsolete banner.
• Help / extraText used for long hints, template buttons (`model_mapping`, `status_code_mapping`, `param_override`, etc.), and API address notice.
• Added `showClear`, `min`, rounded card class names for consistency.
4. Reusable helpers
• `batchAllowed`, `batchExtra` utilities.
• `getInitValues()` + centralized `inputs`→form synchronization.
5. Token editor aligned to the same pattern (`props.visiable` watcher).
Result
Cleaner code, consistent UX, instant field population on every open, and clearer validation/error feedback across both editors.
2025-07-04 05:36:10 +08:00
|
|
|
|
<IconSetting size={16} />
|
|
|
|
|
|
</Avatar>
|
|
|
|
|
|
<div>
|
2025-08-30 21:15:10 +08:00
|
|
|
|
<Text className='text-lg font-medium'>
|
|
|
|
|
|
{t('高级设置')}
|
|
|
|
|
|
</Text>
|
|
|
|
|
|
<div className='text-xs text-gray-600'>
|
|
|
|
|
|
{t('渠道的高级配置选项')}
|
|
|
|
|
|
</div>
|
✨ refactor(EditChannel&EditToken): refactor Channel & Token edit pages with Semi Form and UX enhancements
Overview
• Migrated both `EditChannel.js` and `EditToken.js` to fully leverage Semi UI `Form.*` components, removing legacy `Input/Select/TextArea` + manual labels.
• Unified data-loading strategy: when the drawer becomes visible we load (or reset) data via `props.visible + id` effect and `formApi.setValues()`, guaranteeing fields are always populated; form resets on close.
• Fixed blank-form bug when opening the same record twice.
Key improvements
1. Validation
• `type`, `models` always required.
• `key` required only while creating (not on edit).
2. Batch key creation
• Checkbox moved into `extraText`; hidden when editing or when channel type = 41.
3. Layout & UI
• `Row / Col` (12 + 12) for “Priority” and “Weight”.
• Placeholders revised; model selector now shows creation hint; removed obsolete banner.
• Help / extraText used for long hints, template buttons (`model_mapping`, `status_code_mapping`, `param_override`, etc.), and API address notice.
• Added `showClear`, `min`, rounded card class names for consistency.
4. Reusable helpers
• `batchAllowed`, `batchExtra` utilities.
• `getInitValues()` + centralized `inputs`→form synchronization.
5. Token editor aligned to the same pattern (`props.visiable` watcher).
Result
Cleaner code, consistent UX, instant field population on every open, and clearer validation/error feedback across both editors.
2025-07-04 05:36:10 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
2025-05-25 12:53:00 +08:00
|
|
|
|
|
✨ refactor(EditChannel&EditToken): refactor Channel & Token edit pages with Semi Form and UX enhancements
Overview
• Migrated both `EditChannel.js` and `EditToken.js` to fully leverage Semi UI `Form.*` components, removing legacy `Input/Select/TextArea` + manual labels.
• Unified data-loading strategy: when the drawer becomes visible we load (or reset) data via `props.visible + id` effect and `formApi.setValues()`, guaranteeing fields are always populated; form resets on close.
• Fixed blank-form bug when opening the same record twice.
Key improvements
1. Validation
• `type`, `models` always required.
• `key` required only while creating (not on edit).
2. Batch key creation
• Checkbox moved into `extraText`; hidden when editing or when channel type = 41.
3. Layout & UI
• `Row / Col` (12 + 12) for “Priority” and “Weight”.
• Placeholders revised; model selector now shows creation hint; removed obsolete banner.
• Help / extraText used for long hints, template buttons (`model_mapping`, `status_code_mapping`, `param_override`, etc.), and API address notice.
• Added `showClear`, `min`, rounded card class names for consistency.
4. Reusable helpers
• `batchAllowed`, `batchExtra` utilities.
• `getInitValues()` + centralized `inputs`→form synchronization.
5. Token editor aligned to the same pattern (`props.visiable` watcher).
Result
Cleaner code, consistent UX, instant field population on every open, and clearer validation/error feedback across both editors.
2025-07-04 05:36:10 +08:00
|
|
|
|
<Form.Select
|
|
|
|
|
|
field='groups'
|
|
|
|
|
|
label={t('分组')}
|
2025-05-25 12:53:00 +08:00
|
|
|
|
placeholder={t('请选择可以使用该渠道的分组')}
|
|
|
|
|
|
multiple
|
|
|
|
|
|
allowAdditions
|
2025-08-30 21:15:10 +08:00
|
|
|
|
additionLabel={t(
|
|
|
|
|
|
'请在系统设置页面编辑分组倍率以添加新的分组:',
|
|
|
|
|
|
)}
|
2025-05-25 12:53:00 +08:00
|
|
|
|
optionList={groupOptions}
|
✨ refactor(EditChannel&EditToken): refactor Channel & Token edit pages with Semi Form and UX enhancements
Overview
• Migrated both `EditChannel.js` and `EditToken.js` to fully leverage Semi UI `Form.*` components, removing legacy `Input/Select/TextArea` + manual labels.
• Unified data-loading strategy: when the drawer becomes visible we load (or reset) data via `props.visible + id` effect and `formApi.setValues()`, guaranteeing fields are always populated; form resets on close.
• Fixed blank-form bug when opening the same record twice.
Key improvements
1. Validation
• `type`, `models` always required.
• `key` required only while creating (not on edit).
2. Batch key creation
• Checkbox moved into `extraText`; hidden when editing or when channel type = 41.
3. Layout & UI
• `Row / Col` (12 + 12) for “Priority” and “Weight”.
• Placeholders revised; model selector now shows creation hint; removed obsolete banner.
• Help / extraText used for long hints, template buttons (`model_mapping`, `status_code_mapping`, `param_override`, etc.), and API address notice.
• Added `showClear`, `min`, rounded card class names for consistency.
4. Reusable helpers
• `batchAllowed`, `batchExtra` utilities.
• `getInitValues()` + centralized `inputs`→form synchronization.
5. Token editor aligned to the same pattern (`props.visiable` watcher).
Result
Cleaner code, consistent UX, instant field population on every open, and clearer validation/error feedback across both editors.
2025-07-04 05:36:10 +08:00
|
|
|
|
style={{ width: '100%' }}
|
|
|
|
|
|
onChange={(value) => handleInputChange('groups', value)}
|
2025-05-25 12:53:00 +08:00
|
|
|
|
/>
|
|
|
|
|
|
|
✨ refactor(EditChannel&EditToken): refactor Channel & Token edit pages with Semi Form and UX enhancements
Overview
• Migrated both `EditChannel.js` and `EditToken.js` to fully leverage Semi UI `Form.*` components, removing legacy `Input/Select/TextArea` + manual labels.
• Unified data-loading strategy: when the drawer becomes visible we load (or reset) data via `props.visible + id` effect and `formApi.setValues()`, guaranteeing fields are always populated; form resets on close.
• Fixed blank-form bug when opening the same record twice.
Key improvements
1. Validation
• `type`, `models` always required.
• `key` required only while creating (not on edit).
2. Batch key creation
• Checkbox moved into `extraText`; hidden when editing or when channel type = 41.
3. Layout & UI
• `Row / Col` (12 + 12) for “Priority” and “Weight”.
• Placeholders revised; model selector now shows creation hint; removed obsolete banner.
• Help / extraText used for long hints, template buttons (`model_mapping`, `status_code_mapping`, `param_override`, etc.), and API address notice.
• Added `showClear`, `min`, rounded card class names for consistency.
4. Reusable helpers
• `batchAllowed`, `batchExtra` utilities.
• `getInitValues()` + centralized `inputs`→form synchronization.
5. Token editor aligned to the same pattern (`props.visiable` watcher).
Result
Cleaner code, consistent UX, instant field population on every open, and clearer validation/error feedback across both editors.
2025-07-04 05:36:10 +08:00
|
|
|
|
<Form.Input
|
|
|
|
|
|
field='tag'
|
|
|
|
|
|
label={t('渠道标签')}
|
2025-05-25 12:53:00 +08:00
|
|
|
|
placeholder={t('渠道标签')}
|
✨ refactor(EditChannel&EditToken): refactor Channel & Token edit pages with Semi Form and UX enhancements
Overview
• Migrated both `EditChannel.js` and `EditToken.js` to fully leverage Semi UI `Form.*` components, removing legacy `Input/Select/TextArea` + manual labels.
• Unified data-loading strategy: when the drawer becomes visible we load (or reset) data via `props.visible + id` effect and `formApi.setValues()`, guaranteeing fields are always populated; form resets on close.
• Fixed blank-form bug when opening the same record twice.
Key improvements
1. Validation
• `type`, `models` always required.
• `key` required only while creating (not on edit).
2. Batch key creation
• Checkbox moved into `extraText`; hidden when editing or when channel type = 41.
3. Layout & UI
• `Row / Col` (12 + 12) for “Priority” and “Weight”.
• Placeholders revised; model selector now shows creation hint; removed obsolete banner.
• Help / extraText used for long hints, template buttons (`model_mapping`, `status_code_mapping`, `param_override`, etc.), and API address notice.
• Added `showClear`, `min`, rounded card class names for consistency.
4. Reusable helpers
• `batchAllowed`, `batchExtra` utilities.
• `getInitValues()` + centralized `inputs`→form synchronization.
5. Token editor aligned to the same pattern (`props.visiable` watcher).
Result
Cleaner code, consistent UX, instant field population on every open, and clearer validation/error feedback across both editors.
2025-07-04 05:36:10 +08:00
|
|
|
|
showClear
|
2025-05-25 12:53:00 +08:00
|
|
|
|
onChange={(value) => handleInputChange('tag', value)}
|
2025-09-01 16:23:29 +08:00
|
|
|
|
/>
|
|
|
|
|
|
<Form.TextArea
|
|
|
|
|
|
field='remark'
|
|
|
|
|
|
label={t('备注')}
|
|
|
|
|
|
placeholder={t('请输入备注(仅管理员可见)')}
|
|
|
|
|
|
maxLength={255}
|
|
|
|
|
|
showClear
|
|
|
|
|
|
onChange={(value) => handleInputChange('remark', value)}
|
2025-05-25 12:53:00 +08:00
|
|
|
|
/>
|
|
|
|
|
|
|
✨ refactor(EditChannel&EditToken): refactor Channel & Token edit pages with Semi Form and UX enhancements
Overview
• Migrated both `EditChannel.js` and `EditToken.js` to fully leverage Semi UI `Form.*` components, removing legacy `Input/Select/TextArea` + manual labels.
• Unified data-loading strategy: when the drawer becomes visible we load (or reset) data via `props.visible + id` effect and `formApi.setValues()`, guaranteeing fields are always populated; form resets on close.
• Fixed blank-form bug when opening the same record twice.
Key improvements
1. Validation
• `type`, `models` always required.
• `key` required only while creating (not on edit).
2. Batch key creation
• Checkbox moved into `extraText`; hidden when editing or when channel type = 41.
3. Layout & UI
• `Row / Col` (12 + 12) for “Priority” and “Weight”.
• Placeholders revised; model selector now shows creation hint; removed obsolete banner.
• Help / extraText used for long hints, template buttons (`model_mapping`, `status_code_mapping`, `param_override`, etc.), and API address notice.
• Added `showClear`, `min`, rounded card class names for consistency.
4. Reusable helpers
• `batchAllowed`, `batchExtra` utilities.
• `getInitValues()` + centralized `inputs`→form synchronization.
5. Token editor aligned to the same pattern (`props.visiable` watcher).
Result
Cleaner code, consistent UX, instant field population on every open, and clearer validation/error feedback across both editors.
2025-07-04 05:36:10 +08:00
|
|
|
|
<Row gutter={12}>
|
|
|
|
|
|
<Col span={12}>
|
|
|
|
|
|
<Form.InputNumber
|
|
|
|
|
|
field='priority'
|
|
|
|
|
|
label={t('渠道优先级')}
|
|
|
|
|
|
placeholder={t('渠道优先级')}
|
|
|
|
|
|
min={0}
|
2025-08-30 21:15:10 +08:00
|
|
|
|
onNumberChange={(value) =>
|
|
|
|
|
|
handleInputChange('priority', value)
|
|
|
|
|
|
}
|
✨ refactor(EditChannel&EditToken): refactor Channel & Token edit pages with Semi Form and UX enhancements
Overview
• Migrated both `EditChannel.js` and `EditToken.js` to fully leverage Semi UI `Form.*` components, removing legacy `Input/Select/TextArea` + manual labels.
• Unified data-loading strategy: when the drawer becomes visible we load (or reset) data via `props.visible + id` effect and `formApi.setValues()`, guaranteeing fields are always populated; form resets on close.
• Fixed blank-form bug when opening the same record twice.
Key improvements
1. Validation
• `type`, `models` always required.
• `key` required only while creating (not on edit).
2. Batch key creation
• Checkbox moved into `extraText`; hidden when editing or when channel type = 41.
3. Layout & UI
• `Row / Col` (12 + 12) for “Priority” and “Weight”.
• Placeholders revised; model selector now shows creation hint; removed obsolete banner.
• Help / extraText used for long hints, template buttons (`model_mapping`, `status_code_mapping`, `param_override`, etc.), and API address notice.
• Added `showClear`, `min`, rounded card class names for consistency.
4. Reusable helpers
• `batchAllowed`, `batchExtra` utilities.
• `getInitValues()` + centralized `inputs`→form synchronization.
5. Token editor aligned to the same pattern (`props.visiable` watcher).
Result
Cleaner code, consistent UX, instant field population on every open, and clearer validation/error feedback across both editors.
2025-07-04 05:36:10 +08:00
|
|
|
|
style={{ width: '100%' }}
|
|
|
|
|
|
/>
|
|
|
|
|
|
</Col>
|
|
|
|
|
|
<Col span={12}>
|
|
|
|
|
|
<Form.InputNumber
|
|
|
|
|
|
field='weight'
|
|
|
|
|
|
label={t('渠道权重')}
|
|
|
|
|
|
placeholder={t('渠道权重')}
|
|
|
|
|
|
min={0}
|
2025-08-30 21:15:10 +08:00
|
|
|
|
onNumberChange={(value) =>
|
|
|
|
|
|
handleInputChange('weight', value)
|
|
|
|
|
|
}
|
✨ refactor(EditChannel&EditToken): refactor Channel & Token edit pages with Semi Form and UX enhancements
Overview
• Migrated both `EditChannel.js` and `EditToken.js` to fully leverage Semi UI `Form.*` components, removing legacy `Input/Select/TextArea` + manual labels.
• Unified data-loading strategy: when the drawer becomes visible we load (or reset) data via `props.visible + id` effect and `formApi.setValues()`, guaranteeing fields are always populated; form resets on close.
• Fixed blank-form bug when opening the same record twice.
Key improvements
1. Validation
• `type`, `models` always required.
• `key` required only while creating (not on edit).
2. Batch key creation
• Checkbox moved into `extraText`; hidden when editing or when channel type = 41.
3. Layout & UI
• `Row / Col` (12 + 12) for “Priority” and “Weight”.
• Placeholders revised; model selector now shows creation hint; removed obsolete banner.
• Help / extraText used for long hints, template buttons (`model_mapping`, `status_code_mapping`, `param_override`, etc.), and API address notice.
• Added `showClear`, `min`, rounded card class names for consistency.
4. Reusable helpers
• `batchAllowed`, `batchExtra` utilities.
• `getInitValues()` + centralized `inputs`→form synchronization.
5. Token editor aligned to the same pattern (`props.visiable` watcher).
Result
Cleaner code, consistent UX, instant field population on every open, and clearer validation/error feedback across both editors.
2025-07-04 05:36:10 +08:00
|
|
|
|
style={{ width: '100%' }}
|
|
|
|
|
|
/>
|
|
|
|
|
|
</Col>
|
|
|
|
|
|
</Row>
|
2025-05-25 12:53:00 +08:00
|
|
|
|
|
✨ refactor(EditChannel&EditToken): refactor Channel & Token edit pages with Semi Form and UX enhancements
Overview
• Migrated both `EditChannel.js` and `EditToken.js` to fully leverage Semi UI `Form.*` components, removing legacy `Input/Select/TextArea` + manual labels.
• Unified data-loading strategy: when the drawer becomes visible we load (or reset) data via `props.visible + id` effect and `formApi.setValues()`, guaranteeing fields are always populated; form resets on close.
• Fixed blank-form bug when opening the same record twice.
Key improvements
1. Validation
• `type`, `models` always required.
• `key` required only while creating (not on edit).
2. Batch key creation
• Checkbox moved into `extraText`; hidden when editing or when channel type = 41.
3. Layout & UI
• `Row / Col` (12 + 12) for “Priority” and “Weight”.
• Placeholders revised; model selector now shows creation hint; removed obsolete banner.
• Help / extraText used for long hints, template buttons (`model_mapping`, `status_code_mapping`, `param_override`, etc.), and API address notice.
• Added `showClear`, `min`, rounded card class names for consistency.
4. Reusable helpers
• `batchAllowed`, `batchExtra` utilities.
• `getInitValues()` + centralized `inputs`→form synchronization.
5. Token editor aligned to the same pattern (`props.visiable` watcher).
Result
Cleaner code, consistent UX, instant field population on every open, and clearer validation/error feedback across both editors.
2025-07-04 05:36:10 +08:00
|
|
|
|
<Form.Switch
|
|
|
|
|
|
field='auto_ban'
|
|
|
|
|
|
label={t('是否自动禁用')}
|
|
|
|
|
|
checkedText={t('开')}
|
|
|
|
|
|
uncheckedText={t('关')}
|
2025-07-26 13:33:10 +08:00
|
|
|
|
onChange={(value) => setAutoBan(value)}
|
2025-08-30 21:15:10 +08:00
|
|
|
|
extraText={t(
|
|
|
|
|
|
'仅当自动禁用开启时有效,关闭后不会自动禁用该渠道',
|
|
|
|
|
|
)}
|
✨ refactor(EditChannel&EditToken): refactor Channel & Token edit pages with Semi Form and UX enhancements
Overview
• Migrated both `EditChannel.js` and `EditToken.js` to fully leverage Semi UI `Form.*` components, removing legacy `Input/Select/TextArea` + manual labels.
• Unified data-loading strategy: when the drawer becomes visible we load (or reset) data via `props.visible + id` effect and `formApi.setValues()`, guaranteeing fields are always populated; form resets on close.
• Fixed blank-form bug when opening the same record twice.
Key improvements
1. Validation
• `type`, `models` always required.
• `key` required only while creating (not on edit).
2. Batch key creation
• Checkbox moved into `extraText`; hidden when editing or when channel type = 41.
3. Layout & UI
• `Row / Col` (12 + 12) for “Priority” and “Weight”.
• Placeholders revised; model selector now shows creation hint; removed obsolete banner.
• Help / extraText used for long hints, template buttons (`model_mapping`, `status_code_mapping`, `param_override`, etc.), and API address notice.
• Added `showClear`, `min`, rounded card class names for consistency.
4. Reusable helpers
• `batchAllowed`, `batchExtra` utilities.
• `getInitValues()` + centralized `inputs`→form synchronization.
5. Token editor aligned to the same pattern (`props.visiable` watcher).
Result
Cleaner code, consistent UX, instant field population on every open, and clearer validation/error feedback across both editors.
2025-07-04 05:36:10 +08:00
|
|
|
|
initValue={autoBan}
|
2025-05-25 12:53:00 +08:00
|
|
|
|
/>
|
|
|
|
|
|
|
✨ refactor(EditChannel&EditToken): refactor Channel & Token edit pages with Semi Form and UX enhancements
Overview
• Migrated both `EditChannel.js` and `EditToken.js` to fully leverage Semi UI `Form.*` components, removing legacy `Input/Select/TextArea` + manual labels.
• Unified data-loading strategy: when the drawer becomes visible we load (or reset) data via `props.visible + id` effect and `formApi.setValues()`, guaranteeing fields are always populated; form resets on close.
• Fixed blank-form bug when opening the same record twice.
Key improvements
1. Validation
• `type`, `models` always required.
• `key` required only while creating (not on edit).
2. Batch key creation
• Checkbox moved into `extraText`; hidden when editing or when channel type = 41.
3. Layout & UI
• `Row / Col` (12 + 12) for “Priority” and “Weight”.
• Placeholders revised; model selector now shows creation hint; removed obsolete banner.
• Help / extraText used for long hints, template buttons (`model_mapping`, `status_code_mapping`, `param_override`, etc.), and API address notice.
• Added `showClear`, `min`, rounded card class names for consistency.
4. Reusable helpers
• `batchAllowed`, `batchExtra` utilities.
• `getInitValues()` + centralized `inputs`→form synchronization.
5. Token editor aligned to the same pattern (`props.visiable` watcher).
Result
Cleaner code, consistent UX, instant field population on every open, and clearer validation/error feedback across both editors.
2025-07-04 05:36:10 +08:00
|
|
|
|
<Form.TextArea
|
2025-08-18 04:14:35 +08:00
|
|
|
|
field='param_override'
|
|
|
|
|
|
label={t('参数覆盖')}
|
|
|
|
|
|
placeholder={
|
|
|
|
|
|
t('此项可选,用于覆盖请求参数。不支持覆盖 stream 参数') +
|
2025-08-30 21:15:10 +08:00
|
|
|
|
'\n' +
|
|
|
|
|
|
t('旧格式(直接覆盖):') +
|
2025-08-18 04:14:35 +08:00
|
|
|
|
'\n{\n "temperature": 0,\n "max_tokens": 1000\n}' +
|
2025-08-30 21:15:10 +08:00
|
|
|
|
'\n\n' +
|
|
|
|
|
|
t('新格式(支持条件判断与json自定义):') +
|
2025-08-18 04:14:35 +08:00
|
|
|
|
'\n{\n "operations": [\n {\n "path": "temperature",\n "mode": "set",\n "value": 0.7,\n "conditions": [\n {\n "path": "model",\n "mode": "prefix",\n "value": "gpt"\n }\n ]\n }\n ]\n}'
|
|
|
|
|
|
}
|
|
|
|
|
|
autosize
|
2025-08-30 21:15:10 +08:00
|
|
|
|
onChange={(value) =>
|
|
|
|
|
|
handleInputChange('param_override', value)
|
|
|
|
|
|
}
|
2025-08-18 04:14:35 +08:00
|
|
|
|
extraText={
|
2025-08-30 21:15:10 +08:00
|
|
|
|
<div className='flex gap-2 flex-wrap'>
|
2025-08-18 04:14:35 +08:00
|
|
|
|
<Text
|
2025-08-30 21:15:10 +08:00
|
|
|
|
className='!text-semi-color-primary cursor-pointer'
|
|
|
|
|
|
onClick={() =>
|
|
|
|
|
|
handleInputChange(
|
|
|
|
|
|
'param_override',
|
|
|
|
|
|
JSON.stringify({ temperature: 0 }, null, 2),
|
|
|
|
|
|
)
|
|
|
|
|
|
}
|
2025-08-18 04:14:35 +08:00
|
|
|
|
>
|
|
|
|
|
|
{t('旧格式模板')}
|
|
|
|
|
|
</Text>
|
|
|
|
|
|
<Text
|
2025-08-30 21:15:10 +08:00
|
|
|
|
className='!text-semi-color-primary cursor-pointer'
|
|
|
|
|
|
onClick={() =>
|
|
|
|
|
|
handleInputChange(
|
|
|
|
|
|
'param_override',
|
|
|
|
|
|
JSON.stringify(
|
|
|
|
|
|
{
|
|
|
|
|
|
operations: [
|
|
|
|
|
|
{
|
|
|
|
|
|
path: 'temperature',
|
|
|
|
|
|
mode: 'set',
|
|
|
|
|
|
value: 0.7,
|
|
|
|
|
|
conditions: [
|
|
|
|
|
|
{
|
|
|
|
|
|
path: 'model',
|
|
|
|
|
|
mode: 'prefix',
|
|
|
|
|
|
value: 'gpt',
|
|
|
|
|
|
},
|
|
|
|
|
|
],
|
|
|
|
|
|
logic: 'AND',
|
|
|
|
|
|
},
|
|
|
|
|
|
],
|
|
|
|
|
|
},
|
|
|
|
|
|
null,
|
|
|
|
|
|
2,
|
|
|
|
|
|
),
|
|
|
|
|
|
)
|
|
|
|
|
|
}
|
2025-08-18 04:14:35 +08:00
|
|
|
|
>
|
|
|
|
|
|
{t('新格式模板')}
|
|
|
|
|
|
</Text>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
}
|
|
|
|
|
|
showClear
|
2025-05-25 12:53:00 +08:00
|
|
|
|
/>
|
|
|
|
|
|
|
2025-08-24 01:02:23 +08:00
|
|
|
|
<Form.TextArea
|
2025-08-25 11:32:28 +08:00
|
|
|
|
field='header_override'
|
|
|
|
|
|
label={t('请求头覆盖')}
|
|
|
|
|
|
placeholder={
|
|
|
|
|
|
t('此项可选,用于覆盖请求头参数') +
|
2025-08-30 21:15:10 +08:00
|
|
|
|
'\n' +
|
|
|
|
|
|
t('格式示例:') +
|
2025-08-25 11:32:28 +08:00
|
|
|
|
'\n{\n "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/139.0.0.0 Safari/537.36 Edg/139.0.0.0"\n}'
|
|
|
|
|
|
}
|
|
|
|
|
|
autosize
|
2025-08-30 21:15:10 +08:00
|
|
|
|
onChange={(value) =>
|
|
|
|
|
|
handleInputChange('header_override', value)
|
|
|
|
|
|
}
|
2025-08-25 11:32:28 +08:00
|
|
|
|
extraText={
|
2025-08-30 21:15:10 +08:00
|
|
|
|
<div className='flex gap-2 flex-wrap'>
|
2025-08-25 11:32:28 +08:00
|
|
|
|
<Text
|
2025-08-30 21:15:10 +08:00
|
|
|
|
className='!text-semi-color-primary cursor-pointer'
|
|
|
|
|
|
onClick={() =>
|
|
|
|
|
|
handleInputChange(
|
|
|
|
|
|
'header_override',
|
|
|
|
|
|
JSON.stringify(
|
|
|
|
|
|
{
|
|
|
|
|
|
'User-Agent':
|
|
|
|
|
|
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/139.0.0.0 Safari/537.36 Edg/139.0.0.0',
|
|
|
|
|
|
},
|
|
|
|
|
|
null,
|
|
|
|
|
|
2,
|
|
|
|
|
|
),
|
|
|
|
|
|
)
|
|
|
|
|
|
}
|
2025-08-25 11:32:28 +08:00
|
|
|
|
>
|
|
|
|
|
|
{t('格式模板')}
|
|
|
|
|
|
</Text>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
}
|
|
|
|
|
|
showClear
|
2025-08-24 01:02:23 +08:00
|
|
|
|
/>
|
|
|
|
|
|
|
2025-07-31 12:54:07 +08:00
|
|
|
|
<JSONEditor
|
2025-08-10 12:22:18 +08:00
|
|
|
|
key={`status_code_mapping-${isEdit ? channelId : 'new'}`}
|
✨ refactor(EditChannel&EditToken): refactor Channel & Token edit pages with Semi Form and UX enhancements
Overview
• Migrated both `EditChannel.js` and `EditToken.js` to fully leverage Semi UI `Form.*` components, removing legacy `Input/Select/TextArea` + manual labels.
• Unified data-loading strategy: when the drawer becomes visible we load (or reset) data via `props.visible + id` effect and `formApi.setValues()`, guaranteeing fields are always populated; form resets on close.
• Fixed blank-form bug when opening the same record twice.
Key improvements
1. Validation
• `type`, `models` always required.
• `key` required only while creating (not on edit).
2. Batch key creation
• Checkbox moved into `extraText`; hidden when editing or when channel type = 41.
3. Layout & UI
• `Row / Col` (12 + 12) for “Priority” and “Weight”.
• Placeholders revised; model selector now shows creation hint; removed obsolete banner.
• Help / extraText used for long hints, template buttons (`model_mapping`, `status_code_mapping`, `param_override`, etc.), and API address notice.
• Added `showClear`, `min`, rounded card class names for consistency.
4. Reusable helpers
• `batchAllowed`, `batchExtra` utilities.
• `getInitValues()` + centralized `inputs`→form synchronization.
5. Token editor aligned to the same pattern (`props.visiable` watcher).
Result
Cleaner code, consistent UX, instant field population on every open, and clearer validation/error feedback across both editors.
2025-07-04 05:36:10 +08:00
|
|
|
|
field='status_code_mapping'
|
|
|
|
|
|
label={t('状态码复写')}
|
2025-05-25 12:53:00 +08:00
|
|
|
|
placeholder={
|
2025-08-30 21:15:10 +08:00
|
|
|
|
t(
|
|
|
|
|
|
'此项可选,用于复写返回的状态码,仅影响本地判断,不修改返回到上游的状态码,比如将claude渠道的400错误复写为500(用于重试),请勿滥用该功能,例如:',
|
|
|
|
|
|
) +
|
2025-05-25 12:53:00 +08:00
|
|
|
|
'\n' +
|
|
|
|
|
|
JSON.stringify(STATUS_CODE_MAPPING_EXAMPLE, null, 2)
|
|
|
|
|
|
}
|
2025-07-31 12:54:07 +08:00
|
|
|
|
value={inputs.status_code_mapping || ''}
|
2025-08-30 21:15:10 +08:00
|
|
|
|
onChange={(value) =>
|
|
|
|
|
|
handleInputChange('status_code_mapping', value)
|
|
|
|
|
|
}
|
2025-07-31 12:54:07 +08:00
|
|
|
|
template={STATUS_CODE_MAPPING_EXAMPLE}
|
|
|
|
|
|
templateLabel={t('填入模板')}
|
2025-08-30 21:15:10 +08:00
|
|
|
|
editorType='keyValue'
|
2025-07-31 12:54:07 +08:00
|
|
|
|
formApi={formApiRef.current}
|
2025-08-30 21:15:10 +08:00
|
|
|
|
extraText={t(
|
|
|
|
|
|
'键为原状态码,值为要复写的状态码,仅影响本地判断',
|
|
|
|
|
|
)}
|
✨ refactor(EditChannel&EditToken): refactor Channel & Token edit pages with Semi Form and UX enhancements
Overview
• Migrated both `EditChannel.js` and `EditToken.js` to fully leverage Semi UI `Form.*` components, removing legacy `Input/Select/TextArea` + manual labels.
• Unified data-loading strategy: when the drawer becomes visible we load (or reset) data via `props.visible + id` effect and `formApi.setValues()`, guaranteeing fields are always populated; form resets on close.
• Fixed blank-form bug when opening the same record twice.
Key improvements
1. Validation
• `type`, `models` always required.
• `key` required only while creating (not on edit).
2. Batch key creation
• Checkbox moved into `extraText`; hidden when editing or when channel type = 41.
3. Layout & UI
• `Row / Col` (12 + 12) for “Priority” and “Weight”.
• Placeholders revised; model selector now shows creation hint; removed obsolete banner.
• Help / extraText used for long hints, template buttons (`model_mapping`, `status_code_mapping`, `param_override`, etc.), and API address notice.
• Added `showClear`, `min`, rounded card class names for consistency.
4. Reusable helpers
• `batchAllowed`, `batchExtra` utilities.
• `getInitValues()` + centralized `inputs`→form synchronization.
5. Token editor aligned to the same pattern (`props.visiable` watcher).
Result
Cleaner code, consistent UX, instant field population on every open, and clearer validation/error feedback across both editors.
2025-07-04 05:36:10 +08:00
|
|
|
|
/>
|
2025-09-19 18:09:26 +08:00
|
|
|
|
</Card>
|
|
|
|
|
|
</div>
|
✨ refactor(EditChannel&EditToken): refactor Channel & Token edit pages with Semi Form and UX enhancements
Overview
• Migrated both `EditChannel.js` and `EditToken.js` to fully leverage Semi UI `Form.*` components, removing legacy `Input/Select/TextArea` + manual labels.
• Unified data-loading strategy: when the drawer becomes visible we load (or reset) data via `props.visible + id` effect and `formApi.setValues()`, guaranteeing fields are always populated; form resets on close.
• Fixed blank-form bug when opening the same record twice.
Key improvements
1. Validation
• `type`, `models` always required.
• `key` required only while creating (not on edit).
2. Batch key creation
• Checkbox moved into `extraText`; hidden when editing or when channel type = 41.
3. Layout & UI
• `Row / Col` (12 + 12) for “Priority” and “Weight”.
• Placeholders revised; model selector now shows creation hint; removed obsolete banner.
• Help / extraText used for long hints, template buttons (`model_mapping`, `status_code_mapping`, `param_override`, etc.), and API address notice.
• Added `showClear`, `min`, rounded card class names for consistency.
4. Reusable helpers
• `batchAllowed`, `batchExtra` utilities.
• `getInitValues()` + centralized `inputs`→form synchronization.
5. Token editor aligned to the same pattern (`props.visiable` watcher).
Result
Cleaner code, consistent UX, instant field population on every open, and clearer validation/error feedback across both editors.
2025-07-04 05:36:10 +08:00
|
|
|
|
|
2025-07-26 13:33:10 +08:00
|
|
|
|
{/* Channel Extra Settings Card */}
|
2025-09-19 18:09:26 +08:00
|
|
|
|
<div ref={el => formSectionRefs.current.channelExtraSettings = el}>
|
|
|
|
|
|
<Card className='!rounded-2xl shadow-sm border-0 mb-6'>
|
|
|
|
|
|
{/* Header: Channel Extra Settings */}
|
|
|
|
|
|
<div className='flex items-center mb-2'>
|
2025-08-30 21:15:10 +08:00
|
|
|
|
<Avatar
|
|
|
|
|
|
size='small'
|
|
|
|
|
|
color='violet'
|
|
|
|
|
|
className='mr-2 shadow-md'
|
|
|
|
|
|
>
|
2025-07-26 13:33:10 +08:00
|
|
|
|
<IconBolt size={16} />
|
|
|
|
|
|
</Avatar>
|
|
|
|
|
|
<div>
|
2025-08-30 21:15:10 +08:00
|
|
|
|
<Text className='text-lg font-medium'>
|
|
|
|
|
|
{t('渠道额外设置')}
|
|
|
|
|
|
</Text>
|
2025-07-26 11:39:09 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
2025-07-26 17:18:47 +08:00
|
|
|
|
{inputs.type === 1 && (
|
|
|
|
|
|
<Form.Switch
|
|
|
|
|
|
field='force_format'
|
|
|
|
|
|
label={t('强制格式化')}
|
|
|
|
|
|
checkedText={t('开')}
|
|
|
|
|
|
uncheckedText={t('关')}
|
2025-08-30 21:15:10 +08:00
|
|
|
|
onChange={(value) =>
|
|
|
|
|
|
handleChannelSettingsChange('force_format', value)
|
|
|
|
|
|
}
|
|
|
|
|
|
extraText={t(
|
|
|
|
|
|
'强制将响应格式化为 OpenAI 标准格式(只适用于OpenAI渠道类型)',
|
|
|
|
|
|
)}
|
2025-07-26 17:18:47 +08:00
|
|
|
|
/>
|
|
|
|
|
|
)}
|
2025-07-26 13:33:10 +08:00
|
|
|
|
|
|
|
|
|
|
<Form.Switch
|
|
|
|
|
|
field='thinking_to_content'
|
|
|
|
|
|
label={t('思考内容转换')}
|
|
|
|
|
|
checkedText={t('开')}
|
|
|
|
|
|
uncheckedText={t('关')}
|
2025-08-30 21:15:10 +08:00
|
|
|
|
onChange={(value) =>
|
|
|
|
|
|
handleChannelSettingsChange('thinking_to_content', value)
|
|
|
|
|
|
}
|
|
|
|
|
|
extraText={t(
|
|
|
|
|
|
'将 reasoning_content 转换为 <think> 标签拼接到内容中',
|
|
|
|
|
|
)}
|
2025-07-26 13:33:10 +08:00
|
|
|
|
/>
|
|
|
|
|
|
|
|
|
|
|
|
<Form.Switch
|
|
|
|
|
|
field='pass_through_body_enabled'
|
|
|
|
|
|
label={t('透传请求体')}
|
|
|
|
|
|
checkedText={t('开')}
|
|
|
|
|
|
uncheckedText={t('关')}
|
2025-08-30 21:15:10 +08:00
|
|
|
|
onChange={(value) =>
|
|
|
|
|
|
handleChannelSettingsChange(
|
|
|
|
|
|
'pass_through_body_enabled',
|
|
|
|
|
|
value,
|
|
|
|
|
|
)
|
|
|
|
|
|
}
|
2025-07-26 13:33:10 +08:00
|
|
|
|
extraText={t('启用请求体透传功能')}
|
|
|
|
|
|
/>
|
2025-07-26 11:39:09 +08:00
|
|
|
|
|
2025-07-26 13:33:10 +08:00
|
|
|
|
<Form.Input
|
|
|
|
|
|
field='proxy'
|
|
|
|
|
|
label={t('代理地址')}
|
|
|
|
|
|
placeholder={t('例如: socks5://user:pass@host:port')}
|
2025-08-30 21:15:10 +08:00
|
|
|
|
onChange={(value) =>
|
|
|
|
|
|
handleChannelSettingsChange('proxy', value)
|
|
|
|
|
|
}
|
2025-07-26 13:33:10 +08:00
|
|
|
|
showClear
|
|
|
|
|
|
extraText={t('用于配置网络代理,支持 socks5 协议')}
|
|
|
|
|
|
/>
|
|
|
|
|
|
|
|
|
|
|
|
<Form.TextArea
|
|
|
|
|
|
field='system_prompt'
|
|
|
|
|
|
label={t('系统提示词')}
|
2025-08-30 21:15:10 +08:00
|
|
|
|
placeholder={t(
|
|
|
|
|
|
'输入系统提示词,用户的系统提示词将优先于此设置',
|
|
|
|
|
|
)}
|
|
|
|
|
|
onChange={(value) =>
|
|
|
|
|
|
handleChannelSettingsChange('system_prompt', value)
|
|
|
|
|
|
}
|
2025-07-26 13:33:10 +08:00
|
|
|
|
autosize
|
2025-07-31 22:08:16 +08:00
|
|
|
|
showClear
|
2025-08-30 21:15:10 +08:00
|
|
|
|
extraText={t(
|
|
|
|
|
|
'用户优先:如果用户在请求中指定了系统提示词,将优先使用用户的设置',
|
|
|
|
|
|
)}
|
2025-07-26 13:33:10 +08:00
|
|
|
|
/>
|
2025-08-09 12:53:06 +08:00
|
|
|
|
<Form.Switch
|
|
|
|
|
|
field='system_prompt_override'
|
|
|
|
|
|
label={t('系统提示词拼接')}
|
|
|
|
|
|
checkedText={t('开')}
|
|
|
|
|
|
uncheckedText={t('关')}
|
2025-08-30 21:15:10 +08:00
|
|
|
|
onChange={(value) =>
|
|
|
|
|
|
handleChannelSettingsChange(
|
|
|
|
|
|
'system_prompt_override',
|
|
|
|
|
|
value,
|
|
|
|
|
|
)
|
|
|
|
|
|
}
|
|
|
|
|
|
extraText={t(
|
|
|
|
|
|
'如果用户请求中包含系统提示词,则使用此设置拼接到用户的系统提示词前面',
|
|
|
|
|
|
)}
|
2025-08-09 12:53:06 +08:00
|
|
|
|
/>
|
2025-09-19 18:09:26 +08:00
|
|
|
|
</Card>
|
|
|
|
|
|
</div>
|
2025-05-25 12:53:00 +08:00
|
|
|
|
</div>
|
✨ refactor(EditChannel&EditToken): refactor Channel & Token edit pages with Semi Form and UX enhancements
Overview
• Migrated both `EditChannel.js` and `EditToken.js` to fully leverage Semi UI `Form.*` components, removing legacy `Input/Select/TextArea` + manual labels.
• Unified data-loading strategy: when the drawer becomes visible we load (or reset) data via `props.visible + id` effect and `formApi.setValues()`, guaranteeing fields are always populated; form resets on close.
• Fixed blank-form bug when opening the same record twice.
Key improvements
1. Validation
• `type`, `models` always required.
• `key` required only while creating (not on edit).
2. Batch key creation
• Checkbox moved into `extraText`; hidden when editing or when channel type = 41.
3. Layout & UI
• `Row / Col` (12 + 12) for “Priority” and “Weight”.
• Placeholders revised; model selector now shows creation hint; removed obsolete banner.
• Help / extraText used for long hints, template buttons (`model_mapping`, `status_code_mapping`, `param_override`, etc.), and API address notice.
• Added `showClear`, `min`, rounded card class names for consistency.
4. Reusable helpers
• `batchAllowed`, `batchExtra` utilities.
• `getInitValues()` + centralized `inputs`→form synchronization.
5. Token editor aligned to the same pattern (`props.visiable` watcher).
Result
Cleaner code, consistent UX, instant field population on every open, and clearer validation/error feedback across both editors.
2025-07-04 05:36:10 +08:00
|
|
|
|
</Spin>
|
|
|
|
|
|
)}
|
|
|
|
|
|
</Form>
|
2025-04-27 17:20:49 +08:00
|
|
|
|
<ImagePreview
|
|
|
|
|
|
src={modalImageUrl}
|
|
|
|
|
|
visible={isModalOpenurl}
|
|
|
|
|
|
onVisibleChange={(visible) => setIsModalOpenurl(visible)}
|
|
|
|
|
|
/>
|
2024-03-23 21:24:39 +08:00
|
|
|
|
</SideSheet>
|
2025-08-25 14:45:48 +08:00
|
|
|
|
{/* 使用TwoFactorAuthModal组件进行2FA验证 */}
|
|
|
|
|
|
<TwoFactorAuthModal
|
|
|
|
|
|
visible={show2FAVerifyModal}
|
|
|
|
|
|
code={verifyCode}
|
|
|
|
|
|
loading={verifyLoading}
|
|
|
|
|
|
onCodeChange={setVerifyCode}
|
|
|
|
|
|
onVerify={handleVerify2FA}
|
|
|
|
|
|
onCancel={reset2FAVerifyState}
|
|
|
|
|
|
title={t('查看渠道密钥')}
|
|
|
|
|
|
description={t('为了保护账户安全,请验证您的两步验证码。')}
|
|
|
|
|
|
placeholder={t('请输入验证码或备用码')}
|
|
|
|
|
|
/>
|
|
|
|
|
|
|
|
|
|
|
|
{/* 使用ChannelKeyDisplay组件显示密钥 */}
|
|
|
|
|
|
<Modal
|
|
|
|
|
|
title={
|
2025-08-30 21:15:10 +08:00
|
|
|
|
<div className='flex items-center'>
|
|
|
|
|
|
<div className='w-8 h-8 rounded-full bg-green-100 dark:bg-green-900 flex items-center justify-center mr-3'>
|
|
|
|
|
|
<svg
|
|
|
|
|
|
className='w-4 h-4 text-green-600 dark:text-green-400'
|
|
|
|
|
|
fill='currentColor'
|
|
|
|
|
|
viewBox='0 0 20 20'
|
|
|
|
|
|
>
|
|
|
|
|
|
<path
|
|
|
|
|
|
fillRule='evenodd'
|
|
|
|
|
|
d='M5 9V7a5 5 0 0110 0v2a2 2 0 012 2v5a2 2 0 01-2 2H5a2 2 0 01-2-2v-5a2 2 0 012-2zm8-2v2H7V7a3 3 0 016 0z'
|
|
|
|
|
|
clipRule='evenodd'
|
|
|
|
|
|
/>
|
2025-08-25 14:45:48 +08:00
|
|
|
|
</svg>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
{t('渠道密钥信息')}
|
|
|
|
|
|
</div>
|
|
|
|
|
|
}
|
|
|
|
|
|
visible={twoFAState.showModal && twoFAState.showKey}
|
|
|
|
|
|
onCancel={resetTwoFAState}
|
|
|
|
|
|
footer={
|
2025-08-30 21:15:10 +08:00
|
|
|
|
<Button type='primary' onClick={resetTwoFAState}>
|
2025-08-25 14:45:48 +08:00
|
|
|
|
{t('完成')}
|
|
|
|
|
|
</Button>
|
|
|
|
|
|
}
|
|
|
|
|
|
width={700}
|
|
|
|
|
|
style={{ maxWidth: '90vw' }}
|
|
|
|
|
|
>
|
|
|
|
|
|
<ChannelKeyDisplay
|
|
|
|
|
|
keyData={twoFAState.keyData}
|
|
|
|
|
|
showSuccessIcon={true}
|
|
|
|
|
|
successText={t('密钥获取成功')}
|
|
|
|
|
|
showWarning={true}
|
2025-08-30 21:15:10 +08:00
|
|
|
|
warningText={t(
|
|
|
|
|
|
'请妥善保管密钥信息,不要泄露给他人。如有安全疑虑,请及时更换密钥。',
|
|
|
|
|
|
)}
|
2025-08-25 14:45:48 +08:00
|
|
|
|
/>
|
|
|
|
|
|
</Modal>
|
|
|
|
|
|
|
2025-07-28 01:33:23 +08:00
|
|
|
|
<ModelSelectModal
|
|
|
|
|
|
visible={modelModalVisible}
|
|
|
|
|
|
models={fetchedModels}
|
|
|
|
|
|
selected={inputs.models}
|
|
|
|
|
|
onConfirm={(selectedModels) => {
|
|
|
|
|
|
handleInputChange('models', selectedModels);
|
|
|
|
|
|
showSuccess(t('模型列表已更新'));
|
|
|
|
|
|
setModelModalVisible(false);
|
|
|
|
|
|
}}
|
|
|
|
|
|
onCancel={() => setModelModalVisible(false)}
|
|
|
|
|
|
/>
|
2024-03-23 21:24:39 +08:00
|
|
|
|
</>
|
|
|
|
|
|
);
|
2023-04-23 12:43:10 +08:00
|
|
|
|
};
|
|
|
|
|
|
|
2025-08-30 21:15:10 +08:00
|
|
|
|
export default EditChannelModal;
|