Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
D
dify
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ai-tech
dify
Commits
a0315074
Commit
a0315074
authored
Mar 12, 2024
by
Joel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: code show result
parent
90e01355
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
22 additions
and
3 deletions
+22
-3
swr-initor.tsx
web/app/components/swr-initor.tsx
+1
-0
use-one-step-run.ts
...components/workflow/nodes/_base/hooks/use-one-step-run.ts
+14
-2
panel.tsx
web/app/components/workflow/nodes/code/panel.tsx
+3
-1
use-config.ts
web/app/components/workflow/nodes/code/use-config.ts
+4
-0
No files found.
web/app/components/swr-initor.tsx
View file @
a0315074
...
...
@@ -32,6 +32,7 @@ const SwrInitor = ({
?
(
<
SWRConfig
value=
{
{
shouldRetryOnError
:
false
,
revalidateOnFocus
:
false
,
}
}
>
{
children
}
</
SWRConfig
>
...
...
web/app/components/workflow/nodes/_base/hooks/use-one-step-run.ts
View file @
a0315074
...
...
@@ -19,6 +19,7 @@ const useOneStepRun = <T>({ id, data, defaultRunInputData, isInvalid = () => tru
const
appId
=
useAppStore
.
getState
().
appDetail
?.
id
const
[
runInputData
,
setRunInputData
]
=
useState
<
Record
<
string
,
any
>>
(
defaultRunInputData
||
{})
const
[
runResult
,
setRunResult
]
=
useState
<
any
>
(
null
)
const
{
handleNodeDataUpdate
}:
{
handleNodeDataUpdate
:
(
data
:
any
)
=>
void
}
=
useWorkflow
()
const
isShowSingleRun
=
data
.
_isSingleRun
...
...
@@ -32,6 +33,7 @@ const useOneStepRun = <T>({ id, data, defaultRunInputData, isInvalid = () => tru
})
}
const
runningStatus
=
data
.
_singleRunningStatus
||
NodeRunningStatus
.
NotStart
const
isCompleted
=
runningStatus
===
NodeRunningStatus
.
Succeeded
||
runningStatus
===
NodeRunningStatus
.
Failed
const
handleRun
=
async
()
=>
{
if
(
!
isInvalid
())
return
...
...
@@ -42,10 +44,17 @@ const useOneStepRun = <T>({ id, data, defaultRunInputData, isInvalid = () => tru
_singleRunningStatus
:
NodeRunningStatus
.
Running
,
},
})
let
res
:
any
try
{
const
res
=
await
singleNodeRun
(
appId
!
,
id
,
{
inputs
:
runInputData
})
res
=
await
singleNodeRun
(
appId
!
,
id
,
{
inputs
:
runInputData
})
as
any
if
(
res
.
error
)
throw
new
Error
(
res
.
error
)
}
catch
(
e
)
{
catch
(
e
:
any
)
{
Toast
.
notify
({
type
:
'error'
,
message
:
e
.
toString
(),
})
handleNodeDataUpdate
({
id
,
data
:
{
...
...
@@ -55,6 +64,7 @@ const useOneStepRun = <T>({ id, data, defaultRunInputData, isInvalid = () => tru
})
return
false
}
setRunResult
(
res
)
handleNodeDataUpdate
({
id
,
data
:
{
...
...
@@ -101,10 +111,12 @@ const useOneStepRun = <T>({ id, data, defaultRunInputData, isInvalid = () => tru
hideSingleRun
,
toVarInputs
,
runningStatus
,
isCompleted
,
handleRun
,
handleStop
,
runInputData
,
setRunInputData
,
runResult
,
}
}
...
...
web/app/components/workflow/nodes/code/panel.tsx
View file @
a0315074
...
...
@@ -47,10 +47,12 @@ const Panel: FC<NodePanelProps<CodeNodeType>> = ({
runningStatus
,
handleRun
,
handleStop
,
runResult
,
varInputs
,
inputVarValues
,
setInputVarValues
,
}
=
useConfig
(
id
,
data
)
return
(
<
div
className=
'mt-2'
>
<
div
className=
'px-4 pb-4 space-y-4'
>
...
...
@@ -110,9 +112,9 @@ const Panel: FC<NodePanelProps<CodeNodeType>> = ({
runningStatus=
{
runningStatus
}
onRun=
{
handleRun
}
onStop=
{
handleStop
}
result=
{
<
span
className=
'text-gray-900'
>
{
JSON
.
stringify
(
runResult
,
null
,
2
)
}
</
span
>
}
/>
)
}
</
div
>
)
}
...
...
web/app/components/workflow/nodes/code/use-config.ts
View file @
a0315074
...
...
@@ -38,10 +38,12 @@ const useConfig = (id: string, payload: CodeNodeType) => {
hideSingleRun
,
toVarInputs
,
runningStatus
,
isCompleted
,
handleRun
,
handleStop
,
runInputData
,
setRunInputData
,
runResult
,
}
=
useOneStepRun
<
CodeNodeType
>
({
id
,
data
:
inputs
,
...
...
@@ -74,11 +76,13 @@ const useConfig = (id: string, payload: CodeNodeType) => {
isShowSingleRun
,
hideSingleRun
,
runningStatus
,
isCompleted
,
handleRun
,
handleStop
,
varInputs
,
inputVarValues
,
setInputVarValues
,
runResult
,
}
}
...
...
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