diff --git a/client/public/docs/versionIntro.md b/client/public/docs/versionIntro.md index f8907c288..112dc0d73 100644 --- a/client/public/docs/versionIntro.md +++ b/client/public/docs/versionIntro.md @@ -1,6 +1,6 @@ ### Fast GPT V3.8.8 -1. 新增 - V2 版 OpenAPI,可以在任意第三方套壳 ChatGpt 项目中直接使用 FastGpt 的应用,注意!是直接。 +1. 新增 - V2 版 OpenAPI,可以在任意第三方套壳 ChatGpt 项目中直接使用 FastGpt 的应用,注意!是直接,不需要改任何代码。具体参考[API 文档中《在第三方应用中使用 FastGpt》](https://kjqvjse66l.feishu.cn/docx/DmLedTWtUoNGX8xui9ocdUEjnNh) 2. 新增 - 应用配置最大回复长度。 3. 新增 - 更多的知识库配置项:相似度、最大搜索数量、自定义空搜索结果回复。 4. 新增 - 知识库搜索测试,方便调试。 diff --git a/client/src/pages/model/components/detail/components/API.tsx b/client/src/pages/model/components/detail/components/API.tsx index c1a539dc5..40ace07b1 100644 --- a/client/src/pages/model/components/detail/components/API.tsx +++ b/client/src/pages/model/components/detail/components/API.tsx @@ -1,4 +1,4 @@ -import React, { useState } from 'react'; +import React, { useEffect, useState } from 'react'; import { Box, Divider, Flex, useTheme, Button, Skeleton, useDisclosure } from '@chakra-ui/react'; import { useCopyData } from '@/utils/tools'; import dynamic from 'next/dynamic'; @@ -8,11 +8,10 @@ const APIKeyModal = dynamic(() => import('@/components/APIKeyModal'), { ssr: true }); -const baseUrl = 'https://fastgpt.run/api/openapi'; - const API = ({ modelId }: { modelId: string }) => { const theme = useTheme(); const { copyData } = useCopyData(); + const [baseUrl, setBaseUrl] = useState('https://fastgpt.run/api/openapi'); const { isOpen: isOpenAPIModal, onOpen: onOpenAPIModal, @@ -20,6 +19,10 @@ const API = ({ modelId }: { modelId: string }) => { } = useDisclosure(); const [isLoaded, setIsLoaded] = useState(false); + useEffect(() => { + setBaseUrl(`${location.origin}/api/openapi`); + }, []); + return ( diff --git a/client/src/pages/model/components/detail/components/Settings.tsx b/client/src/pages/model/components/detail/components/Settings.tsx index 053279f54..b188a70b1 100644 --- a/client/src/pages/model/components/detail/components/Settings.tsx +++ b/client/src/pages/model/components/detail/components/Settings.tsx @@ -308,6 +308,7 @@ const Settings = ({ modelId }: { modelId: string }) => { w={'120px'} size={['sm', 'md']} isLoading={btnLoading} + isDisabled={!isOwner} onClick={async () => { try { await saveUpdateModel(); @@ -321,7 +322,7 @@ const Settings = ({ modelId }: { modelId: string }) => { } }} > - 保存 + {isOwner ? '保存' : '仅读,无法修改'} - + {isOwner && ( + + )} + diff --git a/client/src/pages/model/components/detail/index.tsx b/client/src/pages/model/components/detail/index.tsx index 5afaaad25..f537624d2 100644 --- a/client/src/pages/model/components/detail/index.tsx +++ b/client/src/pages/model/components/detail/index.tsx @@ -1,4 +1,4 @@ -import React, { useState, useEffect } from 'react'; +import React, { useState, useEffect, useMemo } from 'react'; import { useRouter } from 'next/router'; import { Box, Flex } from '@chakra-ui/react'; import { useUserStore } from '@/store/user'; @@ -28,9 +28,14 @@ enum TabEnum { const ModelDetail = ({ modelId }: { modelId: string }) => { const router = useRouter(); const { isPc } = useGlobalStore(); - const { modelDetail } = useUserStore(); + const { modelDetail, userInfo } = useUserStore(); const [currentTab, setCurrentTab] = useState<`${TabEnum}`>(TabEnum.settings); + const isOwner = useMemo( + () => modelDetail.userId === userInfo?._id, + [modelDetail.userId, userInfo?._id] + ); + useEffect(() => { window.onbeforeunload = (e) => { e.preventDefault(); @@ -67,7 +72,7 @@ const ModelDetail = ({ modelId }: { modelId: string }) => { w={['300px', '360px']} list={[ { label: '配置', id: TabEnum.settings }, - { label: '知识库', id: TabEnum.kb }, + ...(isOwner ? [{ label: '知识库', id: TabEnum.kb }] : []), { label: '分享', id: TabEnum.share }, { label: 'API', id: TabEnum.API }, { label: '立即对话', id: 'startChat' }