From 021ec0595ddd2ad9ac1aec38b74e921478a1bc45 Mon Sep 17 00:00:00 2001 From: heheer Date: Mon, 9 Dec 2024 09:55:10 +0800 Subject: [PATCH] fix: plugin group api position & team selector optional display (#3339) --- projects/app/src/pages/account/info/index.tsx | 18 ++++++------ .../api/core/app/plugin/getPluginGroups.ts | 29 +++++++++++++++++++ projects/app/src/web/core/app/api/plugin.ts | 2 +- 3 files changed, 39 insertions(+), 10 deletions(-) create mode 100644 projects/app/src/pages/api/core/app/plugin/getPluginGroups.ts diff --git a/projects/app/src/pages/account/info/index.tsx b/projects/app/src/pages/account/info/index.tsx index 9fd4605eb8ef..595b878a82ea 100644 --- a/projects/app/src/pages/account/info/index.tsx +++ b/projects/app/src/pages/account/info/index.tsx @@ -61,10 +61,9 @@ const AiPointsModal = dynamic(() => const Info = () => { const { isPc } = useSystem(); - const { teamPlanStatus } = useUserStore(); + const { teamPlanStatus, initUserInfo } = useUserStore(); const standardPlan = teamPlanStatus?.standardConstants; const { isOpen: isOpenContact, onClose: onCloseContact, onOpen: onOpenContact } = useDisclosure(); - const { initUserInfo } = useUserStore(); useQuery(['init'], initUserInfo); @@ -112,11 +111,10 @@ const MyInfo = ({ onOpenContact }: { onOpenContact: () => void }) => { const theme = useTheme(); const { feConfigs } = useSystemStore(); const { t } = useTranslation(); - const { userInfo, updateUserInfo } = useUserStore(); + const { userInfo, updateUserInfo, teamPlanStatus } = useUserStore(); const { reset } = useForm({ defaultValues: userInfo as UserType }); - const { teamPlanStatus } = useUserStore(); const standardPlan = teamPlanStatus?.standardConstants; const { isPc } = useSystem(); const { toast } = useToast(); @@ -305,12 +303,14 @@ const MyInfo = ({ onOpenContact }: { onOpenContact: () => void }) => { )} )} - - {t('account_info:user_team_team_name')}:  - - + {feConfigs.isPlus && ( + + {t('account_info:user_team_team_name')}:  + + + - + )} {feConfigs?.isPlus && (userInfo?.team?.balance ?? 0) > 0 && ( diff --git a/projects/app/src/pages/api/core/app/plugin/getPluginGroups.ts b/projects/app/src/pages/api/core/app/plugin/getPluginGroups.ts new file mode 100644 index 000000000000..1a0fa5337f6a --- /dev/null +++ b/projects/app/src/pages/api/core/app/plugin/getPluginGroups.ts @@ -0,0 +1,29 @@ +import { NextAPI } from '@/service/middleware/entry'; +import { MongoPluginGroups } from '@fastgpt/service/core/app/plugin/pluginGroupSchema'; +import { PluginGroupSchemaType } from '@fastgpt/service/core/app/plugin/type'; +import { ApiRequestProps, ApiResponseType } from '@fastgpt/service/type/next'; + +export type getPluginGroupsQuery = {}; + +export type getPluginGroupsBody = {}; + +export type getPluginGroupsResponse = PluginGroupSchemaType[]; + +async function handler( + req: ApiRequestProps, + res: ApiResponseType +): Promise { + const pluginGroups = await MongoPluginGroups.find().sort({ groupOrder: 1 }); + + const result = pluginGroups.map((item) => ({ + groupId: item.groupId, + groupName: item.groupName, + groupAvatar: item.groupAvatar, + groupTypes: item.groupTypes, + groupOrder: item.groupOrder + })); + + return result; +} + +export default NextAPI(handler); diff --git a/projects/app/src/web/core/app/api/plugin.ts b/projects/app/src/web/core/app/api/plugin.ts index df59c69f1d28..399eef108b8d 100644 --- a/projects/app/src/web/core/app/api/plugin.ts +++ b/projects/app/src/web/core/app/api/plugin.ts @@ -42,7 +42,7 @@ export const getSystemPlugTemplates = (data: GetSystemPluginTemplatesBody) => POST('/core/app/plugin/getSystemPluginTemplates', data); export const getPluginGroups = () => - GET('/proApi/core/app/plugin/getPluginGroups'); + GET('/core/app/plugin/getPluginGroups'); export const getSystemPluginPaths = (parentId: ParentIdType) => { if (!parentId) return Promise.resolve([]);