mirror of
https://github.com/langgenius/dify.git
synced 2026-05-06 10:28:10 +08:00
service
This commit is contained in:
@ -10,3 +10,7 @@ export function useFeatures<T>(selector: (state: FeatureStoreState) => T): T {
|
|||||||
|
|
||||||
return useStore(store, selector)
|
return useStore(store, selector)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function useFeaturesStore() {
|
||||||
|
return useContext(FeaturesContext)
|
||||||
|
}
|
||||||
|
|||||||
@ -23,6 +23,8 @@ import type {
|
|||||||
import { NODES_INITIAL_DATA } from './constants'
|
import { NODES_INITIAL_DATA } from './constants'
|
||||||
import { getLayoutByDagre } from './utils'
|
import { getLayoutByDagre } from './utils'
|
||||||
import { useStore } from './store'
|
import { useStore } from './store'
|
||||||
|
import { syncWorkflowDraft } from '@/service/workflow'
|
||||||
|
import { useFeaturesStore } from '@/app/components/base/features/hooks'
|
||||||
|
|
||||||
export const useNodesInitialData = () => {
|
export const useNodesInitialData = () => {
|
||||||
const { t } = useTranslation()
|
const { t } = useTranslation()
|
||||||
@ -38,6 +40,25 @@ export const useWorkflow = () => {
|
|||||||
const store = useStoreApi()
|
const store = useStoreApi()
|
||||||
const reactFlow = useReactFlow()
|
const reactFlow = useReactFlow()
|
||||||
const nodesInitialData = useNodesInitialData()
|
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 handleLayout = useCallback(async () => {
|
||||||
const {
|
const {
|
||||||
|
|||||||
Reference in New Issue
Block a user