feat(web): update read_all_config select valueKey

This commit is contained in:
zhaoying
2026-01-26 17:43:25 +08:00
parent 4f4f55d67f
commit 46f0f3cee9
4 changed files with 20 additions and 11 deletions

View File

@@ -15,7 +15,7 @@ interface ApiResponse<T> {
interface CustomSelectProps extends Omit<SelectProps, 'filterOption'> {
url: string;
params?: Record<string, unknown>;
valueKey?: string;
valueKey?: string | string[];
labelKey?: string;
placeholder?: string;
hasAll?: boolean;
@@ -66,11 +66,18 @@ const CustomSelect: FC<CustomSelectProps> = ({
{...props}
>
{hasAll && <Select.Option value={null}>{allTitle || t('common.all')}</Select.Option>}
{displayOptions.map((option) => (
<Select.Option key={option[valueKey]} value={option[valueKey]}>
{String(option[labelKey])}
</Select.Option>
))}
{displayOptions.map((option) => {
const getValue = () => {
if (typeof valueKey === 'string') return option[valueKey];
return valueKey.find(key => option[key] != null) ? option[valueKey.find(key => option[key] != null)!] : undefined;
};
const value = getValue();
return (
<Select.Option key={value} value={value}>
{String(option[labelKey])}
</Select.Option>
);
})}
</Select>
);
};

View File

@@ -79,7 +79,7 @@ const SelectWrapper: FC<{ title: string, desc: string, name: string | string[],
placeholder={t('common.pleaseSelect')}
url={url}
hasAll={false}
valueKey='config_id'
valueKey={['config_id_old', 'config_id']}
labelKey="config_name"
/>
</Form.Item>
@@ -126,12 +126,14 @@ const Agent = forwardRef<AgentRef>((_props, ref) => {
getApplicationConfig(id as string).then(res => {
const response = res as Config
let allTools = Array.isArray(response.tools) ? response.tools : []
const memoryContent = response.memory?.memory_content
const convertedMemoryContent = memoryContent && !isNaN(Number(memoryContent)) ? Number(memoryContent) : memoryContent
form.setFieldsValue({
...response,
tools: allTools,
memory: {
...response.memory,
memory_content: response.memory?.memory_content ? Number(response.memory?.memory_content) : undefined
memory_content: convertedMemoryContent
}
})
setData({

View File

@@ -200,7 +200,7 @@ export const nodeLibrary: NodeLibrary[] = [
config_id: {
type: 'customSelect',
url: memoryConfigListUrl,
valueKey: 'config_id',
valueKey: ['config_id_old', 'config_id'],
labelKey: 'config_name'
},
search_switch: {
@@ -223,7 +223,7 @@ export const nodeLibrary: NodeLibrary[] = [
config_id: {
type: 'customSelect',
url: memoryConfigListUrl,
valueKey: 'config_id',
valueKey: ['config_id_old', 'config_id'],
labelKey: 'config_name'
}
}

View File

@@ -14,7 +14,7 @@ export interface NodeConfig {
url?: string;
params?: { [key: string]: unknown; }
valueKey?: string;
valueKey?: string | string[];
labelKey?: string;
defaultValue?: any;