This commit is contained in:
2026-03-11 02:32:58 +08:00
parent 23fdbf2105
commit b4b286c199
79 changed files with 5079 additions and 5586 deletions

33
src/pages/home/store.ts Normal file
View File

@@ -0,0 +1,33 @@
/**
* @title Home Store
* @description 管理 home 页面的输入框数据和加载状态
* @tags zustand, state-management, input, loading
* @createdAt 2025-12-04
*/
import { create } from 'zustand';
interface HomeState {
// 输入框内容
inputValue: string;
// 加载状态
isLoading: boolean;
// Actions
setInputValue: (value: string) => void;
setLoading: (loading: boolean) => void;
messages: { role: 'user' | 'assistant'; content: string, key: string }[];
addMessage: (message: { role: 'user' | 'assistant'; content: string, key: string }) => void;
}
export const useHomeStore = create<HomeState>((set) => ({
inputValue: '',
isLoading: false,
setInputValue: (value) => set({ inputValue: value }),
setLoading: (loading) => set({ isLoading: loading }),
messages: [],
addMessage: (message) => {
set((state) => ({ messages: [...state.messages, message] }))
}
}));