feat: 对话逻辑调整、历史对话接口联调
This commit is contained in:
46
src/stores/modules/chat/index.ts
Normal file
46
src/stores/modules/chat/index.ts
Normal file
@ -0,0 +1,46 @@
|
||||
import { defineStore } from 'pinia';
|
||||
import { createSession } from '@/api/all/chat';
|
||||
import { handleUserHome } from '@/utils/user';
|
||||
|
||||
interface ChatState {
|
||||
searchValue?: string;
|
||||
agentInfo?: agentInfo;
|
||||
}
|
||||
type agentInfo = {
|
||||
agent_id?: string;
|
||||
name?: string;
|
||||
description?: string;
|
||||
};
|
||||
|
||||
export const useChatStore = defineStore('chat', {
|
||||
state: (): ChatState => ({
|
||||
searchValue: '',
|
||||
agentInfo: {},
|
||||
}),
|
||||
actions: {
|
||||
setSearchValue(searchValue: string) {
|
||||
this.searchValue = searchValue;
|
||||
},
|
||||
clearSearchValue() {
|
||||
this.searchValue = '';
|
||||
},
|
||||
setAgentInfo(agentInfo: agentInfo) {
|
||||
this.agentInfo = agentInfo;
|
||||
},
|
||||
clearAgentInfo() {
|
||||
this.agentInfo = {};
|
||||
},
|
||||
clearAllAgentInfo() {
|
||||
this.agentInfo = {};
|
||||
this.searchValue = '';
|
||||
},
|
||||
async onCreateSession() {
|
||||
const { code, data } = await createSession();
|
||||
if (code === 200) {
|
||||
handleUserHome({
|
||||
conversationId: data.session_id,
|
||||
});
|
||||
}
|
||||
},
|
||||
},
|
||||
});
|
||||
Reference in New Issue
Block a user