diff --git a/web/containers/Layout/Ribbon/index.tsx b/web/containers/Layout/Ribbon/index.tsx index 6c63ade33..83ed2725a 100644 --- a/web/containers/Layout/Ribbon/index.tsx +++ b/web/containers/Layout/Ribbon/index.tsx @@ -41,7 +41,10 @@ export default function RibbonNav() { icon: ( ), state: MainViewState.Thread, @@ -60,7 +63,7 @@ export default function RibbonNav() { const secondaryMenus = [ { - name: 'Local Server', + name: 'Local API Server', icon: ( { + const [errorRangePort, setErrorRangePort] = useState(false) const [serverEnabled, setServerEnabled] = useAtom(serverEnabledAtom) const showing = useAtomValue(showRightSideBarAtom) const activeModelParams = useAtomValue(getActiveThreadModelParamsAtom) const modelEngineParams = toSettingParams(activeModelParams) - const componentDataEngineSetting = getConfigurationsData(modelEngineParams) const { openServerLog, clearServerLog } = useServerLog() - const { activeModel, startModel, stateModel } = useActiveModel() + const { startModel, stateModel } = useActiveModel() const [selectedModel] = useAtom(selectedModelAtom) const [isCorsEnabled, setIsCorsEnabled] = useAtom(corsEnabledAtom) @@ -77,6 +78,15 @@ const LocalServerScreen = () => { const [firstTimeVisitAPIServer, setFirstTimeVisitAPIServer] = useState(false) + const handleChangePort = (value: any) => { + if (Number(value) <= 0 || Number(value) >= 65536) { + setErrorRangePort(true) + } else { + setErrorRangePort(false) + } + setPort(value) + } + useEffect(() => { if ( localStorage.getItem(FIRST_TIME_VISIT_API_SERVER) === null || @@ -87,6 +97,10 @@ const LocalServerScreen = () => { } }, [firstTimeVisitAPIServer]) + useEffect(() => { + handleChangePort(port) + }, []) + return (
{/* Left SideBar */} @@ -102,7 +116,7 @@ const LocalServerScreen = () => {
+ {errorRangePort && ( +

{`The port range should be from 0 to 65536`}

+ )}