chore: check configuration on initial and change values

This commit is contained in:
jialin
2025-04-02 14:19:06 +08:00
parent b1d7bb9fd7
commit f8a8314476
13 changed files with 84 additions and 75 deletions
+11 -17
View File
@@ -117,16 +117,7 @@ const AddModal: FC<AddModalProps> = (props) => {
const handleOnOk = async (allValues: FormData) => {
const result = getSourceRepoConfigValue(props.source, allValues).values;
if (submitAnyway.current) {
onOk(result);
return;
}
const evalutionData = await handleEvaluate(result);
handleShowCompatibleAlert?.(evalutionData);
if (evalutionData?.compatible) {
onOk(result);
}
onOk(result);
};
const handleSubmitAnyway = async () => {
@@ -198,22 +189,25 @@ const AddModal: FC<AddModalProps> = (props) => {
onCancel?.();
}, [onCancel]);
useEffect(() => {
if (!open) {
return;
}
const handleOnOpen = useCallback(() => {
if (props.deploymentType === 'modelFiles') {
form.current?.form?.setFieldsValue({
...props.initialValues
});
setIsGGUF(props.isGGUF || false);
} else {
const backend =
source === modelSourceMap.ollama_library_value
? backendOptionsMap.llamaBox
: backendOptionsMap.vllm;
form.current?.setFieldValue?.('backend', backend);
setIsGGUF(backend === backendOptionsMap.llamaBox);
}
}, [source, props.initialValues, props.deploymentType]);
useEffect(() => {
if (!open) {
return;
} else {
handleOnOpen();
}
return () => {
@@ -225,7 +219,7 @@ const AddModal: FC<AddModalProps> = (props) => {
});
checkTokenRef.current?.cancel();
};
}, [open, props.isGGUF, source, props.initialValues, props.deploymentType]);
}, [open, handleOnOpen]);
return (
<Drawer