mirror of
https://github.com/labring/FastGPT.git
synced 2025-08-03 21:48:02 +00:00
feat: chat ui
This commit is contained in:
@@ -4,12 +4,13 @@ import { immer } from 'zustand/middleware/immer';
|
||||
|
||||
import { ChatHistoryItemType } from '@/types/chat';
|
||||
import type { InitChatResponse } from '@/api/response/chat';
|
||||
import { delChatHistoryById, getChatHistory } from '@/api/chat';
|
||||
import { delChatHistoryById, getChatHistory, clearChatHistoryByAppId } from '@/api/chat';
|
||||
|
||||
type State = {
|
||||
history: ChatHistoryItemType[];
|
||||
loadHistory: (data: { appId?: string }) => Promise<null>;
|
||||
delHistory(history: string): Promise<void>;
|
||||
clearHistory(appId: string): Promise<void>;
|
||||
updateHistory: (history: ChatHistoryItemType) => void;
|
||||
chatData: InitChatResponse;
|
||||
setChatData: (e: InitChatResponse | ((e: InitChatResponse) => InitChatResponse)) => void;
|
||||
@@ -69,6 +70,12 @@ export const useChatStore = create<State>()(
|
||||
});
|
||||
await delChatHistoryById(chatId);
|
||||
},
|
||||
async clearHistory(appId) {
|
||||
set((state) => {
|
||||
state.history = [];
|
||||
});
|
||||
await clearChatHistoryByAppId(appId);
|
||||
},
|
||||
updateHistory(history) {
|
||||
const index = get().history.findIndex((item) => item.chatId === history.chatId);
|
||||
set((state) => {
|
||||
|
@@ -29,7 +29,6 @@ export const clientInitData = async (): Promise<InitDateResponse> => {
|
||||
beianText = res.systemEnv?.beianText;
|
||||
googleClientVerKey = res.systemEnv?.googleClientVerKey;
|
||||
baiduTongji = res.systemEnv?.baiduTongji;
|
||||
console.log(res.feConfigs);
|
||||
|
||||
return res;
|
||||
} catch (error) {
|
||||
|
@@ -19,7 +19,7 @@ type State = {
|
||||
updateUserInfo: (user: UserUpdateParams) => void;
|
||||
myApps: AppListItemType[];
|
||||
myCollectionApps: AppListItemType[];
|
||||
loadMyModels: () => Promise<null>;
|
||||
loadMyApps: () => Promise<AppListItemType[]>;
|
||||
appDetail: AppSchema;
|
||||
loadAppDetail: (id: string, init?: boolean) => Promise<AppSchema>;
|
||||
updateAppDetail(appId: string, data: AppUpdateParams): Promise<void>;
|
||||
@@ -63,12 +63,12 @@ export const useUserStore = create<State>()(
|
||||
},
|
||||
myApps: [],
|
||||
myCollectionApps: [],
|
||||
async loadMyModels() {
|
||||
async loadMyApps() {
|
||||
const res = await getMyModels();
|
||||
set((state) => {
|
||||
state.myApps = res;
|
||||
});
|
||||
return null;
|
||||
return res;
|
||||
},
|
||||
appDetail: defaultApp,
|
||||
async loadAppDetail(id: string, init = false) {
|
||||
|
Reference in New Issue
Block a user