diff --git a/src/services/session/client.ts b/src/services/session/client.ts index 2d205cca8c8c..8d696676366e 100644 --- a/src/services/session/client.ts +++ b/src/services/session/client.ts @@ -166,7 +166,7 @@ export class ClientService implements ISessionService { } async updateSessionGroup(id: string, data: Partial) { - return SessionGroupModel.update(id, data); + return SessionGroupModel.update(id, data as any); } async updateSessionGroupOrder(sortMap: { id: string; sort: number }[]) { diff --git a/src/store/chat/slices/builtinTool/action.test.ts b/src/store/chat/slices/builtinTool/action.test.ts index 63bc5b990a55..7d565d1cb6d4 100644 --- a/src/store/chat/slices/builtinTool/action.test.ts +++ b/src/store/chat/slices/builtinTool/action.test.ts @@ -47,10 +47,9 @@ describe('chatToolSlice', () => { url: '', }); vi.spyOn(result.current, 'toggleDallEImageLoading'); - vi.spyOn(ClientService.prototype, 'checkFileHash').mockImplementation(async () => ({ - isExist: false, - metadata: {}, - })); + vi.spyOn(ClientService.prototype, 'checkFileHash').mockImplementation( + async () => ({ isExist: false }) as any, + ); await act(async () => { await result.current.generateImageFromPrompts(prompts, messageId); diff --git a/src/store/session/slices/sessionGroup/reducer.test.ts b/src/store/session/slices/sessionGroup/reducer.test.ts index 17a947ca217a..52fe51b9e329 100644 --- a/src/store/session/slices/sessionGroup/reducer.test.ts +++ b/src/store/session/slices/sessionGroup/reducer.test.ts @@ -10,14 +10,14 @@ describe('sessionGroupsReducer', () => { { id: nanoid(), name: 'Group 1', - createdAt: Date.now(), - updatedAt: Date.now(), + createdAt: new Date(), + updatedAt: new Date(), }, { id: nanoid(), name: 'Group 2', - createdAt: Date.now(), - updatedAt: Date.now(), + createdAt: new Date(), + updatedAt: new Date(), sort: 1, }, ]; @@ -26,8 +26,8 @@ describe('sessionGroupsReducer', () => { const newItem: SessionGroupItem = { id: nanoid(), name: 'New Group', - createdAt: Date.now(), - updatedAt: Date.now(), + createdAt: new Date(), + updatedAt: new Date(), }; const result = sessionGroupsReducer(initialState, { diff --git a/src/types/clientDB.ts b/src/types/clientDB.ts new file mode 100644 index 000000000000..20febdf542a7 --- /dev/null +++ b/src/types/clientDB.ts @@ -0,0 +1,29 @@ +// 定义加载状态类型 +export enum DatabaseLoadingState { + Error = 'error', + Finished = 'finished', + Idle = 'idle', + Initializing = 'initializing', + LoadingDependencies = 'loadingDependencies', + LoadingWasm = 'loadingWasm', + Migrating = 'migrating', + Ready = 'ready', +} + +export const ClientDatabaseInitStages = [ + DatabaseLoadingState.Idle, + DatabaseLoadingState.Initializing, + DatabaseLoadingState.LoadingDependencies, + DatabaseLoadingState.LoadingWasm, + DatabaseLoadingState.Migrating, + DatabaseLoadingState.Finished, +]; + +// 定义进度回调接口 +export interface ClientDBLoadingProgress { + costTime?: number; + phase: 'wasm' | 'dependencies'; + progress: number; +} + +export type OnStageChange = (state: DatabaseLoadingState) => void; diff --git a/src/types/importer.ts b/src/types/importer.ts index 81bcb0f8574e..2fb413415e65 100644 --- a/src/types/importer.ts +++ b/src/types/importer.ts @@ -9,9 +9,8 @@ import { } from '@/types/message'; import { MetaData } from '@/types/meta'; import { SessionGroupId } from '@/types/session'; -import { ChatTopic } from '@/types/topic'; -interface ImportSession { +export interface ImportSession { config: LobeAgentConfig; createdAt: string; group?: SessionGroupId; @@ -22,7 +21,7 @@ interface ImportSession { updatedAt: string; } -interface ImportMessage { +export interface ImportMessage { content: string; createdAt: number; error?: ChatMessageError; @@ -64,19 +63,32 @@ interface ImportMessage { updatedAt: number; } -interface ImportSessionGroup { +export interface ImportSessionGroup { createdAt: number; id: string; name: string; sort?: number | null; updatedAt: number; } +export interface ImportTopic { + createdAt: number; + favorite?: boolean; + historySummary?: string; + id: string; + metadata?: { + model?: string; + provider?: string; + }; + sessionId?: string; + title: string; + updatedAt: number; +} export interface ImporterEntryData { messages?: ImportMessage[]; sessionGroups?: ImportSessionGroup[]; sessions?: ImportSession[]; - topics?: ChatTopic[]; + topics?: ImportTopic[]; version: number; } diff --git a/src/types/meta.ts b/src/types/meta.ts index 459aece85cdb..23ce2b941c2f 100644 --- a/src/types/meta.ts +++ b/src/types/meta.ts @@ -21,19 +21,10 @@ export const LobeMetaDataSchema = z.object({ export type MetaData = z.infer; export interface BaseDataModel { - /** - * @deprecated - */ - createAt?: number; - createdAt: number; id: string; meta: MetaData; - /** - * @deprecated - */ - updateAt?: number; updatedAt: number; } diff --git a/src/types/session/sessionGroup.ts b/src/types/session/sessionGroup.ts index 85fb3675021b..1c8dbcda048a 100644 --- a/src/types/session/sessionGroup.ts +++ b/src/types/session/sessionGroup.ts @@ -8,11 +8,11 @@ export enum SessionDefaultGroup { export type SessionGroupId = SessionDefaultGroup | string; export interface SessionGroupItem { - createdAt: number; + createdAt: Date; id: string; name: string; - sort?: number; - updatedAt: number; + sort?: number | null; + updatedAt: Date; } export type SessionGroups = SessionGroupItem[];