mirror of
https://github.com/labring/FastGPT.git
synced 2025-07-27 08:25:07 +00:00
fix: add http params focus & ui (#2611)
This commit is contained in:
@@ -10,6 +10,7 @@ type Props<ValueType = string> = Omit<GridProps, 'onChange'> & {
|
|||||||
size?: 'sm' | 'md' | 'lg';
|
size?: 'sm' | 'md' | 'lg';
|
||||||
inlineStyles?: FlexProps;
|
inlineStyles?: FlexProps;
|
||||||
activeColor?: string;
|
activeColor?: string;
|
||||||
|
defaultColor?: string;
|
||||||
onChange: (value: ValueType) => void;
|
onChange: (value: ValueType) => void;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -18,6 +19,7 @@ const LightRowTabs = <ValueType = string,>({
|
|||||||
size = 'md',
|
size = 'md',
|
||||||
value,
|
value,
|
||||||
activeColor = 'primary.600',
|
activeColor = 'primary.600',
|
||||||
|
defaultColor = 'transparent',
|
||||||
onChange,
|
onChange,
|
||||||
inlineStyles,
|
inlineStyles,
|
||||||
...props
|
...props
|
||||||
@@ -63,7 +65,8 @@ const LightRowTabs = <ValueType = string,>({
|
|||||||
py={sizeMap.inlineP}
|
py={sizeMap.inlineP}
|
||||||
alignItems={'center'}
|
alignItems={'center'}
|
||||||
justifyContent={'center'}
|
justifyContent={'center'}
|
||||||
borderBottom={'2px solid transparent'}
|
borderBottom={'2px solid'}
|
||||||
|
borderColor={defaultColor}
|
||||||
px={3}
|
px={3}
|
||||||
whiteSpace={'nowrap'}
|
whiteSpace={'nowrap'}
|
||||||
{...(value === item.value
|
{...(value === item.value
|
||||||
|
@@ -106,6 +106,7 @@ export default function Editor({
|
|||||||
cursor={'text'}
|
cursor={'text'}
|
||||||
color={'myGray.700'}
|
color={'myGray.700'}
|
||||||
bg={focus ? 'white' : bg}
|
bg={focus ? 'white' : bg}
|
||||||
|
borderRadius={'md'}
|
||||||
>
|
>
|
||||||
<LexicalComposer initialConfig={initialConfig} key={key}>
|
<LexicalComposer initialConfig={initialConfig} key={key}>
|
||||||
<PlainTextPlugin
|
<PlainTextPlugin
|
||||||
|
@@ -77,10 +77,7 @@ export default function VariableLabelPickerPlugin({
|
|||||||
onSelectOption={onSelectOption}
|
onSelectOption={onSelectOption}
|
||||||
triggerFn={checkForTriggerMatch}
|
triggerFn={checkForTriggerMatch}
|
||||||
options={variableFilter(variables, queryString || '')}
|
options={variableFilter(variables, queryString || '')}
|
||||||
menuRenderFn={(
|
menuRenderFn={(anchorElementRef, { selectedIndex, selectOptionAndCleanUp }) => {
|
||||||
anchorElementRef,
|
|
||||||
{ selectedIndex, selectOptionAndCleanUp, setHighlightedIndex }
|
|
||||||
) => {
|
|
||||||
if (anchorElementRef.current == null) {
|
if (anchorElementRef.current == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@@ -858,6 +858,7 @@
|
|||||||
},
|
},
|
||||||
"http": {
|
"http": {
|
||||||
"Add props": "Add parameters",
|
"Add props": "Add parameters",
|
||||||
|
"Add props_and_tips": "Add parameter, enter \"/\" to call variable list",
|
||||||
"AppId": "Application ID",
|
"AppId": "Application ID",
|
||||||
"AppSecret": "AppSecret",
|
"AppSecret": "AppSecret",
|
||||||
"ChatId": "Current chat ID",
|
"ChatId": "Current chat ID",
|
||||||
@@ -866,8 +867,10 @@
|
|||||||
"Key already exists": "Key already exists",
|
"Key already exists": "Key already exists",
|
||||||
"Key cannot be empty": "Parameter name cannot be empty",
|
"Key cannot be empty": "Parameter name cannot be empty",
|
||||||
"Props name": "Parameter name",
|
"Props name": "Parameter name",
|
||||||
|
"Props name_and_tips": "Parameter name, enter \"/\" to call variables list",
|
||||||
"Props tip": "Can set HTTP request related parameters\nCan use / to call variables, currently available variables:\n{{variable}}",
|
"Props tip": "Can set HTTP request related parameters\nCan use / to call variables, currently available variables:\n{{variable}}",
|
||||||
"Props value": "Parameter value",
|
"Props value": "Parameter value",
|
||||||
|
"Props value_and_tips": "Parameter value, enter \"/\" to call variables list",
|
||||||
"ResponseChatItemId": "AI response ID",
|
"ResponseChatItemId": "AI response ID",
|
||||||
"Url and params have been split": "Path parameters have been automatically added to Params",
|
"Url and params have been split": "Path parameters have been automatically added to Params",
|
||||||
"curl import": "curl import",
|
"curl import": "curl import",
|
||||||
|
@@ -58,9 +58,6 @@
|
|||||||
"greater_than": "greater than",
|
"greater_than": "greater than",
|
||||||
"greater_than_or_equal_to": "Greater than or equal to",
|
"greater_than_or_equal_to": "Greater than or equal to",
|
||||||
"greeting": "greet",
|
"greeting": "greet",
|
||||||
"http": {
|
|
||||||
"body_none": "This request has no body parameters."
|
|
||||||
},
|
|
||||||
"http_raw_response_description": "The raw response of the HTTP request. \nOnly string or JSON type response data can be accepted.",
|
"http_raw_response_description": "The raw response of the HTTP request. \nOnly string or JSON type response data can be accepted.",
|
||||||
"http_request": "HTTP request",
|
"http_request": "HTTP request",
|
||||||
"http_request_error_info": "HTTP request error information, returns empty when successful",
|
"http_request_error_info": "HTTP request error information, returns empty when successful",
|
||||||
|
@@ -858,6 +858,7 @@
|
|||||||
},
|
},
|
||||||
"http": {
|
"http": {
|
||||||
"Add props": "添加参数",
|
"Add props": "添加参数",
|
||||||
|
"Add props_and_tips": "添加参数,输入“/”唤起变量列表",
|
||||||
"AppId": "应用 ID",
|
"AppId": "应用 ID",
|
||||||
"AppSecret": "AppSecret",
|
"AppSecret": "AppSecret",
|
||||||
"ChatId": "当前对话 ID",
|
"ChatId": "当前对话 ID",
|
||||||
@@ -866,8 +867,10 @@
|
|||||||
"Key already exists": "Key 已经存在",
|
"Key already exists": "Key 已经存在",
|
||||||
"Key cannot be empty": "参数名不能为空",
|
"Key cannot be empty": "参数名不能为空",
|
||||||
"Props name": "参数名",
|
"Props name": "参数名",
|
||||||
|
"Props name_and_tips": "参数名,输入”/“唤起变量列表",
|
||||||
"Props tip": "可以设置 HTTP 请求的相关参数\n可通过输入 / 来调用变量,当前可使用变量:\n{{variable}}",
|
"Props tip": "可以设置 HTTP 请求的相关参数\n可通过输入 / 来调用变量,当前可使用变量:\n{{variable}}",
|
||||||
"Props value": "参数值",
|
"Props value": "参数值",
|
||||||
|
"Props value_and_tips": "参数值,输入“/”唤起变量列表",
|
||||||
"ResponseChatItemId": "AI 回复的 ID",
|
"ResponseChatItemId": "AI 回复的 ID",
|
||||||
"Url and params have been split": "路径参数已被自动加入 Params 中",
|
"Url and params have been split": "路径参数已被自动加入 Params 中",
|
||||||
"curl import": "cURL 导入",
|
"curl import": "cURL 导入",
|
||||||
|
@@ -58,9 +58,6 @@
|
|||||||
"greater_than": "大于",
|
"greater_than": "大于",
|
||||||
"greater_than_or_equal_to": "大于等于",
|
"greater_than_or_equal_to": "大于等于",
|
||||||
"greeting": "打招呼",
|
"greeting": "打招呼",
|
||||||
"http": {
|
|
||||||
"body_none": "该请求没有 Body 体"
|
|
||||||
},
|
|
||||||
"http_raw_response_description": "HTTP请求的原始响应。只能接受字符串或JSON类型响应数据。",
|
"http_raw_response_description": "HTTP请求的原始响应。只能接受字符串或JSON类型响应数据。",
|
||||||
"http_request": "HTTP 请求",
|
"http_request": "HTTP 请求",
|
||||||
"http_request_error_info": "HTTP请求错误信息,成功时返回空",
|
"http_request_error_info": "HTTP请求错误信息,成功时返回空",
|
||||||
|
@@ -289,7 +289,8 @@ export function RenderHttpProps({
|
|||||||
</Flex>
|
</Flex>
|
||||||
<LightRowTabs<TabEnum>
|
<LightRowTabs<TabEnum>
|
||||||
width={'100%'}
|
width={'100%'}
|
||||||
mb={selectedTab === TabEnum.body ? 1 : 2}
|
mb={2}
|
||||||
|
defaultColor={'myGray.250'}
|
||||||
list={[
|
list={[
|
||||||
{ label: <RenderPropsItem text="Params" num={paramsLength} />, value: TabEnum.params },
|
{ label: <RenderPropsItem text="Params" num={paramsLength} />, value: TabEnum.params },
|
||||||
...(!['GET', 'DELETE'].includes(requestMethods)
|
...(!['GET', 'DELETE'].includes(requestMethods)
|
||||||
@@ -298,7 +299,8 @@ export function RenderHttpProps({
|
|||||||
label: (
|
label: (
|
||||||
<Flex alignItems={'center'}>
|
<Flex alignItems={'center'}>
|
||||||
Body
|
Body
|
||||||
{jsonBody?.value && <Box ml={1}>✅</Box>}
|
{(jsonBody?.value || !!formBody?.value?.length) &&
|
||||||
|
contentType?.value !== ContentTypes.none && <Box ml={1}>✅</Box>}
|
||||||
</Flex>
|
</Flex>
|
||||||
),
|
),
|
||||||
value: TabEnum.body
|
value: TabEnum.body
|
||||||
@@ -313,7 +315,7 @@ export function RenderHttpProps({
|
|||||||
value={selectedTab}
|
value={selectedTab}
|
||||||
onChange={setSelectedTab}
|
onChange={setSelectedTab}
|
||||||
/>
|
/>
|
||||||
<Box bg={'white'} borderRadius={'md'} minW={'560px'}>
|
<Box minW={'560px'}>
|
||||||
{params &&
|
{params &&
|
||||||
headers &&
|
headers &&
|
||||||
jsonBody &&
|
jsonBody &&
|
||||||
@@ -494,7 +496,13 @@ const RenderForm = ({
|
|||||||
|
|
||||||
const Render = useMemo(() => {
|
const Render = useMemo(() => {
|
||||||
return (
|
return (
|
||||||
<Box borderRadius={'md'} overflow={'hidden'} borderWidth={'1px'} borderBottom={'none'}>
|
<Box
|
||||||
|
borderRadius={'md'}
|
||||||
|
overflow={'hidden'}
|
||||||
|
borderWidth={'1px'}
|
||||||
|
borderBottom={'none'}
|
||||||
|
bg={'white'}
|
||||||
|
>
|
||||||
<TableContainer overflowY={'visible'} overflowX={'unset'}>
|
<TableContainer overflowY={'visible'} overflowX={'unset'}>
|
||||||
<Table>
|
<Table>
|
||||||
<Thead>
|
<Thead>
|
||||||
@@ -508,16 +516,24 @@ const RenderForm = ({
|
|||||||
</Tr>
|
</Tr>
|
||||||
</Thead>
|
</Thead>
|
||||||
<Tbody>
|
<Tbody>
|
||||||
{list.map((item, index) => (
|
{[...list, { key: '', value: '', label: '' }].map((item, index) => (
|
||||||
<Tr key={`${input.key}${index}`}>
|
<Tr key={`${input.key}${index}`}>
|
||||||
<Td p={0} w={'50%'}>
|
<Td p={0} w={'50%'} borderRight={'1px solid'} borderColor={'myGray.200'}>
|
||||||
<HttpInput
|
<HttpInput
|
||||||
placeholder={t('common:core.module.http.Props name')}
|
placeholder={
|
||||||
|
index !== list.length
|
||||||
|
? t('common:core.module.http.Props name_and_tips')
|
||||||
|
: t('common:core.module.http.Add props_and_tips')
|
||||||
|
}
|
||||||
value={item.key}
|
value={item.key}
|
||||||
variableLabels={variables}
|
variableLabels={variables}
|
||||||
variables={variables}
|
variables={variables}
|
||||||
onBlur={(val) => {
|
onBlur={(val) => {
|
||||||
handleKeyChange(index, val);
|
handleKeyChange(index, val);
|
||||||
|
if (index === list.length) {
|
||||||
|
handleAddNewProps(val);
|
||||||
|
setUpdateTrigger((prev) => !prev);
|
||||||
|
}
|
||||||
}}
|
}}
|
||||||
updateTrigger={updateTrigger}
|
updateTrigger={updateTrigger}
|
||||||
/>
|
/>
|
||||||
@@ -525,7 +541,11 @@ const RenderForm = ({
|
|||||||
<Td p={0} w={'50%'}>
|
<Td p={0} w={'50%'}>
|
||||||
<Box display={'flex'} alignItems={'center'}>
|
<Box display={'flex'} alignItems={'center'}>
|
||||||
<HttpInput
|
<HttpInput
|
||||||
placeholder={t('common:core.module.http.Props value')}
|
placeholder={
|
||||||
|
index !== list.length
|
||||||
|
? t('common:core.module.http.Props value_and_tips')
|
||||||
|
: ''
|
||||||
|
}
|
||||||
value={item.value}
|
value={item.value}
|
||||||
variables={variables}
|
variables={variables}
|
||||||
variableLabels={variables}
|
variableLabels={variables}
|
||||||
@@ -538,40 +558,22 @@ const RenderForm = ({
|
|||||||
setShouldUpdateNode(true);
|
setShouldUpdateNode(true);
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
<MyIcon
|
{index !== list.length && (
|
||||||
name={'delete'}
|
<MyIcon
|
||||||
cursor={'pointer'}
|
name={'delete'}
|
||||||
_hover={{ color: 'red.600' }}
|
cursor={'pointer'}
|
||||||
w={'14px'}
|
_hover={{ color: 'red.600' }}
|
||||||
onClick={() => {
|
w={'14px'}
|
||||||
setList((prevlist) => prevlist.filter((val) => val.key !== item.key));
|
onClick={() => {
|
||||||
setShouldUpdateNode(true);
|
setList((prevlist) => prevlist.filter((val) => val.key !== item.key));
|
||||||
}}
|
setShouldUpdateNode(true);
|
||||||
/>
|
}}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
</Box>
|
</Box>
|
||||||
</Td>
|
</Td>
|
||||||
</Tr>
|
</Tr>
|
||||||
))}
|
))}
|
||||||
<Tr>
|
|
||||||
<Td p={0} w={'50%'}>
|
|
||||||
<HttpInput
|
|
||||||
placeholder={t('common:core.module.http.Add props')}
|
|
||||||
value={''}
|
|
||||||
variableLabels={variables}
|
|
||||||
variables={variables}
|
|
||||||
updateTrigger={updateTrigger}
|
|
||||||
onBlur={(val) => {
|
|
||||||
handleAddNewProps(val);
|
|
||||||
setUpdateTrigger((prev) => !prev);
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
</Td>
|
|
||||||
<Td p={0} w={'50%'}>
|
|
||||||
<Box display={'flex'} alignItems={'center'}>
|
|
||||||
<HttpInput />
|
|
||||||
</Box>
|
|
||||||
</Td>
|
|
||||||
</Tr>
|
|
||||||
</Tbody>
|
</Tbody>
|
||||||
</Table>
|
</Table>
|
||||||
</TableContainer>
|
</TableContainer>
|
||||||
@@ -662,19 +664,6 @@ const RenderBody = ({
|
|||||||
</Box>
|
</Box>
|
||||||
))}
|
))}
|
||||||
</Flex>
|
</Flex>
|
||||||
{typeInput?.value === ContentTypes.none && (
|
|
||||||
<Box
|
|
||||||
px={4}
|
|
||||||
py={12}
|
|
||||||
bg={'white'}
|
|
||||||
color={'myGray.400'}
|
|
||||||
borderRadius={'6px'}
|
|
||||||
border={'1px solid'}
|
|
||||||
borderColor={'myGray.200'}
|
|
||||||
>
|
|
||||||
{t('workflow:http.body_none')}
|
|
||||||
</Box>
|
|
||||||
)}
|
|
||||||
{(typeInput?.value === ContentTypes.formData ||
|
{(typeInput?.value === ContentTypes.formData ||
|
||||||
typeInput?.value === ContentTypes.xWwwFormUrlencoded) && (
|
typeInput?.value === ContentTypes.xWwwFormUrlencoded) && (
|
||||||
<RenderForm nodeId={nodeId} input={formBody} variables={variables} />
|
<RenderForm nodeId={nodeId} input={formBody} variables={variables} />
|
||||||
|
Reference in New Issue
Block a user