From e75b2f3bab8eef729228ecb9da5a8814992f3956 Mon Sep 17 00:00:00 2001 From: wangys <3401275564@qq.com> Date: Tue, 23 Dec 2025 16:16:47 +0800 Subject: [PATCH] =?UTF-8?q?=E6=A8=A1=E5=9D=97=E5=8F=96=E5=87=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../packages/bidding/src/types/shared.d.ts | 83 +++----------- .../packages/platform/src/types/shared.d.ts | 83 +++----------- .../packages/shared/src/api/ai/aichat.ts | 6 +- .../packages/shared/src/components/index.ts | 1 - .../packages/shared/src/types/ai/aiChat.ts | 102 +++++++++++++++++- .../packages/shared/src/types/index.ts | 2 +- .../packages/shared/vite.config.ts | 3 - .../src/api/workcase/index.ts | 0 .../src/api/workcase/workcase.ts | 4 +- .../src/api/workcase/workcaseChat.ts | 95 +--------------- .../chatRoom/chatRoom/ChatRoom.scss | 0 .../components/chatRoom/chatRoom/ChatRoom.vue | 18 +--- .../src/components/chatRoom/index.ts | 0 .../packages/workcase/src/components/index.ts | 1 + .../packages/workcase/src/types/shared.d.ts | 83 +++----------- .../src/types/workcase/chatRoom.ts | 62 +---------- .../src/types/workcase/conversation.ts | 2 +- .../src/types/workcase/customer.ts | 2 +- .../src/types/workcase/index.ts | 0 .../src/types/workcase/wordCloud.ts | 2 +- .../src/types/workcase/workcase.ts | 2 +- .../views/public/ChatRoom/ChatRoomView.vue | 12 +-- 22 files changed, 164 insertions(+), 399 deletions(-) rename urbanLifelineWeb/packages/{shared => workcase}/src/api/workcase/index.ts (100%) rename urbanLifelineWeb/packages/{shared => workcase}/src/api/workcase/workcase.ts (98%) rename urbanLifelineWeb/packages/{shared => workcase}/src/api/workcase/workcaseChat.ts (70%) rename urbanLifelineWeb/packages/{shared => workcase}/src/components/chatRoom/chatRoom/ChatRoom.scss (100%) rename urbanLifelineWeb/packages/{shared => workcase}/src/components/chatRoom/chatRoom/ChatRoom.vue (95%) rename urbanLifelineWeb/packages/{shared => workcase}/src/components/chatRoom/index.ts (100%) create mode 100644 urbanLifelineWeb/packages/workcase/src/components/index.ts rename urbanLifelineWeb/packages/{shared => workcase}/src/types/workcase/chatRoom.ts (83%) rename urbanLifelineWeb/packages/{shared => workcase}/src/types/workcase/conversation.ts (97%) rename urbanLifelineWeb/packages/{shared => workcase}/src/types/workcase/customer.ts (98%) rename urbanLifelineWeb/packages/{shared => workcase}/src/types/workcase/index.ts (100%) rename urbanLifelineWeb/packages/{shared => workcase}/src/types/workcase/wordCloud.ts (88%) rename urbanLifelineWeb/packages/{shared => workcase}/src/types/workcase/workcase.ts (97%) diff --git a/urbanLifelineWeb/packages/bidding/src/types/shared.d.ts b/urbanLifelineWeb/packages/bidding/src/types/shared.d.ts index 488ce0f6..89e856fc 100644 --- a/urbanLifelineWeb/packages/bidding/src/types/shared.d.ts +++ b/urbanLifelineWeb/packages/bidding/src/types/shared.d.ts @@ -46,40 +46,23 @@ declare module 'shared/components/ai/knowledge/DocumentDetail.vue' { export default DocumentDetail } -declare module 'shared/components/chatRoom/ChatRoom.vue' { - import { DefineComponent } from 'vue' - - interface ChatMessageVO { - messageId: string - senderId: string - senderName: string - senderAvatar: string - content: string - files: string[] - sendTime: string - } - - const ChatRoom: DefineComponent<{ - messages: ChatMessageVO[] - currentUserId: string - roomName?: string - meetingUrl?: string - showMeeting?: boolean - fileDownloadUrl?: string - }, {}, {}, {}, {}, {}, {}, { - header?: () => any - 'action-area'?: () => any - }> - export default ChatRoom -} // ========== API 模块 ========== declare module 'shared/api' { - export const api: any + import type { AxiosResponse, AxiosRequestConfig } from 'axios' + + interface ApiInstance { + get(url: string, config?: AxiosRequestConfig): Promise> + post(url: string, data?: any, config?: AxiosRequestConfig): Promise> + put(url: string, data?: any, config?: AxiosRequestConfig): Promise> + delete(url: string, config?: AxiosRequestConfig): Promise> + uploadPut(url: string, data: FormData, config?: AxiosRequestConfig): Promise> + } + + export const api: ApiInstance export const TokenManager: any export const authAPI: any export const fileAPI: any - export const workcaseAPI: any } declare module 'shared/api/auth' { @@ -96,18 +79,9 @@ declare module 'shared/api/ai' { export const aiChatAPI: any } -declare module 'shared/api/workcase' { - export const workcaseAPI: any - export const workcaseChatAPI: any -} - - // ============ types模块 ================== declare module 'shared/types' { - import type { BaseDTO } from '../../../shared/src/types/base' - - // 重新导出 base - export type { BaseDTO } + export type { BaseDTO, BaseVO } from '../../../shared/src/types/base' // 重新导出 response export type { ResultDomain } from '../../../shared/src/types/response' @@ -138,39 +112,6 @@ declare module 'shared/types' { CommentMessageParams } from '../../../shared/src/types/ai' - // 重新导出 workcase - export type { - TbWorkcaseDTO, - TbWorkcaseProcessDTO, - TbWorkcaseDeviceDTO, - // 聊天室相关 - TbChatRoomDTO, - TbChatRoomMessageDTO, - TbChatRoomMemberDTO, - TbVideoMeetingDTO, - TbMeetingParticipantDTO, - TbMeetingTranscriptionDTO, - ChatRoomVO, - ChatMessageVO, - ChatRoomMessageVO, - ChatMemberVO, - VideoMeetingVO, - MeetingParticipantVO, - SendMessageParam, - CreateMeetingParam, - MarkReadParam, - // 客服相关 - TbCustomerServiceDTO, - CustomerServiceVO, - // 词云 - TbWordCloudDTO, - // 来客相关 - TbGuestDTO, - GuestVO, - CustomerVO, - ConversationVO - } from '../../../shared/src/types/workcase' - // 重新导出 menu export type { MenuItem, toMenuItem, toMenuItems } from '../../../shared/src/types/menu' } diff --git a/urbanLifelineWeb/packages/platform/src/types/shared.d.ts b/urbanLifelineWeb/packages/platform/src/types/shared.d.ts index 488ce0f6..89e856fc 100644 --- a/urbanLifelineWeb/packages/platform/src/types/shared.d.ts +++ b/urbanLifelineWeb/packages/platform/src/types/shared.d.ts @@ -46,40 +46,23 @@ declare module 'shared/components/ai/knowledge/DocumentDetail.vue' { export default DocumentDetail } -declare module 'shared/components/chatRoom/ChatRoom.vue' { - import { DefineComponent } from 'vue' - - interface ChatMessageVO { - messageId: string - senderId: string - senderName: string - senderAvatar: string - content: string - files: string[] - sendTime: string - } - - const ChatRoom: DefineComponent<{ - messages: ChatMessageVO[] - currentUserId: string - roomName?: string - meetingUrl?: string - showMeeting?: boolean - fileDownloadUrl?: string - }, {}, {}, {}, {}, {}, {}, { - header?: () => any - 'action-area'?: () => any - }> - export default ChatRoom -} // ========== API 模块 ========== declare module 'shared/api' { - export const api: any + import type { AxiosResponse, AxiosRequestConfig } from 'axios' + + interface ApiInstance { + get(url: string, config?: AxiosRequestConfig): Promise> + post(url: string, data?: any, config?: AxiosRequestConfig): Promise> + put(url: string, data?: any, config?: AxiosRequestConfig): Promise> + delete(url: string, config?: AxiosRequestConfig): Promise> + uploadPut(url: string, data: FormData, config?: AxiosRequestConfig): Promise> + } + + export const api: ApiInstance export const TokenManager: any export const authAPI: any export const fileAPI: any - export const workcaseAPI: any } declare module 'shared/api/auth' { @@ -96,18 +79,9 @@ declare module 'shared/api/ai' { export const aiChatAPI: any } -declare module 'shared/api/workcase' { - export const workcaseAPI: any - export const workcaseChatAPI: any -} - - // ============ types模块 ================== declare module 'shared/types' { - import type { BaseDTO } from '../../../shared/src/types/base' - - // 重新导出 base - export type { BaseDTO } + export type { BaseDTO, BaseVO } from '../../../shared/src/types/base' // 重新导出 response export type { ResultDomain } from '../../../shared/src/types/response' @@ -138,39 +112,6 @@ declare module 'shared/types' { CommentMessageParams } from '../../../shared/src/types/ai' - // 重新导出 workcase - export type { - TbWorkcaseDTO, - TbWorkcaseProcessDTO, - TbWorkcaseDeviceDTO, - // 聊天室相关 - TbChatRoomDTO, - TbChatRoomMessageDTO, - TbChatRoomMemberDTO, - TbVideoMeetingDTO, - TbMeetingParticipantDTO, - TbMeetingTranscriptionDTO, - ChatRoomVO, - ChatMessageVO, - ChatRoomMessageVO, - ChatMemberVO, - VideoMeetingVO, - MeetingParticipantVO, - SendMessageParam, - CreateMeetingParam, - MarkReadParam, - // 客服相关 - TbCustomerServiceDTO, - CustomerServiceVO, - // 词云 - TbWordCloudDTO, - // 来客相关 - TbGuestDTO, - GuestVO, - CustomerVO, - ConversationVO - } from '../../../shared/src/types/workcase' - // 重新导出 menu export type { MenuItem, toMenuItem, toMenuItems } from '../../../shared/src/types/menu' } diff --git a/urbanLifelineWeb/packages/shared/src/api/ai/aichat.ts b/urbanLifelineWeb/packages/shared/src/api/ai/aichat.ts index 4820f611..9306ce04 100644 --- a/urbanLifelineWeb/packages/shared/src/api/ai/aichat.ts +++ b/urbanLifelineWeb/packages/shared/src/api/ai/aichat.ts @@ -1,6 +1,6 @@ import { api } from '@/api/index' import type { ResultDomain } from '@/types' -import type { TbChat, TbChatMessage, ChatPrepareData, StopChatParams, CommentMessageParams, DifyFileInfo } from '@/types/ai' +import type { TbChat, TbChatMessage, ChatPrepareData, StopChatParam, CommentMessageParam, DifyFileInfo } from '@/types/ai' /** * @description AI对话相关接口 @@ -93,7 +93,7 @@ export const aiChatAPI = { * 停止对话 * @param params 停止参数 */ - async stopChat(params: StopChatParams): Promise> { + async stopChat(params: StopChatParam): Promise> { const response = await api.post(`${this.baseUrl}/stop`, params) return response.data }, @@ -102,7 +102,7 @@ export const aiChatAPI = { * 评价消息 * @param params 评价参数 */ - async commentMessage(params: CommentMessageParams): Promise> { + async commentMessage(params: CommentMessageParam): Promise> { const response = await api.post(`${this.baseUrl}/comment`, params) return response.data }, diff --git a/urbanLifelineWeb/packages/shared/src/components/index.ts b/urbanLifelineWeb/packages/shared/src/components/index.ts index 21547580..f1fecff7 100644 --- a/urbanLifelineWeb/packages/shared/src/components/index.ts +++ b/urbanLifelineWeb/packages/shared/src/components/index.ts @@ -2,6 +2,5 @@ export * from './base' export * from './dynamicFormItem' export * from './ai' export * from './file' -export * from './chatRoom' // 通用视图组件 export { default as IframeView } from './iframe/IframeView.vue' \ No newline at end of file diff --git a/urbanLifelineWeb/packages/shared/src/types/ai/aiChat.ts b/urbanLifelineWeb/packages/shared/src/types/ai/aiChat.ts index b7ac7d2a..3c96b0fd 100644 --- a/urbanLifelineWeb/packages/shared/src/types/ai/aiChat.ts +++ b/urbanLifelineWeb/packages/shared/src/types/ai/aiChat.ts @@ -90,22 +90,120 @@ export interface ChatPrepareData { userType?: boolean } +// ==================== 请求参数类型(必传校验) ==================== + +/** + * 创建对话参数 + */ +export interface CreateChatParam { + /** 智能体ID(必传) */ + agentId: string + /** 用户ID(必传) */ + userId: string + /** 用户类型(必传) */ + userType: boolean + /** 对话标题 */ + title?: string +} + +/** + * 准备流式对话参数 + */ +export interface PrepareChatParam { + /** 对话ID(必传) */ + chatId: string + /** 用户问题(必传) */ + query: string + /** 智能体ID(必传) */ + agentId: string + /** 用户类型(必传) */ + userType: boolean + /** 用户ID */ + userId?: string + /** 文件列表 */ + files?: DifyFileInfo[] +} + /** * 停止对话参数 */ -export interface StopChatParams { +export interface StopChatParam { + /** 任务ID(必传) */ taskId: string + /** 智能体ID(必传) */ agentId: string + /** 用户ID(必传) */ userId: string } /** * 评价消息参数 */ -export interface CommentMessageParams { +export interface CommentMessageParam { + /** 智能体ID(必传) */ agentId: string + /** 对话ID(必传) */ chatId: string + /** 消息ID(必传) */ messageId: string + /** 评价内容(必传) */ comment: string + /** 用户ID(必传) */ userId: string +} + +/** + * 查询对话列表参数 + */ +export interface ChatListParam { + /** 用户ID(必传) */ + userId: string + /** 智能体ID */ + agentId?: string +} + +/** + * 查询对话消息列表参数 + */ +export interface ChatMessageListParam { + /** 对话ID(必传) */ + chatId: string +} + +// ==================== SSE 流式对话类型 ==================== + +/** + * SSE 消息事件数据 + */ +export interface SSEMessageData { + /** 事件类型 */ + event?: string + /** 回答内容 */ + answer?: string + /** 任务ID */ + task_id?: string + /** 错误消息 */ + message?: string +} + +/** + * SSE 回调函数 + */ +export interface SSECallbacks { + /** 收到消息 */ + onMessage?: (data: SSEMessageData) => void + /** 消息结束 */ + onEnd?: (taskId: string) => void + /** 发生错误 */ + onError?: (error: string) => void + /** 请求完成(无论成功失败) */ + onComplete?: () => void +} + +/** + * SSE 请求任务对象 + */ +export interface SSETask { + /** 停止请求 */ + abort: () => void } \ No newline at end of file diff --git a/urbanLifelineWeb/packages/shared/src/types/index.ts b/urbanLifelineWeb/packages/shared/src/types/index.ts index b87b7aa2..c01eff91 100644 --- a/urbanLifelineWeb/packages/shared/src/types/index.ts +++ b/urbanLifelineWeb/packages/shared/src/types/index.ts @@ -12,4 +12,4 @@ export * from "./message" export * from "./ai" export * from "./crontab" export * from "./bidding" -export * from "./workcase" \ No newline at end of file +// workcase 类型已移至各自的服务包中(如 workcase_wechat) \ No newline at end of file diff --git a/urbanLifelineWeb/packages/shared/vite.config.ts b/urbanLifelineWeb/packages/shared/vite.config.ts index a7dbb843..33fb1d1c 100644 --- a/urbanLifelineWeb/packages/shared/vite.config.ts +++ b/urbanLifelineWeb/packages/shared/vite.config.ts @@ -40,13 +40,11 @@ export default defineConfig({ './components/iframe/IframeView.vue': './src/components/iframe/IframeView.vue', './components/ai/knowledge/DocumentSegment.vue': './src/components/ai/knowledge/documentSegment/DocumentSegment.vue', './components/ai/knowledge/DocumentDetail.vue': './src/components/ai/knowledge/documentDetail/DocumentDetail.vue', - './components/chatRoom/ChatRoom.vue': './src/components/chatRoom/chatRoom/ChatRoom.vue', // ========== API 模块 ========== './api': './src/api/index.ts', './api/auth': './src/api/auth/auth.ts', './api/file': './src/api/file/file.ts', - './api/workcase': './src/api/workcase/index.ts', './api/ai': './src/api/ai/index.ts', // ========== Utils 工具模块 ========== @@ -62,7 +60,6 @@ export default defineConfig({ './types/auth': './src/types/auth/index.ts', './types/file': './src/types/file/index.ts', './types/sys': './src/types/sys/index.ts', - './types/workcase': './src/types/workcase/index.ts', './types/ai': './src/types/ai/index.ts', // ========== Config 配置模块 ========== diff --git a/urbanLifelineWeb/packages/shared/src/api/workcase/index.ts b/urbanLifelineWeb/packages/workcase/src/api/workcase/index.ts similarity index 100% rename from urbanLifelineWeb/packages/shared/src/api/workcase/index.ts rename to urbanLifelineWeb/packages/workcase/src/api/workcase/index.ts diff --git a/urbanLifelineWeb/packages/shared/src/api/workcase/workcase.ts b/urbanLifelineWeb/packages/workcase/src/api/workcase/workcase.ts similarity index 98% rename from urbanLifelineWeb/packages/shared/src/api/workcase/workcase.ts rename to urbanLifelineWeb/packages/workcase/src/api/workcase/workcase.ts index 2416f7d4..12466570 100644 --- a/urbanLifelineWeb/packages/shared/src/api/workcase/workcase.ts +++ b/urbanLifelineWeb/packages/workcase/src/api/workcase/workcase.ts @@ -1,5 +1,5 @@ -import { api } from '@/api/index' -import type { ResultDomain, PageRequest } from '@/types' +import { api } from 'shared/api' +import type { ResultDomain, PageRequest } from 'shared/types' import type { TbWorkcaseDTO, TbWorkcaseProcessDTO, TbWorkcaseDeviceDTO } from '@/types/workcase' /** diff --git a/urbanLifelineWeb/packages/shared/src/api/workcase/workcaseChat.ts b/urbanLifelineWeb/packages/workcase/src/api/workcase/workcaseChat.ts similarity index 70% rename from urbanLifelineWeb/packages/shared/src/api/workcase/workcaseChat.ts rename to urbanLifelineWeb/packages/workcase/src/api/workcase/workcaseChat.ts index f4df96a5..021cb420 100644 --- a/urbanLifelineWeb/packages/shared/src/api/workcase/workcaseChat.ts +++ b/urbanLifelineWeb/packages/workcase/src/api/workcase/workcaseChat.ts @@ -1,7 +1,5 @@ -import { api } from '@/api/index' -import type { ResultDomain, PageRequest } from '@/types' -import type { TbChat, TbChatMessage, ChatPrepareData } from '@/types/ai' -import type { TbWorkcaseDTO } from '@/types/workcase/workcase' +import { api } from 'shared/api' +import type { ResultDomain, PageRequest } from 'shared/types' import type { TbChatRoomDTO, TbChatRoomMemberDTO, @@ -12,10 +10,10 @@ import type { ChatMemberVO, ChatRoomMessageVO, CustomerServiceVO -} from '@/types/workcase/chatRoom' +} from '@/types/workcase' /** - * @description 工单对话相关接口 + * @description 工单对话相关接口(ChatRoom、客服、词云管理) * @filename workcaseChat.ts * @author cascade * @copyright xyzh @@ -24,91 +22,6 @@ import type { export const workcaseChatAPI = { baseUrl: '/urban-lifeline/workcase/chat', - // ====================== AI对话管理 ====================== - - /** - * 创建对话 - */ - async createChat(chat: TbChat): Promise> { - const response = await api.post(`${this.baseUrl}`, chat) - return response.data - }, - - /** - * 更新对话 - */ - async updateChat(chat: TbChat): Promise> { - const response = await api.put(`${this.baseUrl}`, chat) - return response.data - }, - - /** - * 查询对话列表 - */ - async getChatList(filter: TbChat): Promise> { - const response = await api.post(`${this.baseUrl}/list`, filter) - return response.data - }, - - /** - * 获取对话消息列表 - */ - async getChatMessageList(filter: TbChat): Promise> { - const response = await api.post(`${this.baseUrl}/message/list`, filter) - return response.data - }, - - /** - * 准备对话会话 - */ - async prepareChatMessageSession(prepareData: ChatPrepareData): Promise> { - const response = await api.post(`${this.baseUrl}/prepare`, prepareData) - return response.data - }, - - /** - * 流式对话(SSE)- 返回EventSource URL - */ - getStreamUrl(sessionId: string): string { - return `${this.baseUrl}/stream/${sessionId}` - }, - - /** - * 停止对话 - */ - async stopChat(filter: TbChat, taskId: string): Promise> { - const response = await api.post(`${this.baseUrl}/stop/${taskId}`, filter) - return response.data - }, - - /** - * 评论对话消息 - */ - async commentChatMessage(filter: TbChat, messageId: string, comment: string): Promise> { - const response = await api.post(`${this.baseUrl}/comment`, filter, { - params: { messageId, comment } - }) - return response.data - }, - - // ====================== 对话分析 ====================== - - /** - * 分析对话(AI预填工单信息) - */ - async analyzeChat(chatId: string): Promise> { - const response = await api.get(`${this.baseUrl}/analyze/${chatId}`) - return response.data - }, - - /** - * 总结对话 - */ - async summaryChat(chatId: string): Promise> { - const response = await api.post(`${this.baseUrl}/summary/${chatId}`) - return response.data - }, - // ====================== ChatRoom聊天室管理 ====================== /** diff --git a/urbanLifelineWeb/packages/shared/src/components/chatRoom/chatRoom/ChatRoom.scss b/urbanLifelineWeb/packages/workcase/src/components/chatRoom/chatRoom/ChatRoom.scss similarity index 100% rename from urbanLifelineWeb/packages/shared/src/components/chatRoom/chatRoom/ChatRoom.scss rename to urbanLifelineWeb/packages/workcase/src/components/chatRoom/chatRoom/ChatRoom.scss diff --git a/urbanLifelineWeb/packages/shared/src/components/chatRoom/chatRoom/ChatRoom.vue b/urbanLifelineWeb/packages/workcase/src/components/chatRoom/chatRoom/ChatRoom.vue similarity index 95% rename from urbanLifelineWeb/packages/shared/src/components/chatRoom/chatRoom/ChatRoom.vue rename to urbanLifelineWeb/packages/workcase/src/components/chatRoom/chatRoom/ChatRoom.vue index 44138b7a..e69d1628 100644 --- a/urbanLifelineWeb/packages/shared/src/components/chatRoom/chatRoom/ChatRoom.vue +++ b/urbanLifelineWeb/packages/workcase/src/components/chatRoom/chatRoom/ChatRoom.vue @@ -116,20 +116,11 @@