store.ts 1.1 KB

1234567891011121314151617181920212223242526272829303132
  1. import { create } from 'zustand'
  2. import type { App } from '@/types/app'
  3. import type { IChatItem } from '@/app/components/app/chat/type'
  4. type State = {
  5. appDetail?: App
  6. appSidebarExpand: string
  7. currentLogItem?: IChatItem
  8. showPromptLogModal: boolean
  9. showMessageLogModal: boolean
  10. }
  11. type Action = {
  12. setAppDetail: (appDetail?: App) => void
  13. setAppSiderbarExpand: (state: string) => void
  14. setCurrentLogItem: (item?: IChatItem) => void
  15. setShowPromptLogModal: (showPromptLogModal: boolean) => void
  16. setShowMessageLogModal: (showMessageLogModal: boolean) => void
  17. }
  18. export const useStore = create<State & Action>(set => ({
  19. appDetail: undefined,
  20. setAppDetail: appDetail => set(() => ({ appDetail })),
  21. appSidebarExpand: '',
  22. setAppSiderbarExpand: appSidebarExpand => set(() => ({ appSidebarExpand })),
  23. currentLogItem: undefined,
  24. setCurrentLogItem: currentLogItem => set(() => ({ currentLogItem })),
  25. showPromptLogModal: false,
  26. setShowPromptLogModal: showPromptLogModal => set(() => ({ showPromptLogModal })),
  27. showMessageLogModal: false,
  28. setShowMessageLogModal: showMessageLogModal => set(() => ({ showMessageLogModal })),
  29. }))