mirror of
https://github.com/langgenius/dify.git
synced 2026-01-14 06:07:33 +08:00
Some checks are pending
Build and Push API & Web / build (api, DIFY_API_IMAGE_NAME, linux/amd64, build-api-amd64) (push) Waiting to run
Build and Push API & Web / build (api, DIFY_API_IMAGE_NAME, linux/arm64, build-api-arm64) (push) Waiting to run
Build and Push API & Web / build (web, DIFY_WEB_IMAGE_NAME, linux/amd64, build-web-amd64) (push) Waiting to run
Build and Push API & Web / build (web, DIFY_WEB_IMAGE_NAME, linux/arm64, build-web-arm64) (push) Waiting to run
Build and Push API & Web / create-manifest (api, DIFY_API_IMAGE_NAME, merge-api-images) (push) Blocked by required conditions
Build and Push API & Web / create-manifest (web, DIFY_WEB_IMAGE_NAME, merge-web-images) (push) Blocked by required conditions
30 lines
911 B
TypeScript
30 lines
911 B
TypeScript
import {
|
|
createContext,
|
|
useRef,
|
|
} from 'react'
|
|
import {
|
|
createWorkflowStore,
|
|
} from './store'
|
|
import type { StateCreator } from 'zustand'
|
|
import type { WorkflowSliceShape } from '@/app/components/workflow-app/store/workflow/workflow-slice'
|
|
|
|
type WorkflowStore = ReturnType<typeof createWorkflowStore>
|
|
export const WorkflowContext = createContext<WorkflowStore | null>(null)
|
|
|
|
export type WorkflowProviderProps = {
|
|
children: React.ReactNode
|
|
injectWorkflowStoreSliceFn?: StateCreator<WorkflowSliceShape>
|
|
}
|
|
export const WorkflowContextProvider = ({ children, injectWorkflowStoreSliceFn }: WorkflowProviderProps) => {
|
|
const storeRef = useRef<WorkflowStore | undefined>(undefined)
|
|
|
|
if (!storeRef.current)
|
|
storeRef.current = createWorkflowStore({ injectWorkflowStoreSliceFn })
|
|
|
|
return (
|
|
<WorkflowContext.Provider value={storeRef.current}>
|
|
{children}
|
|
</WorkflowContext.Provider>
|
|
)
|
|
}
|