feat: 更新hook fetch 库

This commit is contained in:
ccnetcore
2025-06-28 23:07:32 +08:00
parent 5383d2d40e
commit 216b57a4c7
14 changed files with 34 additions and 27 deletions

View File

@@ -1,10 +1,10 @@
import type { EmailCodeDTO, LoginDTO, LoginVO, RegisterDTO } from './types';
import { post } from '@/utils/request';
export const login = (data: LoginDTO) => post<LoginVO>('/auth/login', data);
export const login = (data: LoginDTO) => post<LoginVO>('/auth/login', data).json();
// 邮箱验证码
export const emailCode = (data: EmailCodeDTO) => post('/resource/email/code', data);
export const emailCode = (data: EmailCodeDTO) => post('/resource/email/code', data).json();
// 注册账号
export const register = (data: RegisterDTO) => post('/auth/register', data);
export const register = (data: RegisterDTO) => post('/auth/register', data).json();

View File

@@ -7,11 +7,11 @@ export const send = (data: SendDTO) => post<null>('/ai-chat/send', data);
// 新增对应会话聊天记录
export function addChat(data: ChatMessageVo) {
return post('/system/message', data);
return post('/system/message', data).json();
}
// 获取当前会话的聊天记录
export function getChatList(params: GetChatListParams) {
// return get<ChatMessageVo[]>('/system/message/list', params);
return get<ChatMessageVo[]>('/message', params);
return get<ChatMessageVo[]>('/message', params).json();
}

View File

@@ -4,5 +4,5 @@ import { get } from '@/utils/request';
// 获取当前用户的模型列表
export function getModelList() {
// return get<GetSessionListVO[]>('/system/model/modelList');
return get<GetSessionListVO[]>('/ai-chat/model');
return get<GetSessionListVO[]>('/ai-chat/model').json();
}

View File

@@ -9,19 +9,19 @@ import { del, get, post, put } from '@/utils/request';
// 获取会话列表
export function get_session_list(params: GetSessionListParams) {
// return get<ChatSessionVo[]>('/system/session/list', params);
return get<ChatSessionVo[]>('/session', params);
return get<ChatSessionVo[]>('/session', params).json();
}
// 创建会话
export function create_session(data: CreateSessionDTO) {
return post('/session', data);
return post('/session', data).json();
}
// 更新会话
export function update_session(data: ChatSessionVo) {
return put(`/session/${data.id}`, data);
return put(`/session/${data.id}`, data).json();
}
// 会话详情
export function get_session(id: string) {
return get<ChatSessionVo>(`/session/${id}`);
return get<ChatSessionVo>(`/session/${id}`).json();
}
// 删除会话
export function delete_session(ids: string[]) {

View File

@@ -91,7 +91,7 @@ export interface ChatSessionVo {
/**
* 创建时间
*/
createTime?: Date;
creationTime?: Date;
/**
* 自定义的消息前缀图标字段
*/

View File

@@ -2,5 +2,5 @@ import { get } from '@/utils/request';
// 获取用户信息
export function getUserInfo() {
return get<any>('/ai-chat/account');
return get<any>('/ai-chat/account').json();
}

View File

@@ -122,7 +122,7 @@ function handleClick(item: GetSessionListVO) {
display: flex;
flex-direction: column;
gap: 4px;
height: 500px;
height: 200px;
overflow: hidden auto;
.popover-content-box-items {
:deep() {

View File

@@ -178,7 +178,7 @@ export const useSessionStore = defineStore('session', () => {
// 删除会话(供组件调用)
const deleteSessions = async (ids: string[]) => {
try {
//todo cc这里删除返回空的body结果炸了报错堆栈都没有
// todo cc这里删除返回空的body结果炸了报错堆栈都没有
await delete_session(ids);
// 1. 先找到被修改会话在 sessionList 中的索引(假设 sessionList 是按服务端排序的完整列表)
const targetIndex = sessionList.value.findIndex(session => session.id === ids[0]);
@@ -200,7 +200,7 @@ export const useSessionStore = defineStore('session', () => {
const currentDate = new Date();
return sessions.map((session) => {
const createDate = new Date(session.createTime!);
const createDate = new Date(session.creationTime!);
const diffDays = Math.floor(
(currentDate.getTime() - createDate.getTime()) / (1000 * 60 * 60 * 24),
);