global.ts 900 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. import { createPersistStore } from "../utils/store";
  2. const state = {
  3. documents: [] as {
  4. id: string,
  5. name: string,
  6. url: string,
  7. }[],
  8. isChatActive: true,
  9. showMenu: false,
  10. selectedAppId: "",
  11. currentSession: {
  12. appId: '',
  13. dialogName: '',
  14. id: '',
  15. messages: [],
  16. },
  17. };
  18. export const useGlobalStore = createPersistStore(
  19. { ...state },
  20. (set, get) => ({
  21. setDocuments(list: {
  22. id: string,
  23. name: string,
  24. url: string,
  25. }[]) {
  26. set({ documents: list });
  27. },
  28. setIsChatActive(status: boolean) {
  29. set({ isChatActive: status });
  30. },
  31. setShowMenu(status: boolean) {
  32. set({ showMenu: status });
  33. },
  34. setSelectedAppId(appId: string) {
  35. set({ selectedAppId: appId });
  36. },
  37. setCurrentSession(session: any) {
  38. set({ currentSession: session });
  39. },
  40. }),
  41. {
  42. name: "Global",
  43. version: 1,
  44. },
  45. );