浏览代码

fix: remove unnecessary credentials of custom tool (#2621)

tags/0.5.8
Yeuoly 1年前
父节点
当前提交
57ffecd0e5
没有帐户链接到提交者的电子邮件

+ 7
- 0
web/app/components/tools/edit-custom-collection-modal/index.tsx 查看文件

const handleSave = () => { const handleSave = () => {
const postData = clone(customCollection) const postData = clone(customCollection)
delete postData.tools delete postData.tools

if (postData.credentials.auth_type === AuthType.none) {
delete postData.credentials.api_key_header
delete postData.credentials.api_key_header_prefix
delete postData.credentials.api_key_value
}

if (isAdd) { if (isAdd) {
onAdd?.(postData) onAdd?.(postData)
return return

+ 8
- 1
web/app/components/tools/edit-custom-collection-modal/test-api.tsx 查看文件

import { useContext } from 'use-context-selector' import { useContext } from 'use-context-selector'
import { Settings01 } from '../../base/icons/src/vender/line/general' import { Settings01 } from '../../base/icons/src/vender/line/general'
import ConfigCredentials from './config-credentials' import ConfigCredentials from './config-credentials'
import type { Credential, CustomCollectionBackend, CustomParamSchema } from '@/app/components/tools/types'
import { AuthType, type Credential, type CustomCollectionBackend, type CustomParamSchema } from '@/app/components/tools/types'
import Button from '@/app/components/base/button' import Button from '@/app/components/base/button'
import Drawer from '@/app/components/base/drawer-plus' import Drawer from '@/app/components/base/drawer-plus'
import I18n from '@/context/i18n' import I18n from '@/context/i18n'
const { operation_id: toolName, parameters } = tool const { operation_id: toolName, parameters } = tool
const [parametersValue, setParametersValue] = useState<Record<string, string>>({}) const [parametersValue, setParametersValue] = useState<Record<string, string>>({})
const handleTest = async () => { const handleTest = async () => {
// clone test schema
const credentials = JSON.parse(JSON.stringify(tempCredential)) as Credential
if (credentials.auth_type === AuthType.none) {
delete credentials.api_key_header_prefix
delete credentials.api_key_header
delete credentials.api_key_value
}
const data = { const data = {
tool_name: toolName, tool_name: toolName,
credentials: tempCredential, credentials: tempCredential,

正在加载...
取消
保存