diff --git a/src/routes/ai-chat/list.ts b/src/routes/ai-chat/list.ts index 08c4bbb..07eaea4 100644 --- a/src/routes/ai-chat/list.ts +++ b/src/routes/ai-chat/list.ts @@ -11,10 +11,15 @@ app .define(async (ctx) => { const tokenUser = ctx.state.tokenUser; const type = ctx.query.type || 'keep'; + const all = ctx.query.all || false; + let search: any = {}; + if (type && !all) { + search.type = type; + } const aiChatList = await AiChatHistoryModel.findAll({ where: { uid: tokenUser.id, - type, + ...search, }, order: [['updatedAt', 'DESC']], }); diff --git a/src/routes/ai-chat/models/ai-chat-history.ts b/src/routes/ai-chat/models/ai-chat-history.ts index 4e1777f..762ba59 100644 --- a/src/routes/ai-chat/models/ai-chat-history.ts +++ b/src/routes/ai-chat/models/ai-chat-history.ts @@ -18,6 +18,8 @@ type AiChatHistoryData = { [key: string]: any; }; }; +export const aiChatTypes = ['keep', 'temp', 'archive'] as const; +export type AIChatType = (typeof aiChatTypes)[number]; export class AiChatHistoryModel extends Model { declare id: string; declare username: string;