diff --git a/web/src/components/ModelSelect/index.tsx b/web/src/components/ModelSelect/index.tsx index 8f9152fb..85977376 100644 --- a/web/src/components/ModelSelect/index.tsx +++ b/web/src/components/ModelSelect/index.tsx @@ -2,9 +2,9 @@ * @Author: ZhaoYing * @Date: 2026-03-07 16:49:59 * @Last Modified by: ZhaoYing - * @Last Modified time: 2026-03-25 11:21:59 + * @Last Modified time: 2026-04-17 10:11:54 */ -import { useEffect, useState, type FC } from 'react'; +import { type FC, useEffect, useState } from 'react'; import { Select, Flex, Space } from 'antd'; import type { SelectProps } from 'antd/es/select'; import { useTranslation } from 'react-i18next'; @@ -22,16 +22,10 @@ interface ModelSelectProps extends SelectProps { fontClassName?: string; isAutoFetch?: boolean; initialData?: Model[]; + updateOptions?: (options: Model[]) => void; } -const ModelSelect: FC = ({ - params, - placeholder, - fontClassName, - isAutoFetch = true, - initialData = [], - ...props -}) => { +const ModelSelect: FC = ({ params, placeholder, fontClassName, isAutoFetch = true, initialData = [], updateOptions, ...props }) => { const { t } = useTranslation(); const [options, setOptions] = useState([]); @@ -60,6 +54,10 @@ const ModelSelect: FC = ({ ); }; + useEffect(() => { + if (updateOptions) updateOptions([...options, ...initialData]); + }, [options, initialData]) + return (