Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
赵月辉
/
fastgpt-migrated
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Unverified
Commit
67445b40
authored
Aug 27, 2024
by
heheer
Committed by
GitHub
Aug 27, 2024
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: global variable key repeat & value type (#2540)
parent
d3731d22
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
43 additions
and
7 deletions
+43
-7
packages/global/core/app/type.d.ts
+6
-1
packages/web/i18n/en/common.json
+1
-0
packages/web/i18n/zh/common.json
+1
-0
projects/app/src/components/core/app/VariableEdit.tsx
+34
-2
projects/app/src/web/core/workflow/utils.ts
+1
-4
No files found.
packages/global/core/app/type.d.ts
View file @
67445b40
import
type
{
FlowNodeTemplateType
,
StoreNodeItemType
}
from
'../workflow/type/node'
;
import
type
{
FlowNodeTemplateType
,
StoreNodeItemType
}
from
'../workflow/type/node'
;
import
{
AppTypeEnum
}
from
'./constants'
;
import
{
AppTypeEnum
}
from
'./constants'
;
import
{
PermissionTypeEnum
}
from
'../../support/permission/constant'
;
import
{
PermissionTypeEnum
}
from
'../../support/permission/constant'
;
import
{
NodeInputKeyEnum
,
VariableInputEnum
}
from
'../workflow/constants'
;
import
{
NodeInputKeyEnum
,
VariableInputEnum
,
WorkflowIOValueTypeEnum
}
from
'../workflow/constants'
;
import
{
SelectedDatasetType
}
from
'../workflow/api'
;
import
{
SelectedDatasetType
}
from
'../workflow/api'
;
import
{
DatasetSearchModeEnum
}
from
'../dataset/constants'
;
import
{
DatasetSearchModeEnum
}
from
'../dataset/constants'
;
import
{
TeamTagSchema
as
TeamTagsSchemaType
}
from
'@fastgpt/global/support/user/team/type.d'
;
import
{
TeamTagSchema
as
TeamTagsSchemaType
}
from
'@fastgpt/global/support/user/team/type.d'
;
...
@@ -111,6 +115,7 @@ export type VariableItemType = {
...
@@ -111,6 +115,7 @@ export type VariableItemType = {
required
:
boolean
;
required
:
boolean
;
maxLen
:
number
;
maxLen
:
number
;
enums
:
{
value
:
string
}[];
enums
:
{
value
:
string
}[];
valueType
:
WorkflowIOValueTypeEnum
;
};
};
// tts
// tts
export
type
AppTTSConfigType
=
{
export
type
AppTTSConfigType
=
{
...
...
packages/web/i18n/en/common.json
View file @
67445b40
...
@@ -914,6 +914,7 @@
...
@@ -914,6 +914,7 @@
"add option"
:
"Add option"
,
"add option"
:
"Add option"
,
"input type"
:
"Text"
,
"input type"
:
"Text"
,
"key"
:
"Variable key"
,
"key"
:
"Variable key"
,
"key already exists"
:
"Key already exist"
,
"key is required"
:
"Variable key is required"
,
"key is required"
:
"Variable key is required"
,
"select type"
:
"Dropdown single select"
,
"select type"
:
"Dropdown single select"
,
"text max length"
:
"Maximum length"
,
"text max length"
:
"Maximum length"
,
...
...
packages/web/i18n/zh/common.json
View file @
67445b40
...
@@ -914,6 +914,7 @@
...
@@ -914,6 +914,7 @@
"add option"
:
"添加选项"
,
"add option"
:
"添加选项"
,
"input type"
:
"文本"
,
"input type"
:
"文本"
,
"key"
:
"变量 key"
,
"key"
:
"变量 key"
,
"key already exists"
:
"Key 已经存在"
,
"key is required"
:
"变量 key 是必须的"
,
"key is required"
:
"变量 key 是必须的"
,
"select type"
:
"下拉单选"
,
"select type"
:
"下拉单选"
,
"text max length"
:
"最大长度"
,
"text max length"
:
"最大长度"
,
...
...
projects/app/src/components/core/app/VariableEdit.tsx
View file @
67445b40
...
@@ -23,7 +23,11 @@ import {
...
@@ -23,7 +23,11 @@ import {
useDisclosure
useDisclosure
}
from
'@chakra-ui/react'
;
}
from
'@chakra-ui/react'
;
import
{
SmallAddIcon
}
from
'@chakra-ui/icons'
;
import
{
SmallAddIcon
}
from
'@chakra-ui/icons'
;
import
{
VariableInputEnum
,
variableMap
}
from
'@fastgpt/global/core/workflow/constants'
;
import
{
VariableInputEnum
,
variableMap
,
WorkflowIOValueTypeEnum
}
from
'@fastgpt/global/core/workflow/constants'
;
import
type
{
VariableItemType
}
from
'@fastgpt/global/core/app/type.d'
;
import
type
{
VariableItemType
}
from
'@fastgpt/global/core/app/type.d'
;
import
MyIcon
from
'@fastgpt/web/components/common/Icon'
;
import
MyIcon
from
'@fastgpt/web/components/common/Icon'
;
import
{
useForm
}
from
'react-hook-form'
;
import
{
useForm
}
from
'react-hook-form'
;
...
@@ -310,6 +314,27 @@ const VariableEdit = ({
...
@@ -310,6 +314,27 @@ const VariableEdit = ({
return
;
return
;
}
}
}
}
// check repeat key
const
existingVariable
=
variables
.
find
(
(
item
)
=>
item
.
key
===
variable
.
key
&&
item
.
id
!==
variable
.
id
);
if
(
existingVariable
)
{
toast
({
status
:
'warning'
,
title
:
t
(
'common:core.module.variable.key already exists'
)
});
return
;
}
// set valuetype based on variable.type
variable
.
valueType
=
valueTypeMap
[
variable
.
type
];
// set default required value based on variableType
if
(
variable
.
type
===
VariableInputEnum
.
custom
)
{
variable
.
required
=
false
;
}
const
onChangeVariable
=
[...
variables
];
const
onChangeVariable
=
[...
variables
];
// update
// update
if
(
variable
.
id
)
{
if
(
variable
.
id
)
{
...
@@ -344,9 +369,16 @@ export const defaultVariable: VariableItemType = {
...
@@ -344,9 +369,16 @@ export const defaultVariable: VariableItemType = {
type
:
VariableInputEnum
.
input
,
type
:
VariableInputEnum
.
input
,
required
:
true
,
required
:
true
,
maxLen
:
50
,
maxLen
:
50
,
enums
:
[{
value
:
''
}]
enums
:
[{
value
:
''
}],
valueType
:
WorkflowIOValueTypeEnum
.
string
};
};
export
const
addVariable
=
()
=>
{
export
const
addVariable
=
()
=>
{
const
newVariable
=
{
...
defaultVariable
,
key
:
''
,
id
:
''
};
const
newVariable
=
{
...
defaultVariable
,
key
:
''
,
id
:
''
};
return
newVariable
;
return
newVariable
;
};
};
const
valueTypeMap
=
{
[
VariableInputEnum
.
input
]:
WorkflowIOValueTypeEnum
.
string
,
[
VariableInputEnum
.
select
]:
WorkflowIOValueTypeEnum
.
string
,
[
VariableInputEnum
.
textarea
]:
WorkflowIOValueTypeEnum
.
string
,
[
VariableInputEnum
.
custom
]:
WorkflowIOValueTypeEnum
.
any
};
projects/app/src/web/core/workflow/utils.ts
View file @
67445b40
...
@@ -374,10 +374,7 @@ export const getWorkflowGlobalVariables = ({
...
@@ -374,10 +374,7 @@ export const getWorkflowGlobalVariables = ({
systemConfigNode
:
getGuideModule
(
nodes
),
systemConfigNode
:
getGuideModule
(
nodes
),
isPublicFetch
:
true
isPublicFetch
:
true
})?.
variables
||
[]
})?.
variables
||
[]
).
map
((
item
)
=>
({
);
...
item
,
valueType
:
WorkflowIOValueTypeEnum
.
any
}));
const
systemVariables
=
getSystemVariables
(
t
);
const
systemVariables
=
getSystemVariables
(
t
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment