30 lines
1.2 KiB
TypeScript
30 lines
1.2 KiB
TypeScript
/*
|
|
* @Author: ZhaoYing
|
|
* @Date: 2026-04-10 18:11:19
|
|
* @Last Modified by: ZhaoYing
|
|
* @Last Modified time: 2026-04-10 18:11:19
|
|
*/
|
|
import { create } from 'zustand'
|
|
import type { NodeCheckResult } from '@/views/Workflow/components/CheckList'
|
|
import type { ChatItem } from '@/components/Chat/types'
|
|
|
|
interface WorkflowState {
|
|
checkResults: Record<string, NodeCheckResult[]>
|
|
setCheckResults: (appId: string, results: NodeCheckResult[]) => void
|
|
getCheckResults: (appId: string) => NodeCheckResult[]
|
|
chatHistoryMap: Record<string, ChatItem[]>
|
|
setChatHistory: (conversationId: string, history: ChatItem[]) => void
|
|
getChatHistory: (conversationId: string) => ChatItem[]
|
|
}
|
|
|
|
export const useWorkflowStore = create<WorkflowState>((set, get) => ({
|
|
checkResults: {},
|
|
setCheckResults: (appId, results) =>
|
|
set(state => ({ checkResults: { ...state.checkResults, [appId]: results } })),
|
|
getCheckResults: (appId) => get().checkResults[appId] ?? [],
|
|
chatHistoryMap: {},
|
|
setChatHistory: (conversationId, history) =>
|
|
set(state => ({ chatHistoryMap: { ...state.chatHistoryMap, [conversationId]: history } })),
|
|
getChatHistory: (conversationId) => get().chatHistoryMap[conversationId] ?? [],
|
|
}))
|