mirror of
https://github.com/labring/FastGPT.git
synced 2026-04-17 02:06:41 +08:00
fix mcp header (#6105)
* fix mcp header * perf: del tip * secret type --------- Co-authored-by: archer <545436317@qq.com>
This commit is contained in:
@@ -87,9 +87,9 @@ const AuthValueDisplay = ({
|
||||
};
|
||||
|
||||
export const getSecretType = (config: HeaderSecretConfigType): HeaderSecretTypeEnum => {
|
||||
if (config.Bearer) {
|
||||
if (config.Bearer && (config.Bearer.secret || config.Bearer.value)) {
|
||||
return HeaderSecretTypeEnum.Bearer;
|
||||
} else if (config.Basic) {
|
||||
} else if (config.Basic && (config.Basic.secret || config.Basic.value)) {
|
||||
return HeaderSecretTypeEnum.Basic;
|
||||
} else if (config.customs && config.customs.length > 0) {
|
||||
return HeaderSecretTypeEnum.Custom;
|
||||
|
||||
@@ -22,6 +22,7 @@ import type { StoreNodeItemType } from '@fastgpt/global/core/workflow/type/node'
|
||||
import type { StoreEdgeItemType } from '@fastgpt/global/core/workflow/type/edge';
|
||||
import { AppErrEnum } from '@fastgpt/global/common/error/code/app';
|
||||
import { useToast } from '@fastgpt/web/hooks/useToast';
|
||||
import { AppTypeList } from '@fastgpt/global/core/app/constants';
|
||||
|
||||
const InfoModal = dynamic(() => import('./InfoModal'));
|
||||
const TagsEditModal = dynamic(() => import('./TagsEditModal'));
|
||||
@@ -184,9 +185,10 @@ const AppContextProvider = ({ children }: { children: ReactNode }) => {
|
||||
}
|
||||
);
|
||||
|
||||
const isAgent = AppTypeList.includes(appDetail.type);
|
||||
const { openConfirm: openConfirmDel, ConfirmModal: ConfirmDelModal } = useConfirm({
|
||||
content: t('app:confirm_del_app_tip', { name: appDetail.name }),
|
||||
type: 'delete'
|
||||
type: 'delete',
|
||||
content: isAgent ? t('app:confirm_del_app_tip') : t('app:confirm_del_tool_tip')
|
||||
});
|
||||
const { runAsync: deleteApp } = useRequest2(
|
||||
async () => {
|
||||
@@ -199,7 +201,7 @@ const AppContextProvider = ({ children }: { children: ReactNode }) => {
|
||||
localStorage.removeItem(`app_log_keys_${appId}`);
|
||||
});
|
||||
|
||||
router.replace(`/dashboard/agent`);
|
||||
router.replace(isAgent ? `/dashboard/agent` : `/dashboard/tool`);
|
||||
},
|
||||
successToast: t('common:delete_success'),
|
||||
errorToast: t('common:delete_failed')
|
||||
@@ -209,9 +211,9 @@ const AppContextProvider = ({ children }: { children: ReactNode }) => {
|
||||
() =>
|
||||
openConfirmDel({
|
||||
onConfirm: deleteApp,
|
||||
customContent: t('app:confirm_del_app_tip', { name: appDetail.name })
|
||||
inputConfirmText: appDetail.name
|
||||
})(),
|
||||
[appDetail.name, deleteApp, openConfirmDel, t]
|
||||
[deleteApp, openConfirmDel, appDetail.name]
|
||||
);
|
||||
|
||||
const contextValue: AppContextType = useMemo(
|
||||
|
||||
@@ -11,7 +11,12 @@ import MyBox from '@fastgpt/web/components/common/MyBox';
|
||||
import { useRequest2 } from '@fastgpt/web/hooks/useRequest';
|
||||
import { useContextSelector } from 'use-context-selector';
|
||||
import { AppListContext } from './context';
|
||||
import { AppFolderTypeList, AppTypeEnum, ToolTypeList } from '@fastgpt/global/core/app/constants';
|
||||
import {
|
||||
AppFolderTypeList,
|
||||
AppTypeEnum,
|
||||
AppTypeList,
|
||||
ToolTypeList
|
||||
} from '@fastgpt/global/core/app/constants';
|
||||
import { useFolderDrag } from '@/components/common/folder/useFolderDrag';
|
||||
import dynamic from 'next/dynamic';
|
||||
import type { EditResourceInfoFormType } from '@/components/common/Modal/EditResourceModal';
|
||||
@@ -35,7 +40,6 @@ import { ReadRoleVal } from '@fastgpt/global/support/permission/constant';
|
||||
import { useToast } from '@fastgpt/web/hooks/useToast';
|
||||
import { getWebReqUrl } from '@fastgpt/web/common/system/utils';
|
||||
import { createAppTypeMap } from '@/pageComponents/app/constants';
|
||||
import { type CreateAppType } from '@/pages/dashboard/create';
|
||||
import { useUserStore } from '@/web/support/user/useUserStore';
|
||||
import EmptyTip from '@fastgpt/web/components/common/EmptyTip';
|
||||
|
||||
@@ -183,6 +187,9 @@ const List = () => {
|
||||
>
|
||||
{hasCreatePer ? <ListCreateButton appType={appType} /> : <ForbiddenCreateButton />}
|
||||
{myApps.map((app, index) => {
|
||||
const isAgent = AppTypeList.includes(app.type);
|
||||
const isTool = ToolTypeList.includes(app.type);
|
||||
const isFolder = AppFolderTypeList.includes(app.type);
|
||||
return (
|
||||
<MyTooltip
|
||||
key={app._id}
|
||||
@@ -416,10 +423,13 @@ const List = () => {
|
||||
openConfirmDel({
|
||||
onConfirm: () => onclickDelApp(app._id),
|
||||
inputConfirmText: app.name,
|
||||
customContent:
|
||||
app.type === AppTypeEnum.folder
|
||||
? t('app:confirm_delete_folder_tip')
|
||||
: t('app:confirm_del_app_tip')
|
||||
customContent: (() => {
|
||||
if (isFolder)
|
||||
return t('app:confirm_delete_folder_tip');
|
||||
if (isAgent) return t('app:confirm_del_app_tip');
|
||||
if (isTool) return t('app:confirm_del_tool_tip');
|
||||
return t('app:confirm_del_app_tip');
|
||||
})()
|
||||
})()
|
||||
}
|
||||
]
|
||||
|
||||
@@ -38,6 +38,7 @@ import MyImage from '@fastgpt/web/components/common/Image/MyImage';
|
||||
import LeftRadio from '@fastgpt/web/components/common/Radio/LeftRadio';
|
||||
import HeaderAuthForm from '@/components/common/secret/HeaderAuthForm';
|
||||
import { getMCPTools, postCreateHttpTools, postCreateMCPTools } from '@/web/core/app/api/tool';
|
||||
import { headerValue2StoreHeader } from '@/components/common/secret/HeaderAuthConfig';
|
||||
import type { McpToolConfigType } from '@fastgpt/global/core/app/tool/mcpTool/type';
|
||||
import AppTypeCard from '@/pageComponents/app/create/AppTypeCard';
|
||||
import type { StoreSecretValueType } from '@fastgpt/global/common/secret/type';
|
||||
@@ -133,10 +134,11 @@ const CreateAppsPage = () => {
|
||||
};
|
||||
|
||||
if (appType === AppTypeEnum.mcpToolSet) {
|
||||
const headerSecret = headerValue2StoreHeader(mcpHeaderSecret || {});
|
||||
return postCreateMCPTools({
|
||||
...baseParams,
|
||||
url: mcpUrl || '',
|
||||
headerSecret: mcpHeaderSecret || {},
|
||||
headerSecret,
|
||||
toolList: (mcpToolList || []) as McpToolConfigType[]
|
||||
});
|
||||
}
|
||||
@@ -421,9 +423,10 @@ const CreateAppsPage = () => {
|
||||
h={8}
|
||||
isLoading={isGettingMCPTools}
|
||||
onClick={() => {
|
||||
const headerSecret = headerValue2StoreHeader(mcpHeaderSecret || {});
|
||||
runGetMCPTools({
|
||||
url: mcpUrl || '',
|
||||
headerSecret: mcpHeaderSecret
|
||||
headerSecret
|
||||
});
|
||||
}}
|
||||
>
|
||||
|
||||
Reference in New Issue
Block a user