diff --git a/src/app/(main)/profile/(home)/[[...slugs]]/page.tsx b/src/app/(main)/profile/(home)/[[...slugs]]/page.tsx index f47fa890a2142..e122316d5df46 100644 --- a/src/app/(main)/profile/(home)/[[...slugs]]/page.tsx +++ b/src/app/(main)/profile/(home)/[[...slugs]]/page.tsx @@ -1,6 +1,6 @@ +import { Skeleton } from 'antd'; import dynamic from 'next/dynamic'; -import SkeletonLoading from '@/components/SkeletonLoading'; import { enableClerk } from '@/const/auth'; import { metadataModule } from '@/server/metadata'; import { translation } from '@/server/translation'; @@ -13,7 +13,7 @@ import Client from '../Client'; const ClerkProfile = dynamic(() => import('../../features/ClerkProfile'), { loading: () => (
- +
), }); diff --git a/src/app/(main)/profile/loading.tsx b/src/app/(main)/profile/loading.tsx index 6a56336021978..2c93414921abd 100644 --- a/src/app/(main)/profile/loading.tsx +++ b/src/app/(main)/profile/loading.tsx @@ -1,9 +1,3 @@ -import SkeletonLoading from '@/components/SkeletonLoading'; +import FullLoading from '@/components/Loading/BrandTextLoading'; -export default () => { - return ( -
- -
- ); -}; +export default () => ; diff --git a/src/app/(main)/profile/security/page.tsx b/src/app/(main)/profile/security/page.tsx index 392ef8ec16160..95a233c60cfe0 100644 --- a/src/app/(main)/profile/security/page.tsx +++ b/src/app/(main)/profile/security/page.tsx @@ -1,7 +1,7 @@ +import { Skeleton } from 'antd'; import dynamic from 'next/dynamic'; import { notFound } from 'next/navigation'; -import SkeletonLoading from '@/components/SkeletonLoading'; import { enableClerk } from '@/const/auth'; import { metadataModule } from '@/server/metadata'; import { translation } from '@/server/translation'; @@ -10,7 +10,7 @@ import { isMobileDevice } from '@/utils/server/responsive'; const ClerkProfile = dynamic(() => import('../features/ClerkProfile'), { loading: () => (
- +
), }); diff --git a/src/database/server/models/session.ts b/src/database/server/models/session.ts index 1aa90bca5f97e..b3d11e4e0582b 100644 --- a/src/database/server/models/session.ts +++ b/src/database/server/models/session.ts @@ -13,7 +13,7 @@ import { } from '@/database/utils/genWhere'; import { idGenerator } from '@/database/utils/idGenerator'; import { parseAgentConfig } from '@/server/globalConfig/parseDefaultAgent'; -import { ChatSessionList, LobeAgentSession } from '@/types/session'; +import { ChatSessionList, LobeAgentSession, SessionRankItem } from '@/types/session'; import { merge } from '@/utils/merge'; import { @@ -119,15 +119,7 @@ export class SessionModel { return result[0].count; }; - rank = async (): Promise< - { - avatar: string | null; - backgroundColor: string | null; - count: number; - id: string; - title: string | null; - }[] - > => { + rank = async (): Promise => { return this.db .select({ avatar: agents.avatar, diff --git a/src/database/server/models/topic.ts b/src/database/server/models/topic.ts index 7fb82aa6a6f9f..f37bd8a1bf4fa 100644 --- a/src/database/server/models/topic.ts +++ b/src/database/server/models/topic.ts @@ -9,6 +9,7 @@ import { genWhere, } from '@/database/utils/genWhere'; import { idGenerator } from '@/database/utils/idGenerator'; +import { TopicRankItem } from '@/types/topic'; import { NewMessage, TopicItem, messages, topics } from '../../schemas'; @@ -126,14 +127,7 @@ export class TopicModel { return result[0].count; }; - rank = async (): Promise< - { - count: number; - id: string; - sessionId: string | null; - title: string | null; - }[] - > => { + rank = async (): Promise => { return this.db .select({ count: count(messages.id).as('count'), diff --git a/src/services/message/client.ts b/src/services/message/client.ts index 87357c441b1d6..508412304b241 100644 --- a/src/services/message/client.ts +++ b/src/services/message/client.ts @@ -1,5 +1,3 @@ -import dayjs from 'dayjs'; - import { INBOX_SESSION_ID } from '@/const/session'; import { clientDB } from '@/database/client/db'; import { MessageModel } from '@/database/server/models/message'; @@ -52,9 +50,9 @@ export class ClientService extends BaseClientService implements IMessageService return data as unknown as ChatMessage[]; }; - async countMessages(params?: { endDate?: string; range?: [string, string]; startDate?: string }) { + countMessages: IMessageService['countMessages'] = async (params) => { return this.messageModel.count(params); - } + }; getAllMessagesInSession: IMessageService['getAllMessagesInSession'] = async (sessionId) => { const data = this.messageModel.queryBySessionId(this.toDbSessionId(sessionId)); diff --git a/src/services/message/server.ts b/src/services/message/server.ts index 56757ce9c47fb..f28dc26052ad8 100644 --- a/src/services/message/server.ts +++ b/src/services/message/server.ts @@ -36,13 +36,9 @@ export class ServerService implements IMessageService { }); }; - countMessages = async (params?: { - endDate?: string; - range?: [string, string]; - startDate?: string; - }): Promise => { + countMessages: IMessageService['countMessages'] = async (params) => { return lambdaClient.message.count.query(params); - } + }; updateMessageError: IMessageService['updateMessageError'] = async (id, error) => { return lambdaClient.message.update.mutate({ id, value: { error } }); diff --git a/src/services/message/type.ts b/src/services/message/type.ts index d6e68be2121da..dd8f90a864fb1 100644 --- a/src/services/message/type.ts +++ b/src/services/message/type.ts @@ -16,7 +16,11 @@ export interface IMessageService { getMessages(sessionId: string, topicId?: string): Promise; getAllMessages(): Promise; getAllMessagesInSession(sessionId: string): Promise; - countMessages(): Promise; + countMessages(params?: { + endDate?: string; + range?: [string, string]; + startDate?: string; + }): Promise; updateMessageError(id: string, error: ChatMessageError): Promise; updateMessage(id: string, message: Partial): Promise; diff --git a/src/services/session/client.ts b/src/services/session/client.ts index 131a21c3e39f9..4b848b20917b1 100644 --- a/src/services/session/client.ts +++ b/src/services/session/client.ts @@ -74,13 +74,13 @@ export class ClientService extends BaseClientService implements ISessionService } }; - async countSessions(params?: { endDate?: string; range?: [string, string]; startDate?: string }) { + countSessions: ISessionService['countSessions'] = async (params) => { return this.sessionModel.count(params); - } + }; - async rankSessions() { + rankSessions: ISessionService['rankSessions'] = async () => { return this.sessionModel.rank(); - } + }; searchSessions: ISessionService['searchSessions'] = async (keyword) => { return this.sessionModel.queryByKeyword(keyword); diff --git a/src/services/session/server.ts b/src/services/session/server.ts index 1ed64452d0b0c..1e98271a7be5e 100644 --- a/src/services/session/server.ts +++ b/src/services/session/server.ts @@ -36,14 +36,14 @@ export class ServerService implements ISessionService { return lambdaClient.session.getGroupedSessions.query(); }; - countSessions = async (params?: { - endDate?: string; - range?: [string, string]; - startDate?: string; - }): Promise => { + countSessions: ISessionService['countSessions'] = async (params) => { return lambdaClient.session.countSessions.query(params); }; + rankSessions: ISessionService['rankSessions'] = async () => { + return lambdaClient.session.rankSessions.query(); + }; + updateSession: ISessionService['updateSession'] = (id, data) => { const { group, pinned, meta, updatedAt } = data; return lambdaClient.session.updateSession.mutate({ diff --git a/src/services/session/type.ts b/src/services/session/type.ts index 95025e360da66..c63f8bc52dafb 100644 --- a/src/services/session/type.ts +++ b/src/services/session/type.ts @@ -11,6 +11,7 @@ import { LobeSessions, SessionGroupItem, SessionGroups, + SessionRankItem, UpdateSessionParams, } from '@/types/session'; @@ -36,15 +37,7 @@ export interface ISessionService { range?: [string, string]; startDate?: string; }): Promise; - rankSessions(): Promise< - { - avatar: string | null; - count: number; - id: string; - title: string | null; - backgroundColor: string | null; - }[] - >; + rankSessions(): Promise; searchSessions(keyword: string): Promise; updateSession(id: string, data: Partial): Promise; diff --git a/src/services/topic/client.ts b/src/services/topic/client.ts index 333720e9f7a6f..b1593fd7ce87b 100644 --- a/src/services/topic/client.ts +++ b/src/services/topic/client.ts @@ -55,20 +55,13 @@ export class ClientService extends BaseClientService implements ITopicService { return data as unknown as Promise; }; - async countTopics(params?: { endDate?: string; range?: [string, string]; startDate?: string }) { + countTopics: ITopicService['countTopics'] = async (params) => { return this.topicModel.count(params); - } + }; - async rankTopics(): Promise< - { - count: number; - id: string; - sessionId: string | null; - title: string | null; - }[] - > { + rankTopics: ITopicService['rankTopics'] = async () => { return this.topicModel.rank(); - } + }; updateTopic: ITopicService['updateTopic'] = async (id, data) => { return this.topicModel.update(id, data as any); diff --git a/src/services/topic/server.ts b/src/services/topic/server.ts index a2a22f580cf7f..30f345f2c711b 100644 --- a/src/services/topic/server.ts +++ b/src/services/topic/server.ts @@ -24,24 +24,13 @@ export class ServerService implements ITopicService { getAllTopics: ITopicService['getAllTopics'] = () => lambdaClient.topic.getAllTopics.query() as any; - countTopics = async(params?: { - endDate?: string; - range?: [string, string]; - startDate?: string; - }): Promise => { + countTopics: ITopicService['countTopics'] = async (params) => { return lambdaClient.topic.countTopics.query(params); - } + }; - rankTopics = async (): Promise< - { - count: number; - id: string; - sessionId: string | null; - title: string | null; - }[] - > => { + rankTopics: ITopicService['rankTopics'] = async () => { return lambdaClient.topic.rankTopics.query(); - } + }; searchTopics: ITopicService['searchTopics'] = (keywords, sessionId) => lambdaClient.topic.searchTopics.query({ diff --git a/src/services/topic/type.ts b/src/services/topic/type.ts index 6bd7ab1b1cb49..74b43a28075c3 100644 --- a/src/services/topic/type.ts +++ b/src/services/topic/type.ts @@ -1,6 +1,6 @@ /* eslint-disable typescript-sort-keys/interface */ import { BatchTaskResult } from '@/types/service'; -import { ChatTopic } from '@/types/topic'; +import { ChatTopic, TopicRankItem } from '@/types/topic'; export interface CreateTopicParams { favorite?: boolean; @@ -22,15 +22,12 @@ export interface ITopicService { getTopics(params: QueryTopicParams): Promise; getAllTopics(): Promise; - countTopics(): Promise; - rankTopics(): Promise< - { - id: string; - title: string | null; - count: number; - sessionId: string | null; - }[] - >; + countTopics(params?: { + endDate?: string; + range?: [string, string]; + startDate?: string; + }): Promise; + rankTopics(): Promise; searchTopics(keyword: string, sessionId?: string): Promise; updateTopic(id: string, data: Partial): Promise; diff --git a/src/types/session/index.ts b/src/types/session/index.ts index d794930381678..f6777e8a92c90 100644 --- a/src/types/session/index.ts +++ b/src/types/session/index.ts @@ -15,3 +15,11 @@ export interface UpdateSessionParams { pinned?: boolean; updatedAt: Date; } + +export interface SessionRankItem { + avatar: string | null; + backgroundColor: string | null; + count: number; + id: string; + title: string | null; +} diff --git a/src/types/topic/topic.ts b/src/types/topic/topic.ts index 39b65c690a446..e74ec10f21f3f 100644 --- a/src/types/topic/topic.ts +++ b/src/types/topic/topic.ts @@ -44,3 +44,10 @@ export interface ChatTopic extends Omit { } export type ChatTopicMap = Record; + +export interface TopicRankItem { + count: number; + id: string; + sessionId: string | null; + title: string | null; +}