cnhis-design-vue 3.4.0-beta.72 → 3.4.0-beta.73

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/README.md +87 -87
  2. package/es/components/iho-chat/index.d.ts +136 -98
  3. package/es/components/iho-chat/src/Index.vue.d.ts +136 -98
  4. package/es/components/iho-chat/src/Index.vue2.js +5 -3
  5. package/es/components/iho-chat/src/api/index.d.ts +89 -16
  6. package/es/components/iho-chat/src/api/index.js +8 -1
  7. package/es/components/iho-chat/src/components/ChatAdd.vue.d.ts +2 -4
  8. package/es/components/iho-chat/src/components/ChatFile.vue.d.ts +4 -8
  9. package/es/components/iho-chat/src/components/ChatFooter.vue.d.ts +4 -8
  10. package/es/components/iho-chat/src/components/ChatHeader.vue.d.ts +21 -32
  11. package/es/components/iho-chat/src/components/ChatMain.vue.d.ts +82 -21
  12. package/es/components/iho-chat/src/components/ChatMain.vue2.js +28 -29
  13. package/es/components/iho-chat/src/components/ChatRecord.vue.d.ts +4 -8
  14. package/es/components/iho-chat/src/components/ChatSearch.vue.d.ts +2 -4
  15. package/es/components/iho-chat/src/components/ChatSet.vue.d.ts +9 -8
  16. package/es/components/iho-chat/src/components/ChatSet.vue2.js +48 -11
  17. package/es/components/iho-chat/src/components/MessageEvent.vue.d.ts +2 -4
  18. package/es/components/iho-chat/src/components/MessageMarkdown.vue.d.ts +74 -0
  19. package/es/components/iho-chat/src/components/MessageMarkdown.vue.js +6 -0
  20. package/es/components/iho-chat/src/components/MessageMarkdown.vue2.js +41 -0
  21. package/es/components/iho-chat/src/components/MessageMergeForward.vue.d.ts +4 -8
  22. package/es/components/iho-chat/src/components/MultipleVideo.vue.d.ts +4 -8
  23. package/es/components/iho-chat/src/components/PersonProfile.vue.d.ts +2 -4
  24. package/es/components/iho-chat/src/components/PersonProfile.vue2.js +1 -1
  25. package/es/components/iho-chat/src/components/SiderList.vue.d.ts +2 -4
  26. package/es/components/iho-chat/src/components/Video.vue.d.ts +2 -4
  27. package/es/components/iho-chat/src/components/userItemRender.js +2 -1
  28. package/es/components/iho-chat/src/constants/index.d.ts +2 -1
  29. package/es/components/iho-chat/src/constants/index.js +1 -0
  30. package/es/components/iho-chat/src/hooks/useData.d.ts +26 -10
  31. package/es/components/iho-chat/src/hooks/useData.js +30 -9
  32. package/es/components/iho-chat/src/hooks/useStreamOutput.d.ts +6 -0
  33. package/es/components/iho-chat/src/hooks/useStreamOutput.js +99 -0
  34. package/es/components/iho-chat/src/hooks/useVideo.d.ts +2 -4
  35. package/es/components/iho-chat/src/hooks/useWebSocket.js +14 -4
  36. package/es/components/iho-chat/src/types/index.d.ts +2 -4
  37. package/es/components/iho-chat/src/utils/sseClient.d.ts +22 -0
  38. package/es/components/iho-chat/src/utils/sseClient.js +97 -0
  39. package/es/components/iho-chat/style/index.css +1 -1
  40. package/es/components/index.css +1 -1
  41. package/es/env.d.ts +25 -25
  42. package/es/shared/package.json.js +1 -1
  43. package/package.json +3 -3
@@ -0,0 +1,99 @@
1
+ import { useData } from './useData.js';
2
+ import 'vue';
3
+ import 'stompjs';
4
+ import 'sockjs-client/dist/sockjs.min.js';
5
+ import { MESSAGE_TYPE } from '../constants/index.js';
6
+ import '../api/index.js';
7
+ import '../utils/index.js';
8
+ import 'lodash-es';
9
+ import 'trtc-sdk-v5';
10
+ import { SseClient } from '../utils/sseClient.js';
11
+ import { uuidGenerator } from '../../../../shared/utils/index.js';
12
+ import { format } from 'date-fns';
13
+ import { useThrottleFn } from '@vueuse/core';
14
+
15
+ function useStreamOutput() {
16
+ const { state, token, appendMsg, tempState, scrollToBottom } = useData();
17
+ function handleRender(id, content) {
18
+ const msgItem = state.msgList.find((item) => item.id === id);
19
+ if (msgItem) {
20
+ const oldContent = msgItem.content.msg;
21
+ if (content && oldContent !== content) {
22
+ msgItem.content.msg = content;
23
+ scrollToBottom();
24
+ }
25
+ }
26
+ }
27
+ const _handleRender = useThrottleFn(handleRender, 250, true, true);
28
+ let sseClient = null;
29
+ async function handleStreamOutput() {
30
+ var _a, _b, _c, _d;
31
+ if (sseClient == null ? void 0 : sseClient.active)
32
+ return;
33
+ const flagObj = {
34
+ id: uuidGenerator(),
35
+ status: "START",
36
+ content: ""
37
+ };
38
+ state.loading = true;
39
+ sseClient == null ? void 0 : sseClient.disconnect();
40
+ sseClient = new SseClient();
41
+ await sseClient.connect(
42
+ "/flow/ai/mcpApi/conversation",
43
+ {
44
+ agentCode: ((_b = (_a = state.currentSessionItem.businessInfo) == null ? void 0 : _a.topicInfo) == null ? void 0 : _b.agentCode) || "A17696-012",
45
+ sessionId: state.currentSessionItem.receiver,
46
+ conversationId: flagObj.id,
47
+ content: "\u804A\u5929\u603B\u7ED3",
48
+ configs: {
49
+ ...(_d = (_c = state.currentSessionItem.businessInfo) == null ? void 0 : _c.topicInfo) == null ? void 0 : _d.param
50
+ }
51
+ },
52
+ (data, msg) => {
53
+ const content = data != null ? data : "";
54
+ if (flagObj.status === "START") {
55
+ tempState.currentMsg = {
56
+ id: flagObj.id,
57
+ chatType: state.currentSessionItem.chatType,
58
+ receiver: state.currentSessionItem.receiver,
59
+ content: { chatMessageType: MESSAGE_TYPE.AI_SUMMARY, msg: "" },
60
+ sender: state.userInfo.id,
61
+ senderName: state.userInfo.name,
62
+ senderAvatar: state.userInfo.avatar,
63
+ sendTime: format(new Date(Date.now() + 30 * 1e3), "yyyy-MM-dd HH:mm:ss")
64
+ };
65
+ appendMsg();
66
+ flagObj.status = "STOP";
67
+ } else {
68
+ flagObj.content += content;
69
+ const { id, content: snapshotContent } = flagObj;
70
+ _handleRender(id, snapshotContent);
71
+ }
72
+ },
73
+ {
74
+ headers: {
75
+ Authorization: "bearer " + token.value
76
+ },
77
+ method: "POST",
78
+ onClose: () => {
79
+ state.loading = false;
80
+ sseClient = null;
81
+ },
82
+ onError: () => {
83
+ state.loading = false;
84
+ sseClient == null ? void 0 : sseClient.disconnect();
85
+ sseClient = null;
86
+ }
87
+ }
88
+ );
89
+ return {
90
+ msgId: flagObj.id,
91
+ content: flagObj.content
92
+ };
93
+ }
94
+ return {
95
+ handleStreamOutput
96
+ };
97
+ }
98
+
99
+ export { useStreamOutput };
@@ -28,7 +28,7 @@ export interface VideoConfig {
28
28
  }
29
29
  export declare function useVideo(config?: VideoConfig): {
30
30
  state: {
31
- orgId: string | number;
31
+ orgId: string;
32
32
  currentSessionItem: import("../../../../shared/types").AnyObject;
33
33
  id: string;
34
34
  userInfo: import("../../../../shared/types").AnyObject;
@@ -56,11 +56,8 @@ export declare function useVideo(config?: VideoConfig): {
56
56
  __time?: string | undefined;
57
57
  __sendTime?: string | undefined;
58
58
  }[];
59
- currentMsg: import("../../../../shared/types").AnyObject;
60
- isAppendMsg: boolean;
61
59
  sessionList: import("../../../../shared/types").AnyObject[];
62
60
  isChangeSession: boolean;
63
- updateSessionItem: import("../../../../shared/types").AnyObject;
64
61
  isUpdateSession: boolean;
65
62
  currentReferenceMsg: import("../../../../shared/types").AnyObject | null;
66
63
  currentReEditMsg: import("../../../../shared/types").AnyObject | null;
@@ -78,6 +75,7 @@ export declare function useVideo(config?: VideoConfig): {
78
75
  info: import("../../../../shared/types").AnyObject | null;
79
76
  };
80
77
  isForward: boolean;
78
+ loading: boolean;
81
79
  };
82
80
  trtcProxy: Ref<any, any>;
83
81
  sendMessage: (message: {
@@ -6,7 +6,17 @@ import { isAudioOrVideoMessage } from '../utils/index.js';
6
6
  import { remove } from 'lodash-es';
7
7
 
8
8
  function useWebSocket(props, data) {
9
- const { stompClient, state, openSession, closeSession, setSessionList, setUpdateSessionItem, setCurrentSessionItem } = data;
9
+ const {
10
+ stompClient,
11
+ state,
12
+ tempState,
13
+ openSession,
14
+ closeSession,
15
+ setSessionList,
16
+ setUpdateSessionItem,
17
+ setCurrentSessionItem,
18
+ appendMsg
19
+ } = data;
10
20
  const groupSessionList = [];
11
21
  initWebSocket();
12
22
  function initWebSocket() {
@@ -77,9 +87,9 @@ function useWebSocket(props, data) {
77
87
  );
78
88
  }
79
89
  async function handleMessage(messageVo, chatType) {
80
- state.currentMsg = messageVo;
90
+ tempState.currentMsg = messageVo;
81
91
  if (messageVo.sessionKey === state.currentSessionItem.sessionKey) {
82
- state.isAppendMsg = true;
92
+ appendMsg();
83
93
  if (messageVo.sender !== state.userInfo.id) {
84
94
  await readMessageApi({
85
95
  chatType,
@@ -115,7 +125,7 @@ function useWebSocket(props, data) {
115
125
  case SUBSCRIBE_MESSAGE_TYPE.MESSAGE: {
116
126
  if (isAudioOrVideoMessage(messageVo.content)) {
117
127
  if (!state.showVideo && !state.showMultipleVideo || messageVo.content.avStatus !== AV_STATUS.IN_CALL) {
118
- state.currentMsg = messageVo;
128
+ tempState.currentMsg = messageVo;
119
129
  Object.assign(state.currentAVMsg, {
120
130
  strRoomId: messageVo.sessionKey,
121
131
  chatMessageType: messageVo.content.chatMessageType,
@@ -26,16 +26,13 @@ export type MsgListItem = {
26
26
  [key: string]: any;
27
27
  };
28
28
  export type IState = {
29
- orgId: number | string;
29
+ orgId: string;
30
30
  currentSessionItem: AnyObject;
31
31
  id: string;
32
32
  userInfo: AnyObject;
33
33
  msgList: MsgListItem[];
34
- currentMsg: AnyObject;
35
- isAppendMsg: boolean;
36
34
  sessionList: AnyObject[];
37
35
  isChangeSession: boolean;
38
- updateSessionItem: AnyObject;
39
36
  isUpdateSession: boolean;
40
37
  currentReferenceMsg: null | AnyObject;
41
38
  currentReEditMsg: null | AnyObject;
@@ -53,6 +50,7 @@ export type IState = {
53
50
  info: AnyObject | null;
54
51
  };
55
52
  isForward: boolean;
53
+ loading: boolean;
56
54
  };
57
55
  export type FileOptions = {
58
56
  file: UploadFileInfo;
@@ -0,0 +1,22 @@
1
+ import { type EventSourceMessage } from '@microsoft/fetch-event-source';
2
+ import { AnyObject, AnyFn } from '../../../../shared/types';
3
+ type SSEClientOptions = {
4
+ headers?: Record<string, string>;
5
+ method?: 'GET' | 'POST';
6
+ withCredentials?: boolean;
7
+ parseJSON?: boolean;
8
+ abortOn?: (msg: EventSourceMessage) => boolean;
9
+ onOpen?: (response: Response) => void;
10
+ onError?: (error: unknown) => void;
11
+ onClose?: () => void;
12
+ };
13
+ export declare class SseClient {
14
+ private controller?;
15
+ private connecting;
16
+ private baseOptions;
17
+ constructor(options?: SSEClientOptions);
18
+ get active(): boolean;
19
+ disconnect(): void;
20
+ connect(url: string, params: AnyObject | undefined, onMessage: AnyFn<[unknown, EventSourceMessage], void>, options?: SSEClientOptions): Promise<void>;
21
+ }
22
+ export default SseClient;
@@ -0,0 +1,97 @@
1
+ import { fetchEventSource } from '@microsoft/fetch-event-source';
2
+
3
+ function toQuery(url, params) {
4
+ if (!params || Object.keys(params).length === 0)
5
+ return url;
6
+ const usp = new URLSearchParams();
7
+ Object.entries(params).forEach(([k, v]) => {
8
+ if (v === void 0 || v === null)
9
+ return;
10
+ usp.append(k, typeof v === "string" ? v : JSON.stringify(v));
11
+ });
12
+ return url + (url.includes("?") ? "&" : "?") + usp.toString();
13
+ }
14
+ function safeParse(data, enable) {
15
+ if (!enable)
16
+ return data;
17
+ try {
18
+ return JSON.parse(data);
19
+ } catch (e) {
20
+ return data;
21
+ }
22
+ }
23
+ class SseClient {
24
+ constructor(options = { method: "POST", parseJSON: true }) {
25
+ this.connecting = false;
26
+ this.baseOptions = options;
27
+ }
28
+ get active() {
29
+ return this.connecting && !!this.controller && !this.controller.signal.aborted;
30
+ }
31
+ disconnect() {
32
+ if (this.controller && !this.controller.signal.aborted) {
33
+ this.controller.abort();
34
+ }
35
+ this.connecting = false;
36
+ }
37
+ async connect(url, params = {}, onMessage, options = {}) {
38
+ var _a, _b, _c, _d;
39
+ const opts = {
40
+ parseJSON: true,
41
+ abortOn: (msg) => msg.data === "[DONE]",
42
+ ...this.baseOptions,
43
+ ...options
44
+ };
45
+ if (this.controller)
46
+ this.controller.abort();
47
+ this.controller = new AbortController();
48
+ this.connecting = true;
49
+ const method = (_a = opts.method) != null ? _a : "POST";
50
+ const headers = { "Content-Type": "application/json", ...(_b = opts.headers) != null ? _b : {} };
51
+ const credentials = opts.withCredentials ? "include" : "same-origin";
52
+ const finalUrl = method === "GET" ? toQuery(url, params) : url;
53
+ const body = method === "POST" ? JSON.stringify(params != null ? params : {}) : void 0;
54
+ try {
55
+ await fetchEventSource(finalUrl, {
56
+ method,
57
+ headers,
58
+ body,
59
+ signal: this.controller.signal,
60
+ credentials,
61
+ openWhenHidden: true,
62
+ onopen: async (r) => {
63
+ var _a2;
64
+ return (_a2 = opts.onOpen) == null ? void 0 : _a2.call(opts, r);
65
+ },
66
+ onmessage: (msg) => {
67
+ var _a2;
68
+ try {
69
+ const data = safeParse(msg.data, opts.parseJSON !== false);
70
+ onMessage(data, msg);
71
+ if (opts.abortOn && opts.abortOn(msg))
72
+ this.disconnect();
73
+ } catch (e) {
74
+ (_a2 = opts.onError) == null ? void 0 : _a2.call(opts, e);
75
+ }
76
+ },
77
+ onclose: () => {
78
+ this.disconnect();
79
+ },
80
+ onerror: (err) => {
81
+ var _a2;
82
+ (_a2 = opts.onError) == null ? void 0 : _a2.call(opts, err);
83
+ this.disconnect();
84
+ throw err;
85
+ }
86
+ });
87
+ } catch (e) {
88
+ (_c = opts.onError) == null ? void 0 : _c.call(opts, e);
89
+ this.disconnect();
90
+ } finally {
91
+ this.connecting = false;
92
+ (_d = opts.onClose) == null ? void 0 : _d.call(opts);
93
+ }
94
+ }
95
+ }
96
+
97
+ export { SseClient, SseClient as default };