feat: 对话逻辑调整、历史对话接口联调

This commit is contained in:
rd
2025-08-22 18:28:09 +08:00
parent 0d5cb7ba38
commit 063ce3df5e
13 changed files with 221 additions and 71 deletions

View 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,
});
}
},
},
});

View File

@ -8,3 +8,4 @@
export * from './app';
export * from './tab-bar';
export * from './user';
export * from './chat';

View File

@ -1,20 +0,0 @@
import { defineStore } from 'pinia';
interface SharedDataState {
routeParams: Record<string, any> | null;
}
export const useSharedDataStore = defineStore('sharedData', {
state: (): SharedDataState => ({
routeParams: null,
}),
actions: {
setRouteParams(params: Record<string, any>) {
this.routeParams = params;
},
clearRouteParams() {
this.routeParams = null;
},
},
});