diff --git a/ui/ModelModal/package.json b/ui/ModelModal/package.json index 5a1afcc..e6ac4a5 100644 --- a/ui/ModelModal/package.json +++ b/ui/ModelModal/package.json @@ -1,6 +1,6 @@ { "name": "@yokowu/modelkit-ui", - "version": "0.7.0", + "version": "0.7.1", "description": "A reusable AI model configuration modal component for React applications", "private": false, "type": "module", diff --git a/ui/ModelModal/src/ModelModal.tsx b/ui/ModelModal/src/ModelModal.tsx index f40381d..77e363b 100644 --- a/ui/ModelModal/src/ModelModal.tsx +++ b/ui/ModelModal/src/ModelModal.tsx @@ -507,6 +507,11 @@ export const ModelModal: React.FC = ({ value: true, message: 'URL 不能为空', }, + validate: (value) => { + if (!value) return true; // 空值由required规则处理 + const hasScheme = /^https?:\/\//i.test(value); + return hasScheme || 'API地址必须包含协议(http://或https://)'; + }, }} render={({ field }) => ( = ({ ) : modelUserList.length === 0 ? ( - <> - {addModelError && ( - - {addModelError} - - )} - ) : ( <> diff --git a/usecase/modelkit.go b/usecase/modelkit.go index 0d8889d..190d9f6 100644 --- a/usecase/modelkit.go +++ b/usecase/modelkit.go @@ -446,12 +446,12 @@ func generateBaseURLFixSuggestion(errContent string, baseURL string) string { hasPath = true } - errType := consts.AddModelBaseURLErrTypeHost + var errType consts.AddModelBaseURLErrType // 404 且是本地地址,建议使用宿主机主机名 if is404 && isLocal { errType = consts.AddModelBaseURLErrTypeHost - } else if !isLocal && !hasPath && !is404 { - // 不是本地地址,且没有path,且不是404,建议在API地址末尾添加/v1 + } else if !isLocal && !hasPath { + // 不是本地地址,且没有path,建议在API地址末尾添加/v1 errType = consts.AddModelBaseURLErrTypeV1Path } else { return ""