feat: 完成对接接口
This commit is contained in:
@@ -60,16 +60,15 @@ export const useSessionStore = defineStore('session', () => {
|
||||
try {
|
||||
const params: GetSessionListParams = {
|
||||
userId: userStore.userInfo?.userId as number,
|
||||
pageNum: page,
|
||||
pageSize: pageSize.value,
|
||||
skipCount: page,
|
||||
maxResultCount: pageSize.value,
|
||||
isAsc: 'desc',
|
||||
orderByColumn: 'createTime',
|
||||
};
|
||||
|
||||
const resArr = await get_session_list(params);
|
||||
|
||||
// 预处理会话分组 并添加前缀图标
|
||||
const res = processSessions(resArr.rows);
|
||||
const res = processSessions(resArr.data.items);
|
||||
|
||||
const allSessions = new Map(sessionList.value.map(item => [item.id, item])); // 现有所有数据
|
||||
res.forEach(item => allSessions.set(item.id, { ...item })); // 更新/添加数据
|
||||
@@ -126,7 +125,7 @@ export const useSessionStore = defineStore('session', () => {
|
||||
// msg: "操作成功",
|
||||
// data: "1935711019560206338"
|
||||
// };
|
||||
console.log('create_session---res--',res)
|
||||
console.log('create_session---res--', res);
|
||||
// 创建会话后立刻查询列表会话
|
||||
// 1. 先找到被修改会话在 sessionList 中的索引(假设 sessionList 是按服务端排序的完整列表)
|
||||
const targetIndex = sessionList.value.findIndex(session => session.id === `${res.data}`);
|
||||
@@ -138,13 +137,12 @@ export const useSessionStore = defineStore('session', () => {
|
||||
// 3. 刷新目标页数据
|
||||
await requestSessionList(targetPage, true);
|
||||
// 并将当前勾选信息设置为新增的会话信息
|
||||
const newSessionRes = await get_session(`${res.data}`);
|
||||
const newSessionRes = await get_session(`${res.data.id}`);
|
||||
setCurrentSession(newSessionRes.data);
|
||||
|
||||
// 跳转聊天页
|
||||
router.replace({
|
||||
name: 'chatWithId',
|
||||
params: { id: `${res.data}` },
|
||||
params: { id: `${res.data.id}` },
|
||||
});
|
||||
}
|
||||
catch (error) {
|
||||
@@ -180,6 +178,7 @@ export const useSessionStore = defineStore('session', () => {
|
||||
// 删除会话(供组件调用)
|
||||
const deleteSessions = async (ids: string[]) => {
|
||||
try {
|
||||
//todo cc这里删除,返回空的body,结果炸了,报错堆栈都没有
|
||||
await delete_session(ids);
|
||||
// 1. 先找到被修改会话在 sessionList 中的索引(假设 sessionList 是按服务端排序的完整列表)
|
||||
const targetIndex = sessionList.value.findIndex(session => session.id === ids[0]);
|
||||
|
||||
Reference in New Issue
Block a user