UNPKG

@lobehub/chat

Version:

Lobe Chat - an open-source, high-performance chatbot framework that supports speech synthesis, multimodal, and extensible Function Call plugin system. Supports one-click free deployment of your private ChatGPT/LLM web application.

37 lines (28 loc) 1.13 kB
import { shallow } from 'zustand/shallow'; import { createWithEqualityFn } from 'zustand/traditional'; import { StateCreator } from 'zustand/vanilla'; import { createDevtools } from '../middleware/createDevtools'; import { type ElectronAppAction, createElectronAppSlice } from './actions/app'; import { type ElectronRemoteServerAction, remoteSyncSlice } from './actions/sync'; import { type ElectronState, initialState } from './initialState'; // =============== 聚合 createStoreFn ============ // export interface ElectronStore extends ElectronState, ElectronRemoteServerAction, ElectronAppAction { /* empty */ } const createStore: StateCreator<ElectronStore, [['zustand/devtools', never]]> = ( ...parameters ) => ({ ...initialState, ...remoteSyncSlice(...parameters), ...createElectronAppSlice(...parameters), }); // =============== 实装 useStore ============ // const devtools = createDevtools('electron'); export const useElectronStore = createWithEqualityFn<ElectronStore>()( devtools(createStore), shallow, ); export const getElectronStoreState = () => useElectronStore.getState();