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
acacc0a4
Commit
acacc0a4
authored
Mar 05, 2024
by
StyleZhang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
service
parent
b2ae7089
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
0 deletions
+25
-0
hooks.ts
web/app/components/base/features/hooks.ts
+4
-0
hooks.ts
web/app/components/workflow/hooks.ts
+21
-0
No files found.
web/app/components/base/features/hooks.ts
View file @
acacc0a4
...
...
@@ -10,3 +10,7 @@ export function useFeatures<T>(selector: (state: FeatureStoreState) => T): T {
return
useStore
(
store
,
selector
)
}
export
function
useFeaturesStore
()
{
return
useContext
(
FeaturesContext
)
}
web/app/components/workflow/hooks.ts
View file @
acacc0a4
...
...
@@ -23,6 +23,8 @@ import type {
import
{
NODES_INITIAL_DATA
}
from
'./constants'
import
{
getLayoutByDagre
}
from
'./utils'
import
{
useStore
}
from
'./store'
import
{
syncWorkflowDraft
}
from
'@/service/workflow'
import
{
useFeaturesStore
}
from
'@/app/components/base/features/hooks'
export
const
useNodesInitialData
=
()
=>
{
const
{
t
}
=
useTranslation
()
...
...
@@ -38,6 +40,25 @@ export const useWorkflow = () => {
const
store
=
useStoreApi
()
const
reactFlow
=
useReactFlow
()
const
nodesInitialData
=
useNodesInitialData
()
const
featuresStore
=
useFeaturesStore
()
const
handleSyncWorkflowDraft
=
useCallback
(()
=>
{
const
{
getNodes
,
edges
,
}
=
store
.
getState
()
syncWorkflowDraft
({
url
:
`/apps/
${
''
}
/workflows/draft`
,
params
:
{
graph
:
{
nodes
:
getNodes
(),
edges
,
},
features
:
{},
},
})
},
[
store
])
const
handleLayout
=
useCallback
(
async
()
=>
{
const
{
...
...
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