cnhis-design-vue 3.2.9-beta.19 → 3.2.9-beta.22

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 (36) hide show
  1. package/es/components/base-search/index.d.ts +2 -0
  2. package/es/components/base-search/src/index.vue.d.ts +2 -0
  3. package/es/components/field-set/src/FieldColor.vue.d.ts +1 -1
  4. package/es/components/field-set/src/FieldFilter.vue.d.ts +1 -1
  5. package/es/components/field-set/src/FieldSet.vue.d.ts +2 -2
  6. package/es/components/field-set/src/components/table-row.vue.d.ts +1 -1
  7. package/es/components/field-set/src/components/table-row.vue2.js +1 -1
  8. package/es/components/iho-chat/index.d.ts +245 -1
  9. package/es/components/iho-chat/src/Index.vue.d.ts +245 -1
  10. package/es/components/iho-chat/src/Index.vue2.js +1 -1
  11. package/es/components/iho-chat/src/components/ChatAdd.vue.d.ts +1 -0
  12. package/es/components/iho-chat/src/components/ChatAdd.vue2.js +1 -1
  13. package/es/components/iho-chat/src/components/ChatFile.vue.d.ts +121 -1
  14. package/es/components/iho-chat/src/components/ChatFile.vue2.js +1 -1
  15. package/es/components/iho-chat/src/components/ChatFooter.vue.d.ts +1 -0
  16. package/es/components/iho-chat/src/components/ChatHeader.vue.d.ts +122 -1
  17. package/es/components/iho-chat/src/components/ChatMain.vue.d.ts +120 -0
  18. package/es/components/iho-chat/src/components/ChatMain.vue2.js +1 -1
  19. package/es/components/iho-chat/src/components/ChatSet.vue.d.ts +1 -0
  20. package/es/components/iho-chat/src/components/ContextMenu.js +1 -1
  21. package/es/components/iho-chat/src/components/MultipleVideo.vue.d.ts +1 -0
  22. package/es/components/iho-chat/src/hooks/useSession.js +1 -1
  23. package/es/components/iho-chat/src/hooks/useState.d.ts +5 -0
  24. package/es/components/iho-chat/src/hooks/useState.js +1 -1
  25. package/es/components/iho-chat/src/utils/chatSock.js +1 -1
  26. package/es/components/iho-chat/style/index.css +1 -1
  27. package/es/components/index.css +1 -1
  28. package/es/components/quick-search/index.d.ts +3 -0
  29. package/es/components/quick-search/src/index.vue.d.ts +3 -0
  30. package/es/components/table-filter/src/hooks/useAdvanced.d.ts +1 -0
  31. package/es/components/table-filter/src/hooks/useAdvanced.js +1 -1
  32. package/es/components/table-filter/src/hooks/useRenderWidget.js +1 -1
  33. package/es/components/table-filter/src/types/index.d.ts +2 -0
  34. package/es/shared/package.json.js +1 -1
  35. package/es/shared/utils/index.js +1 -1
  36. package/package.json +2 -2
@@ -245,6 +245,7 @@ declare const _default: import("vue").DefineComponent<{}, {
245
245
  options: import("vue").Ref<AnyObject[]>;
246
246
  groupName: import("vue").Ref<string>;
247
247
  checkedSourceIds: import("vue").Ref<(string | number)[]>;
248
+ remark: import("vue").Ref<string>;
248
249
  userList: import("vue").Ref<AnyObject[]>;
249
250
  handleInput: () => void;
250
251
  _disabledIds: import("vue").ComputedRef<any[]>;
@@ -324,6 +325,11 @@ declare const _default: import("vue").DefineComponent<{}, {
324
325
  };
325
326
  }>> & {}>>;
326
327
  state: import("../types").IState;
328
+ relayMessage: (param: {
329
+ checkedIds: string[];
330
+ remark: string;
331
+ content: AnyObject;
332
+ }) => Promise<void>;
327
333
  imageList: import("vue").Ref<AnyObject[]>;
328
334
  fileList: import("vue").Ref<AnyObject[]>;
329
335
  imageRef: import("vue").Ref<any>;
@@ -338,7 +344,7 @@ declare const _default: import("vue").DefineComponent<{}, {
338
344
  handleSearch: () => Promise<void>;
339
345
  formatImageList: (data: AnyObject[]) => {
340
346
  label: string;
341
- list: unknown;
347
+ list: any;
342
348
  }[];
343
349
  resetAndSearch: () => void;
344
350
  title: import("vue").ComputedRef<"聊天图片" | "聊天文件">;
@@ -351,8 +357,122 @@ declare const _default: import("vue").DefineComponent<{}, {
351
357
  NIcon: any;
352
358
  NTooltip: any;
353
359
  SearchOutline: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, import("vue").EmitsOptions, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{}>>, {}>;
360
+ OpenOutline: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, import("vue").EmitsOptions, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{}>>, {}>;
354
361
  DownloadOutline: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, import("vue").EmitsOptions, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{}>>, {}>;
355
362
  downloadFile: typeof import("../utils").downloadFile;
363
+ ChatAdd: import("vue").DefineComponent<{
364
+ title: {
365
+ type: StringConstructor;
366
+ default: string;
367
+ };
368
+ mode: {
369
+ type: StringConstructor;
370
+ default: string;
371
+ };
372
+ options: {
373
+ type: import("vue").PropType<AnyObject[]>;
374
+ };
375
+ disabledIds: {
376
+ type: import("vue").PropType<string[]>;
377
+ default: () => never[];
378
+ };
379
+ defaultValue: {
380
+ type: import("vue").PropType<AnyObject[]>;
381
+ default: () => never[];
382
+ };
383
+ }, {
384
+ props: Readonly<import("@vue/shared").LooseRequired<Readonly<import("vue").ExtractPropTypes<{
385
+ title: {
386
+ type: StringConstructor;
387
+ default: string;
388
+ };
389
+ mode: {
390
+ type: StringConstructor;
391
+ default: string;
392
+ };
393
+ options: {
394
+ type: import("vue").PropType<AnyObject[]>;
395
+ };
396
+ disabledIds: {
397
+ type: import("vue").PropType<string[]>;
398
+ default: () => never[];
399
+ };
400
+ defaultValue: {
401
+ type: import("vue").PropType<AnyObject[]>;
402
+ default: () => never[];
403
+ };
404
+ }>> & {
405
+ onComfirm?: ((...args: any[]) => any) | undefined;
406
+ }>>;
407
+ emit: (event: "comfirm", ...args: any[]) => void;
408
+ state: import("../types").IState;
409
+ setCurrentSessionItem: (item: AnyObject) => void;
410
+ listRef: import("vue").Ref<any>;
411
+ keyword: import("vue").Ref<string>;
412
+ showModal: import("vue").Ref<boolean>;
413
+ checkedOptions: import("vue").Ref<AnyObject[]>;
414
+ options: import("vue").Ref<AnyObject[]>;
415
+ groupName: import("vue").Ref<string>;
416
+ checkedSourceIds: import("vue").Ref<(string | number)[]>;
417
+ remark: import("vue").Ref<string>;
418
+ userList: import("vue").Ref<AnyObject[]>;
419
+ handleInput: () => void;
420
+ _disabledIds: import("vue").ComputedRef<any[]>;
421
+ defaultOptions: import("vue").ComputedRef<{
422
+ id: any;
423
+ name: any;
424
+ avatar: any;
425
+ }[]>;
426
+ checkedIds: import("vue").ComputedRef<any[]>;
427
+ btnDisabled: import("vue").ComputedRef<boolean>;
428
+ allChecked: import("vue").WritableComputedRef<boolean>;
429
+ handlePositiveClick: () => Promise<void>;
430
+ updateCheckedSourceIds: () => void;
431
+ handleSourceIdsUpdate: (value: (string | number)[], meta: {
432
+ actionType: "check" | "uncheck";
433
+ value: string | number;
434
+ }) => void;
435
+ closeTag: (id: string) => void;
436
+ NModal: any;
437
+ NButton: any;
438
+ NSpace: any;
439
+ NAvatar: any;
440
+ NIcon: any;
441
+ NTag: any;
442
+ NInput: any;
443
+ NCheckbox: any;
444
+ NCheckboxGroup: any;
445
+ NTooltip: any;
446
+ SearchOutline: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, import("vue").EmitsOptions, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{}>>, {}>;
447
+ AddOutline: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, import("vue").EmitsOptions, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{}>>, {}>;
448
+ }, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, "comfirm"[], "comfirm", import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
449
+ title: {
450
+ type: StringConstructor;
451
+ default: string;
452
+ };
453
+ mode: {
454
+ type: StringConstructor;
455
+ default: string;
456
+ };
457
+ options: {
458
+ type: import("vue").PropType<AnyObject[]>;
459
+ };
460
+ disabledIds: {
461
+ type: import("vue").PropType<string[]>;
462
+ default: () => never[];
463
+ };
464
+ defaultValue: {
465
+ type: import("vue").PropType<AnyObject[]>;
466
+ default: () => never[];
467
+ };
468
+ }>> & {
469
+ onComfirm?: ((...args: any[]) => any) | undefined;
470
+ }, {
471
+ defaultValue: AnyObject[];
472
+ mode: string;
473
+ title: string;
474
+ disabledIds: string[];
475
+ }>;
356
476
  }, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
357
477
  type: {
358
478
  type: StringConstructor;
@@ -565,6 +685,7 @@ declare const _default: import("vue").DefineComponent<{}, {
565
685
  options: import("vue").Ref<AnyObject[]>;
566
686
  groupName: import("vue").Ref<string>;
567
687
  checkedSourceIds: import("vue").Ref<(string | number)[]>;
688
+ remark: import("vue").Ref<string>;
568
689
  userList: import("vue").Ref<AnyObject[]>;
569
690
  handleInput: () => void;
570
691
  _disabledIds: import("vue").ComputedRef<any[]>;
@@ -7,12 +7,18 @@ declare const _default: import("vue").DefineComponent<{}, {
7
7
  chatMainRef: import("vue").Ref<HTMLElement | undefined>;
8
8
  state: import("../types").IState;
9
9
  setMsgList: (list?: AnyObject[]) => void;
10
+ relayMessage: (param: {
11
+ checkedIds: string[];
12
+ remark: string;
13
+ content: AnyObject;
14
+ }) => Promise<void>;
10
15
  setCurrentSessionItem: (item: AnyObject) => void;
11
16
  isGroupChat: import("vue").ComputedRef<boolean>;
12
17
  contextmenuRef: import("vue").Ref<any>;
13
18
  showMenu: import("vue").Ref<boolean>;
14
19
  menuPosition: any;
15
20
  menuMsgId: import("vue").Ref<any>;
21
+ relayTriggerRef: import("vue").Ref<any>;
16
22
  pageInfo: {
17
23
  page: number;
18
24
  hasMore: boolean;
@@ -39,6 +45,7 @@ declare const _default: import("vue").DefineComponent<{}, {
39
45
  resetInfo: () => void;
40
46
  setReferenceMsg: (msgItem: AnyObject) => void;
41
47
  handleSelect: (key: string, msgItem: AnyObject) => void;
48
+ handleRelay: (checkedIds: string[], remark: string) => void;
42
49
  reEdit: (item: AnyObject) => void;
43
50
  NAvatar: any;
44
51
  NImageGroup: any;
@@ -224,6 +231,119 @@ declare const _default: import("vue").DefineComponent<{}, {
224
231
  }, {
225
232
  show: boolean;
226
233
  }>;
234
+ ChatAdd: import("vue").DefineComponent<{
235
+ title: {
236
+ type: StringConstructor;
237
+ default: string;
238
+ };
239
+ mode: {
240
+ type: StringConstructor;
241
+ default: string;
242
+ };
243
+ options: {
244
+ type: import("vue").PropType<AnyObject[]>;
245
+ };
246
+ disabledIds: {
247
+ type: import("vue").PropType<string[]>;
248
+ default: () => never[];
249
+ };
250
+ defaultValue: {
251
+ type: import("vue").PropType<AnyObject[]>;
252
+ default: () => never[];
253
+ };
254
+ }, {
255
+ props: Readonly<import("@vue/shared").LooseRequired<Readonly<import("vue").ExtractPropTypes<{
256
+ title: {
257
+ type: StringConstructor;
258
+ default: string;
259
+ };
260
+ mode: {
261
+ type: StringConstructor;
262
+ default: string;
263
+ };
264
+ options: {
265
+ type: import("vue").PropType<AnyObject[]>;
266
+ };
267
+ disabledIds: {
268
+ type: import("vue").PropType<string[]>;
269
+ default: () => never[];
270
+ };
271
+ defaultValue: {
272
+ type: import("vue").PropType<AnyObject[]>;
273
+ default: () => never[];
274
+ };
275
+ }>> & {
276
+ onComfirm?: ((...args: any[]) => any) | undefined;
277
+ }>>;
278
+ emit: (event: "comfirm", ...args: any[]) => void;
279
+ state: import("../types").IState;
280
+ setCurrentSessionItem: (item: AnyObject) => void;
281
+ listRef: import("vue").Ref<any>;
282
+ keyword: import("vue").Ref<string>;
283
+ showModal: import("vue").Ref<boolean>;
284
+ checkedOptions: import("vue").Ref<AnyObject[]>;
285
+ options: import("vue").Ref<AnyObject[]>;
286
+ groupName: import("vue").Ref<string>;
287
+ checkedSourceIds: import("vue").Ref<(string | number)[]>;
288
+ remark: import("vue").Ref<string>;
289
+ userList: import("vue").Ref<AnyObject[]>;
290
+ handleInput: () => void;
291
+ _disabledIds: import("vue").ComputedRef<any[]>;
292
+ defaultOptions: import("vue").ComputedRef<{
293
+ id: any;
294
+ name: any;
295
+ avatar: any;
296
+ }[]>;
297
+ checkedIds: import("vue").ComputedRef<any[]>;
298
+ btnDisabled: import("vue").ComputedRef<boolean>;
299
+ allChecked: import("vue").WritableComputedRef<boolean>;
300
+ handlePositiveClick: () => Promise<void>;
301
+ updateCheckedSourceIds: () => void;
302
+ handleSourceIdsUpdate: (value: (string | number)[], meta: {
303
+ actionType: "check" | "uncheck";
304
+ value: string | number;
305
+ }) => void;
306
+ closeTag: (id: string) => void;
307
+ NModal: any;
308
+ NButton: any;
309
+ NSpace: any;
310
+ NAvatar: any;
311
+ NIcon: any;
312
+ NTag: any;
313
+ NInput: any;
314
+ NCheckbox: any;
315
+ NCheckboxGroup: any;
316
+ NTooltip: any;
317
+ SearchOutline: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, import("vue").EmitsOptions, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{}>>, {}>;
318
+ AddOutline: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, import("vue").EmitsOptions, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{}>>, {}>;
319
+ }, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, "comfirm"[], "comfirm", import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
320
+ title: {
321
+ type: StringConstructor;
322
+ default: string;
323
+ };
324
+ mode: {
325
+ type: StringConstructor;
326
+ default: string;
327
+ };
328
+ options: {
329
+ type: import("vue").PropType<AnyObject[]>;
330
+ };
331
+ disabledIds: {
332
+ type: import("vue").PropType<string[]>;
333
+ default: () => never[];
334
+ };
335
+ defaultValue: {
336
+ type: import("vue").PropType<AnyObject[]>;
337
+ default: () => never[];
338
+ };
339
+ }>> & {
340
+ onComfirm?: ((...args: any[]) => any) | undefined;
341
+ }, {
342
+ defaultValue: AnyObject[];
343
+ mode: string;
344
+ title: string;
345
+ disabledIds: string[];
346
+ }>;
227
347
  simplifyMessage: typeof simplifyMessage;
228
348
  isAudioOrVideoMessage: typeof isAudioOrVideoMessage;
229
349
  getAVTime: typeof getAVTime;
@@ -1 +1 @@
1
- import{defineComponent as e,ref as t,computed as n,watch as s,openBlock as o,createElementBlock as i,normalizeClass as r,unref as a,normalizeStyle as c,createVNode as l,withCtx as u,Fragment as m,renderList as p,toDisplayString as d,createCommentVNode as f,createBlock as g,createElementVNode as v,createTextVNode as y,withModifiers as h,nextTick as T}from"vue";import{NImageGroup as M,NButton as k,NAvatar as _,NImage as x,NIcon as I,NSpace as w,NButtonGroup as C,NTooltip as S}from"naive-ui";import{format as E}from"date-fns";import{getHistoryRecordApi as j,readMessageApi as L}from"../api/index.js";import{useState as b}from"../hooks/useState.js";import{useSession as z}from"../hooks/useSession.js";import{MESSAGE_TYPE as A}from"../constants/index.js";import"trtc-sdk-v5";import{isAudioOrVideoMessage as H,simplifyMessage as D,getAVTime as R,downloadFile as N}from"../utils/index.js";import{first as O,last as P}from"lodash-es";import q from"./PersonProfile.vue.js";import B from"./MessageTemplate.vue.js";import{emojis as J}from"../utils/emoji.js";import W from"./ContextMenu.js";import"../../../../shared/utils/index.js";import"@vueuse/core";import"@vue/shared";import"@vueuse/shared";import"../../../../shared/hooks/selectHooks/useSearchContent.js";import{CallOutline as U,VideocamOutline as X,DocumentSharp as F,ChatbubbleEllipsesOutline as G,EllipsisHorizontal as K,ArrowDownSharp as Y}from"@vicons/ionicons5";import{useScrollLoading as $}from"../../../../shared/hooks/useScrollLoading.js";const Q={key:0,class:"tip-text"},V={key:1,class:"tip-text"},Z={key:2,class:"message-box"},ee={key:0,class:"content-box"},te={class:"name-box"},ne=["data-time"],se=["onContextmenu"],oe={key:0,class:"reference-content"},ie=["innerHTML"],re=["src"],ae=["innerHTML"],ce=["innerHTML"],le={style:{"margin-left":"8px"}},ue={class:"size"};var me=e({__name:"ChatMain",setup(e){const me=t(),{state:pe,setMsgList:de}=b(),{setCurrentSessionItem:fe,isGroupChat:ge}=z(pe),ve=t(),ye=t(!1),he=t({left:0,top:0}),Te=t(),Me={page:0,hasMore:!0,lastSendTime:E(new Date,"yyyy-MM-dd HH:mm:ss")},ke=n((()=>({"--c-tip-top":ge.value?"1px":"-20px","--c-tip-gap":ge.value?"10px":"0px"})));function _e({nodes:e}){var t,n;const{_ctx:s}=null==(t=e.download)?void 0:t.children,o=s?null==(n=null==s?void 0:s.proxy)?void 0:n.previewSrc:"";return[e.prev,e.next,e.rotateCounterclockwise,e.rotateClockwise,e.resizeToOriginalSize,e.zoomOut,e.zoomIn,l(S,null,{trigger:()=>l(I,{style:"cursor: pointer",color:"rgba(255, 255, 255, 0.75",size:24,component:Y,onClick:()=>o&&N(o,"img")},null),default:()=>"下载"}),e.close]}async function xe(){try{if(!Me.hasMore)return;Me.page++;const e=await j({sessionKey:pe.currentSessionItem.sessionKey,page:Me.page,lastSendTime:Me.lastSendTime});if(!Array.isArray(e)||0===e.length)return Me.hasMore=!1,console.log("接口返回不是一个数组,或者没有更多消息了");const t=O(e).id;Me.lastSendTime=P(e).sendTime,de(Me.page>1?[...e,...pe.msgList]:e),1===Me.page&&pe.currentSessionItem.unreadNum&&(await L({chatType:pe.currentSessionItem.chatType,messageIdSet:[t],receiver:pe.userInfo.id,sender:pe.currentSessionItem.receiver}),fe({unreadNum:0}))}catch(e){console.log(e)}}async function Ie(e,t){Te.value=t,async function(e){var t,n,s,o,i,r;ye.value=!0,await T();const{clientX:a,clientY:c}=e,{width:l=0,height:u=0,left:m=0,top:p=0}=(null==(t=me.value)?void 0:t.getBoundingClientRect())||{},d=null!=(o=null==(s=null==(n=ve.value)?void 0:n.$el)?void 0:s.getBoundingClientRect().height)?o:220,f=null!=(r=null==(i=me.value)?void 0:i.scrollTop)?r:0,g=5,v={};a<=m+l/2?v.left=a-m+g+"px":v.right=m+l-a-g+"px";c-p<d/2?v.top=f+g+"px":p+u-c<=d/2?v.bottom=Math.abs(f)+g+"px":v.top=f+c-p-d/2+"px";he.value=v}(e)}function we(e){const{chatMessageType:t,messageTemplate:n}=e.content;return t!==A.TEMPLATE||!!n}function Ce(e){const{chatMessageType:t}=e.content;return e.sender===pe.userInfo.id&&Date.now()-new Date(e.sendTime).getTime()<864e5&&[A.TEXT,A.EMOJI].includes(t)}function Se(e){const{chatMessageType:t,msg:n=""}=e.content;if(t===A.BLEND){const e=n.match(/<img[^>]*>/gi);return!e||!e.length}return t&&[A.TEXT,A.EMOJI].includes(t)}function Ee(e){const{chatMessageType:t,msg:n=""}=e.content,s=n.match(/<img[^>]*>/gi);return t===A.BLEND&&s&&s.length}function je(e,t){var n,s;const{chatMessageType:o,messageTemplate:i}=e.content;if(o===A.TEMPLATE)return"system"===t?2==(null==(n=null==i?void 0:i.setting)?void 0:n.style.id):2!=(null==(s=null==i?void 0:i.setting)?void 0:s.style.id)}function Le(e){var t,n;const{chatMessageType:s,messageTemplate:o}=e;return s===A.TEMPLATE&&3==(null==(n=null==(t=null==o?void 0:o.setting)?void 0:t.style)?void 0:n.id)}function be(e,t){var n;const s=new Date(e.sendTime).getTime(),o=null==(n=pe.msgList[t+1])?void 0:n.sendTime;if(o){return s-new Date(o).getTime()>3e5}return!0}function ze(e){pe.currentReferenceMsg=e,pe.currentReferenceMsg.content.referenceContent=null,Object.assign(pe.currentReferenceMsg,{chatType:pe.currentSessionItem.chatType,receiver:pe.currentSessionItem.receiver,receiverAvatar:pe.currentSessionItem.avatar,receiverName:pe.currentSessionItem.name})}function Ae(e,t){"reply"===e&&ze(t)}return $(me,(()=>{xe()}),"top",(()=>{ye.value=!1})),s((()=>pe.id),(e=>{e&&(pe.currentReferenceMsg=null,Object.assign(Me,{page:0,hasMore:!0,lastSendTime:E(new Date,"yyyy-MM-dd HH:mm:ss")}),xe())}),{immediate:!0}),s((()=>pe.isAppendMsg),(e=>{e&&(de([...pe.msgList,pe.currentMsg]),async function(){var e,t,n;await T();const s=null!=(t=null==(e=me.value)?void 0:e.scrollHeight)?t:0;null==(n=me.value)||n.scrollTo({top:s,behavior:"auto"})}(),pe.isAppendMsg=!1)}),{immediate:!0}),(e,t)=>(o(),i("div",{class:r(["chat-main",{"home-bg":!a(pe).id}]),ref_key:"chatMainRef",ref:me,style:c(a(ke))},[l(a(M),{"show-toolbar-tooltip":"","render-toolbar":_e},{default:u((()=>[(o(!0),i(m,null,p(a(pe).msgList,((e,t)=>(o(),i(m,{key:e.id},[we(e)?(o(),i("div",{key:0,class:r(["message-item",{"message-item--mine":e.sender==a(pe).userInfo.id}])},[be(e,t)?(o(),i("p",Q,d(e.__sendTime),1)):f("v-if",!0),je(e,"system")||"WITHDRAWN"===e.status?(o(),i(m,{key:1},[je(e,"system")?(o(),g(B,{key:0,data:e},null,8,["data"])):f("v-if",!0),"WITHDRAWN"===e.status?(o(),i("p",V,[v("span",null,d(e.sender==a(pe).userInfo.id?"你":e.senderName)+"撤回了一条消息",1),Ce(e)?(o(),g(a(k),{key:0,size:"tiny",style:{color:"var(--c-primary-color)","margin-left":"5px"},text:"",onClick:()=>function(e){pe.currentReEditMsg=e}(e)},{default:u((()=>[y(" 重新编辑 ")])),_:2},1032,["onClick"])):f("v-if",!0)])):f("v-if",!0)],64)):(o(),i("div",Z,[l(q,{"user-id":e.sender,placement:e.sender==a(pe).userInfo.id?"left":"right"},{trigger:u((()=>[l(a(_),{round:"",size:38,src:e.senderAvatar},null,8,["src"])])),_:2},1032,["user-id","placement"]),e.content?(o(),i("div",ee,[v("div",te,[v("span",{class:"name","data-time":e.__time},d(a(ge)?e.senderName:""),9,ne)]),v("div",{class:r(["content",{emoji:e.content.chatMessageType===a(A).EMOJI,template:e.content.chatMessageType===a(A).TEMPLATE,"template--3":Le(e.content),"audio-video":a(H)(e.content),file:e.content.chatMessageType===a(A).FILE}]),onContextmenu:h((t=>Ie(t,e.id)),["prevent"])},[Se(e)?(o(),i(m,{key:0},[e.content.referenceContent?(o(),i("div",oe,[v("span",null,d(e.content.referenceContent.senderName)+":",1),v("pre",{innerHTML:a(D)(e.content.referenceContent.content)},null,8,ie)])):f("v-if",!0),e.content.chatMessageType===a(A).EMOJI?(o(),i("img",{key:1,class:r([e.content.referenceContent?"emoji--min":"emoji--big"]),src:a(J).findEmoji(e.__content)},null,10,re)):(o(),i("pre",{key:2,innerHTML:e.__content},null,8,ae))],64)):f("v-if",!0),Ee(e)?(o(),i("pre",{key:1,innerHTML:e.__content},null,8,ce)):f("v-if",!0),je(e,"template")?(o(),g(B,{key:2,data:e},null,8,["data"])):f("v-if",!0),e.content.chatMessageType===a(A).IMAGE?(o(),g(a(x),{key:3,width:"240",src:e.__content},null,8,["src"])):f("v-if",!0),a(H)(e.content)?(o(),i(m,{key:4},[l(a(I),{class:r({"is-audio":e.content.chatMessageType===a(A).AUDIO}),component:e.content.chatMessageType===a(A).AUDIO?a(U):a(X)},null,8,["class","component"]),v("span",le,d(a(R)(e.__content)),1)],64)):f("v-if",!0),e.content.chatMessageType===a(A).FILE?(o(),g(a(w),{key:5,"wrap-item":!1},{default:u((()=>[l(a(I),{class:"icon-file",size:"40",component:a(F)},null,8,["component"]),l(a(w),{"wrap-item":!1,vertical:"",justify:"space-between",style:{"row-gap":"0"}},{default:u((()=>[v("span",null,d(e.__content),1),v("span",ue,d(e.__size),1)])),_:2},1024)])),_:2},1024)):f("v-if",!0),l(a(C),{class:"quick-menu"},{default:u((()=>[a(H)(e.content)?f("v-if",!0):(o(),i(m,{key:0},[f(' <n-button quaternary size="tiny">\r\n\t\t\t\t\t\t\t\t\t\t\t\t<template #icon>\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t<i class="chat--iconfont chat--icon-face" />\r\n\t\t\t\t\t\t\t\t\t\t\t\t</template>\r\n\t\t\t\t\t\t\t\t\t\t\t</n-button> '),l(a(k),{quaternary:"",size:"tiny",onClick:()=>ze(e)},{icon:u((()=>[l(a(I),{size:"17",component:a(G)},null,8,["component"])])),_:2},1032,["onClick"])],64)),l(a(k),{quaternary:"",size:"tiny",onClick:t=>Ie(t,e.id)},{icon:u((()=>[l(a(I),{size:"14",component:a(K)},null,8,["component"])])),_:2},1032,["onClick"])])),_:2},1024)],42,se)])):f("v-if",!0)]))],2)):f("v-if",!0)],64)))),128))])),_:1}),l(a(W),{ref_key:"contextmenuRef",ref:ve,show:ye.value,"onUpdate:show":t[0]||(t[0]=e=>ye.value=e),position:he.value,"msg-id":Te.value,onSelect:Ae},null,8,["show","position","msg-id"])],6))}});export{me as default};
1
+ import{defineComponent as e,ref as t,computed as n,watch as s,openBlock as o,createElementBlock as i,normalizeClass as r,unref as a,normalizeStyle as c,createVNode as l,withCtx as u,Fragment as m,renderList as p,toDisplayString as d,createCommentVNode as f,createBlock as g,createElementVNode as v,createTextVNode as y,withModifiers as h,nextTick as T}from"vue";import{NImageGroup as M,NButton as k,NAvatar as _,NImage as x,NIcon as I,NSpace as C,NButtonGroup as w,NTooltip as S}from"naive-ui";import{format as j}from"date-fns";import{getHistoryRecordApi as E,readMessageApi as L}from"../api/index.js";import{useState as b}from"../hooks/useState.js";import{useSession as A}from"../hooks/useSession.js";import{MESSAGE_TYPE as z}from"../constants/index.js";import"trtc-sdk-v5";import{isAudioOrVideoMessage as H,simplifyMessage as D,getAVTime as R,downloadFile as N}from"../utils/index.js";import{first as O,last as P}from"lodash-es";import q from"./PersonProfile.vue.js";import B from"./MessageTemplate.vue.js";import{emojis as J}from"../utils/emoji.js";import W from"./ContextMenu.js";import U from"./ChatAdd.vue.js";import"../../../../shared/utils/index.js";import"@vueuse/core";import"@vue/shared";import"@vueuse/shared";import"../../../../shared/hooks/selectHooks/useSearchContent.js";import{CallOutline as X,VideocamOutline as F,DocumentSharp as G,ChatbubbleEllipsesOutline as K,EllipsisHorizontal as Y,ArrowDownSharp as $}from"@vicons/ionicons5";import{useScrollLoading as Q}from"../../../../shared/hooks/useScrollLoading.js";const V={key:0,class:"tip-text"},Z={key:1,class:"tip-text"},ee={key:2,class:"message-box"},te={key:0,class:"content-box"},ne={class:"name-box"},se=["data-time"],oe=["onContextmenu"],ie={key:0,class:"reference-content"},re=["innerHTML"],ae=["src"],ce=["innerHTML"],le=["innerHTML"],ue={style:{"margin-left":"8px"}},me={class:"size"};var pe=e({__name:"ChatMain",setup(e){const pe=t(),{state:de,setMsgList:fe,relayMessage:ge}=b(),{setCurrentSessionItem:ve,isGroupChat:ye}=A(de),he=t(),Te=t(!1),Me=t({left:0,top:0}),ke=t(),_e=t(),xe={page:0,hasMore:!0,lastSendTime:j(new Date,"yyyy-MM-dd HH:mm:ss")},Ie=n((()=>({"--c-tip-top":ye.value?"1px":"-20px","--c-tip-gap":ye.value?"10px":"0px"})));function Ce({nodes:e}){var t,n;const{_ctx:s}=null==(t=e.download)?void 0:t.children,o=s?null==(n=null==s?void 0:s.proxy)?void 0:n.previewSrc:"";return[e.prev,e.next,e.rotateCounterclockwise,e.rotateClockwise,e.resizeToOriginalSize,e.zoomOut,e.zoomIn,l(S,null,{trigger:()=>l(I,{style:"cursor: pointer",color:"rgba(255, 255, 255, 0.75",size:24,component:$,onClick:()=>o&&N(o,"img")},null),default:()=>"下载"}),e.close]}async function we(){try{if(!xe.hasMore)return;xe.page++;const e=await E({sessionKey:de.currentSessionItem.sessionKey,page:xe.page,lastSendTime:xe.lastSendTime});if(!Array.isArray(e)||0===e.length)return xe.hasMore=!1,console.log("接口返回不是一个数组,或者没有更多消息了");const t=O(e).id;xe.lastSendTime=P(e).sendTime,fe(xe.page>1?[...de.msgList,...e]:e),1===xe.page&&de.currentSessionItem.unreadNum&&(await L({chatType:de.currentSessionItem.chatType,messageIdSet:[t],receiver:de.userInfo.id,sender:de.currentSessionItem.receiver}),ve({unreadNum:0}))}catch(e){console.log(e)}}async function Se(e,t){ke.value=t,async function(e){var t,n,s,o,i,r;Te.value=!0,await T();const{clientX:a,clientY:c}=e,{width:l=0,height:u=0,left:m=0,top:p=0}=(null==(t=pe.value)?void 0:t.getBoundingClientRect())||{},d=null!=(o=null==(s=null==(n=he.value)?void 0:n.$el)?void 0:s.getBoundingClientRect().height)?o:220,f=null!=(r=null==(i=pe.value)?void 0:i.scrollTop)?r:0,g=5,v={};a<=m+l/2?v.left=a-m+g+"px":v.right=m+l-a-g+"px";c-p<d/2?v.top=f+g+"px":p+u-c<=d/2?v.bottom=Math.abs(f)+g+"px":v.top=f+c-p-d/2+"px";Me.value=v}(e)}function je(e){const{chatMessageType:t,messageTemplate:n}=e.content;return t!==z.TEMPLATE||!!n}function Ee(e){const{chatMessageType:t}=e.content;return e.sender===de.userInfo.id&&Date.now()-new Date(e.sendTime).getTime()<864e5&&[z.TEXT,z.EMOJI].includes(t)}function Le(e){const{chatMessageType:t,msg:n=""}=e.content;if(t===z.BLEND){const e=n.match(/<img[^>]*>/gi);return!e||!e.length}return t&&[z.TEXT,z.EMOJI].includes(t)}function be(e){const{chatMessageType:t,msg:n=""}=e.content,s=n.match(/<img[^>]*>/gi);return t===z.BLEND&&s&&s.length}function Ae(e,t){var n,s;const{chatMessageType:o,messageTemplate:i}=e.content;if(o===z.TEMPLATE)return"system"===t?2==(null==(n=null==i?void 0:i.setting)?void 0:n.style.id):2!=(null==(s=null==i?void 0:i.setting)?void 0:s.style.id)}function ze(e){var t,n;const{chatMessageType:s,messageTemplate:o}=e;return s===z.TEMPLATE&&3==(null==(n=null==(t=null==o?void 0:o.setting)?void 0:t.style)?void 0:n.id)}function He(e,t){var n;const s=new Date(e.sendTime).getTime(),o=null==(n=de.msgList[t+1])?void 0:n.sendTime;if(o){return s-new Date(o).getTime()>3e5}return!0}function De(e){de.currentReferenceMsg=e,de.currentReferenceMsg.content.referenceContent=null,Object.assign(de.currentReferenceMsg,{chatType:de.currentSessionItem.chatType,receiver:de.currentSessionItem.receiver,receiverAvatar:de.currentSessionItem.avatar,receiverName:de.currentSessionItem.name})}function Re(e,t){var n;"reply"!==e?"relay"===e&&(null==(n=_e.value)||n.click()):De(t)}function Ne(e,t){const n=de.msgList.find((e=>e.id===ke.value));ge({checkedIds:e,remark:t,content:n.content})}return Q(pe,(()=>{we()}),"top",(()=>{Te.value=!1})),s((()=>de.id),(e=>{e&&(de.currentReferenceMsg=null,Object.assign(xe,{page:0,hasMore:!0,lastSendTime:j(new Date,"yyyy-MM-dd HH:mm:ss")}),we())}),{immediate:!0}),s((()=>de.isAppendMsg),(e=>{e&&(fe([de.currentMsg,...de.msgList]),async function(){var e,t,n;await T();const s=null!=(t=null==(e=pe.value)?void 0:e.scrollHeight)?t:0;null==(n=pe.value)||n.scrollTo({top:s,behavior:"auto"})}(),de.isAppendMsg=!1)}),{immediate:!0}),(e,t)=>(o(),i("div",{class:r(["chat-main",{"home-bg":!a(de).id}]),ref_key:"chatMainRef",ref:pe,style:c(a(Ie))},[l(a(M),{"show-toolbar-tooltip":"","render-toolbar":Ce},{default:u((()=>[(o(!0),i(m,null,p(a(de).msgList,((e,t)=>(o(),i(m,{key:e.id},[je(e)?(o(),i("div",{key:0,class:r(["message-item",{"message-item--mine":e.sender==a(de).userInfo.id}])},[He(e,t)?(o(),i("p",V,d(e.__sendTime),1)):f("v-if",!0),Ae(e,"system")||"WITHDRAWN"===e.status?(o(),i(m,{key:1},[Ae(e,"system")?(o(),g(B,{key:0,data:e},null,8,["data"])):f("v-if",!0),"WITHDRAWN"===e.status?(o(),i("p",Z,[v("span",null,d(e.sender==a(de).userInfo.id?"你":e.senderName)+"撤回了一条消息",1),Ee(e)?(o(),g(a(k),{key:0,size:"tiny",style:{color:"var(--c-primary-color)","margin-left":"5px"},text:"",onClick:()=>function(e){de.currentReEditMsg=e}(e)},{default:u((()=>[y(" 重新编辑 ")])),_:2},1032,["onClick"])):f("v-if",!0)])):f("v-if",!0)],64)):(o(),i("div",ee,[l(q,{"user-id":e.sender,placement:e.sender==a(de).userInfo.id?"left":"right"},{trigger:u((()=>[l(a(_),{round:"",size:38,src:e.senderAvatar},null,8,["src"])])),_:2},1032,["user-id","placement"]),e.content?(o(),i("div",te,[v("div",ne,[v("span",{class:"name","data-time":e.__time},d(a(ye)?e.senderName:""),9,se)]),v("div",{class:r(["content",{emoji:e.content.chatMessageType===a(z).EMOJI,template:e.content.chatMessageType===a(z).TEMPLATE,"template--3":ze(e.content),"audio-video":a(H)(e.content),file:e.content.chatMessageType===a(z).FILE}]),onContextmenu:h((t=>Se(t,e.id)),["prevent"])},[Le(e)?(o(),i(m,{key:0},[e.content.referenceContent?(o(),i("div",ie,[v("span",null,d(e.content.referenceContent.senderName)+":",1),v("pre",{innerHTML:a(D)(e.content.referenceContent.content)},null,8,re)])):f("v-if",!0),e.content.chatMessageType===a(z).EMOJI?(o(),i("img",{key:1,class:r([e.content.referenceContent?"emoji--min":"emoji--big"]),src:a(J).findEmoji(e.__content)},null,10,ae)):(o(),i("pre",{key:2,innerHTML:e.__content},null,8,ce))],64)):f("v-if",!0),be(e)?(o(),i("pre",{key:1,innerHTML:e.__content},null,8,le)):f("v-if",!0),Ae(e,"template")?(o(),g(B,{key:2,data:e},null,8,["data"])):f("v-if",!0),e.content.chatMessageType===a(z).IMAGE?(o(),g(a(x),{key:3,width:"240",src:e.__content},null,8,["src"])):f("v-if",!0),a(H)(e.content)?(o(),i(m,{key:4},[l(a(I),{class:r({"is-audio":e.content.chatMessageType===a(z).AUDIO}),component:e.content.chatMessageType===a(z).AUDIO?a(X):a(F)},null,8,["class","component"]),v("span",ue,d(a(R)(e.__content)),1)],64)):f("v-if",!0),e.content.chatMessageType===a(z).FILE?(o(),g(a(C),{key:5,"wrap-item":!1},{default:u((()=>[l(a(I),{class:"icon-file",size:"40",component:a(G)},null,8,["component"]),l(a(C),{"wrap-item":!1,vertical:"",justify:"space-between",style:{"row-gap":"0"}},{default:u((()=>[v("span",null,d(e.__content),1),v("span",me,d(e.__size),1)])),_:2},1024)])),_:2},1024)):f("v-if",!0),l(a(w),{class:"quick-menu"},{default:u((()=>[a(H)(e.content)?f("v-if",!0):(o(),i(m,{key:0},[f(' <n-button quaternary size="tiny">\r\n\t\t\t\t\t\t\t\t\t\t\t\t<template #icon>\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t<i class="chat--iconfont chat--icon-face" />\r\n\t\t\t\t\t\t\t\t\t\t\t\t</template>\r\n\t\t\t\t\t\t\t\t\t\t\t</n-button> '),l(a(k),{quaternary:"",size:"tiny",onClick:()=>De(e)},{icon:u((()=>[l(a(I),{size:"17",component:a(K)},null,8,["component"])])),_:2},1032,["onClick"])],64)),l(a(k),{quaternary:"",size:"tiny",onClick:t=>Se(t,e.id)},{icon:u((()=>[l(a(I),{size:"14",component:a(Y)},null,8,["component"])])),_:2},1032,["onClick"])])),_:2},1024)],42,oe)])):f("v-if",!0)]))],2)):f("v-if",!0)],64)))),128))])),_:1}),l(a(W),{ref_key:"contextmenuRef",ref:he,show:Te.value,"onUpdate:show":t[0]||(t[0]=e=>Te.value=e),position:Me.value,"msg-id":ke.value,onSelect:Re},null,8,["show","position","msg-id"]),l(U,{title:"转发消息",mode:"relay",onComfirm:Ne},{trigger:u((()=>[v("span",{style:{display:"none"},ref_key:"relayTriggerRef",ref:_e},"转发",512)])),_:1})],6))}});export{pe as default};
@@ -158,6 +158,7 @@ declare const _default: import("vue").DefineComponent<{}, {
158
158
  options: import("vue").Ref<AnyObject[]>;
159
159
  groupName: import("vue").Ref<string>;
160
160
  checkedSourceIds: import("vue").Ref<(string | number)[]>;
161
+ remark: import("vue").Ref<string>;
161
162
  userList: import("vue").Ref<AnyObject[]>;
162
163
  handleInput: () => void;
163
164
  _disabledIds: import("vue").ComputedRef<any[]>;
@@ -1 +1 @@
1
- import{defineComponent as e,ref as t,computed as s,withDirectives as o,createVNode as i,vShow as n,isVNode as r}from"vue";import{NButtonGroup as a,NButton as l,NIcon as m}from"naive-ui";import{CopyOutline as c,ChatbubbleEllipsesOutline as d,ReturnDownBack as u,DownloadOutline as p}from"@vicons/ionicons5";import{onClickOutside as g}from"@vueuse/core";import{useState as f}from"../hooks/useState.js";import{useSession as y}from"../hooks/useSession.js";import{MESSAGE_TYPE as w}from"../constants/index.js";import"trtc-sdk-v5";import{isAudioOrVideoMessage as h,downloadFile as v}from"../utils/index.js";import{emojis as I}from"../utils/emoji.js";import{recallMessageApi as T}from"../api/index.js";import{format as M}from"date-fns";var b=e({name:"PopupMenu",inheritAttrs:!1,props:{show:{type:Boolean,default:!1},position:{type:Object},msgId:{type:String}},emits:["update:show","select"],setup(e,{attrs:b,slots:E,emit:j}){const{state:k,setMsgList:S}=f(),{setCurrentSessionItem:x}=y(k),L=[{icon:c,label:"复制",key:"copy"},{icon:d,label:"回复",key:"reply"},{icon:u,label:"撤回",key:"withdraw"},{icon:p,label:"下载",key:"download"}],O=t(null),A=s((()=>k.msgList.find((({id:t})=>t===e.msgId)))),D=s((()=>{if(!e.msgId)return[];if(!(null==A?void 0:A.value))return[];const{content:t={},sendTime:s,sender:o}=A.value,{chatMessageType:i}=t,n=[];return(o!==k.userInfo.id||i===w.TEMPLATE||o===k.userInfo.id&&Date.now()-new Date(s).getTime()>2592e5)&&n.push("withdraw"),[w.TEXT,w.EMOJI,w.BLEND].includes(i)?n.push("download"):h(t)?n.push("copy","relay","reply","download"):i===w.FILE?n.push("copy"):[w.FORWARD,w.TEMPLATE].includes(i)&&n.push("copy","download"),n.length?L.filter((e=>!n.includes(e.key))):L}));return g(O,(e=>{j("update:show",!1)})),()=>{let t;return e.msgId&&D.value?o(i("div",{class:"contextmenu-wrapper",ref:O,style:e.position},[i(a,{vertical:!0},(s=t=D.value.map((t=>i(l,{onClick:()=>async function(t){j("update:show",!1);const{content:s={},sendTime:o,sender:i}=A.value||{},{chatMessageType:n}=s;switch(t){case"copy":if(!s.msg)return console.log("复制内容为空!");if(!navigator||!("clipboard"in navigator))return console.log("当前浏览器版本不支持复制!");try{if(n===w.TEXT)await navigator.clipboard.writeText(s.msg);else{let e;if([w.EMOJI,w.IMAGE].includes(n)){const t=n===w.EMOJI?I.findEmoji(s.msg):s.msg;e=`<img data-msg=${s.msg} data-type=${n} class=${n===w.EMOJI?"emoji--min":""} src=${t} />`}else e=s.msg;await navigator.clipboard.write([new window.ClipboardItem({"text/html":new Blob([e],{type:"text/html"})})])}}catch(e){console.log("复制失败!")}return;case"download":return void v(s.fileUrl,s.msg);case"withdraw":{const t=k.msgList.findIndex((({id:t})=>t===e.msgId)),s=0===t;if(await T({chatType:k.currentSessionItem.chatType,messageIdSet:[e.msgId],receiver:k.currentSessionItem.receiver,sender:k.userInfo.id,isLastMessage:s}),k.msgList[t].status="WITHDRAWN",s){const e=M(new Date,"yyyy-MM-dd HH:mm:ss");x({lastMessageStatus:"WITHDRAWN",lastMessageSendTime:e,sortTime:e,updatedTime:e})}}}j("select",t,A.value)}(t.key),quaternary:!0},{default:()=>t.label,icon:()=>i(m,{component:t.icon},null)}))),"function"==typeof s||"[object Object]"===Object.prototype.toString.call(s)&&!r(s)?t:{default:()=>[t]}))]),[[n,e.show]]):null;var s}}});export{b as default};
1
+ import{defineComponent as e,ref as t,computed as s,withDirectives as o,createVNode as i,vShow as n,isVNode as r}from"vue";import{NButtonGroup as a,NButton as l,NIcon as c}from"naive-ui";import{CopyOutline as m,OpenOutline as d,ChatbubbleEllipsesOutline as u,ReturnDownBack as p,DownloadOutline as g}from"@vicons/ionicons5";import{onClickOutside as f}from"@vueuse/core";import{useState as y}from"../hooks/useState.js";import{useSession as w}from"../hooks/useSession.js";import{MESSAGE_TYPE as h}from"../constants/index.js";import"trtc-sdk-v5";import{isAudioOrVideoMessage as v,downloadFile as I}from"../utils/index.js";import{emojis as T}from"../utils/emoji.js";import{recallMessageApi as M}from"../api/index.js";import{format as b}from"date-fns";var E=e({name:"PopupMenu",inheritAttrs:!1,props:{show:{type:Boolean,default:!1},position:{type:Object},msgId:{type:String}},emits:["update:show","select"],setup(e,{attrs:E,slots:j,emit:k}){const{state:S,setMsgList:x}=y(),{setCurrentSessionItem:L}=w(S),O=[{icon:m,label:"复制",key:"copy"},{icon:d,label:"转发",key:"relay"},{icon:u,label:"回复",key:"reply"},{icon:p,label:"撤回",key:"withdraw"},{icon:g,label:"下载",key:"download"}],A=t(null),D=s((()=>S.msgList.find((({id:t})=>t===e.msgId)))),W=s((()=>{if(!e.msgId)return[];if(!(null==D?void 0:D.value))return[];const{content:t={},sendTime:s,sender:o}=D.value,{chatMessageType:i}=t,n=[];return(o!==S.userInfo.id||i===h.TEMPLATE||o===S.userInfo.id&&Date.now()-new Date(s).getTime()>2592e5)&&n.push("withdraw"),[h.TEXT,h.EMOJI,h.BLEND].includes(i)?n.push("download"):v(t)?n.push("copy","relay","reply","download"):i===h.FILE?n.push("copy"):[h.FORWARD,h.TEMPLATE].includes(i)&&n.push("copy","download"),n.length?O.filter((e=>!n.includes(e.key))):O}));return f(A,(e=>{k("update:show",!1)})),()=>{let t;return e.msgId&&W.value?o(i("div",{class:"contextmenu-wrapper",ref:A,style:e.position},[i(a,{vertical:!0},(s=t=W.value.map((t=>i(l,{onClick:()=>async function(t){k("update:show",!1);const{content:s={},sendTime:o,sender:i}=D.value||{},{chatMessageType:n}=s;switch(t){case"copy":if(!s.msg)return console.log("复制内容为空!");if(!navigator||!("clipboard"in navigator))return console.log("当前浏览器版本不支持复制!");try{if(n===h.TEXT)await navigator.clipboard.writeText(s.msg);else{let e;if([h.EMOJI,h.IMAGE].includes(n)){const t=n===h.EMOJI?T.findEmoji(s.msg):s.msg;e=`<img data-msg=${s.msg} data-type=${n} class=${n===h.EMOJI?"emoji--min":""} src=${t} />`}else e=s.msg;await navigator.clipboard.write([new window.ClipboardItem({"text/html":new Blob([e],{type:"text/html"})})])}}catch(e){console.log("复制失败!")}return;case"download":return void I(s.fileUrl,s.msg);case"withdraw":{const t=S.msgList.findIndex((({id:t})=>t===e.msgId)),s=0===t;if(await M({chatType:S.currentSessionItem.chatType,messageIdSet:[e.msgId],receiver:S.currentSessionItem.receiver,sender:S.userInfo.id,isLastMessage:s}),S.msgList[t].status="WITHDRAWN",s){const e=b(new Date,"yyyy-MM-dd HH:mm:ss");L({lastMessageStatus:"WITHDRAWN",lastMessageSendTime:e,sortTime:e,updatedTime:e})}return}}k("select",t,D.value)}(t.key),quaternary:!0},{default:()=>t.label,icon:()=>i(c,{component:t.icon},null)}))),"function"==typeof s||"[object Object]"===Object.prototype.toString.call(s)&&!r(s)?t:{default:()=>[t]}))]),[[n,e.show]]):null;var s}}});export{E as default};
@@ -106,6 +106,7 @@ declare const _default: import("vue").DefineComponent<{}, {
106
106
  options: import("vue").Ref<AnyObject[]>;
107
107
  groupName: import("vue").Ref<string>;
108
108
  checkedSourceIds: import("vue").Ref<(string | number)[]>;
109
+ remark: import("vue").Ref<string>;
109
110
  userList: import("vue").Ref<AnyObject[]>;
110
111
  handleInput: () => void;
111
112
  _disabledIds: import("vue").ComputedRef<any[]>;
@@ -1 +1 @@
1
- import{computed as e}from"vue";import{simplifyMessage as s}from"../utils/index.js";import{cloneDeep as t,isArray as n,uniqBy as i}from"lodash-es";import{CHAT_TYPE as o}from"../constants/index.js";import{groupUserApi as r}from"../api/index.js";function a(e){return e.chatType===o.GROUP}function u(e){const{lastMessage:t,lastSenderName:n=""}=e,i=s(t)||"";return a(e)&&n?n+": "+i:i}function c(s){const c=e((()=>a(s.currentSessionItem)));function m(e){Object.assign(s.currentSessionItem,e,{lastMessageContent:Reflect.has(e,"lastMessageContent")?e.lastMessageContent:Reflect.has(e,"lastMessage")?u({...e,chatType:e.chatType||s.currentSessionItem.chatType}):s.currentSessionItem.lastMessageContent}),s.isChangeSession=!0,s.id!==s.currentSessionItem.id&&(s.msgList=[],s.id=s.currentSessionItem.id)}function d(e){s.sessionList=t(i(e,"id")),s.sessionList.forEach((e=>{Object.assign(e,{defaultName:Reflect.has(e,"defaultName")?e.defaultName:e.name||"",lastMessageContent:Reflect.has(e,"lastMessageContent")?e.lastMessageContent:u(e)}),e.receiver===s.userInfo.id&&(e.unreadNum=0),e.chatType!==o.GROUP||e.name||r({id:e.receiver}).then((s=>{n(s)&&(e.name=s.map((e=>e.name)).join(","))}))}))}return{openSession:async function(e){const i=s.currentSessionItem.sessionKey;if(m(e),i!==s.currentSessionItem.sessionKey)if(c.value){const t=await r({id:e.receiver});s.currentGroupUser=n(t)?t:[]}else s.currentGroupUser=[s.userInfo,{...t(e),id:e.receiver}]},closeSession:function(){if(!s.id)return null;const{currentSessionItem:e}=s;return s.currentSessionItem={},s.msgList=[],s.id="",s.currentGroupUser=[],e},getCurrentSession:function(){return s.id?s.currentSessionItem:null},setCurrentSessionItem:m,setUpdateSessionItem:function(e){const n=s.sessionList.find((s=>s.sessionKey===e.sessionKey)),i={...e,lastMessageContent:u({...e,chatType:e.chatType||(null==n?void 0:n.chatType)})};s.updateSessionItem=n?{...t(n),...i}:i,s.isUpdateSession=!0},setSessionList:d,isGroupChat:c,updateSessionList:function(e){!e.id||s.sessionList.map((e=>e.id)).includes(e.id)?s.sessionList.some((t=>{if(t.sessionKey===e.sessionKey){let{unreadNum:n=0}=t;return Object.assign(t,e),e.sessionKey!==s.currentSessionItem.sessionKey&&(t.unreadNum=++n),!0}})):d([...s.sessionList,e])}}}export{c as useSession};
1
+ import{computed as e}from"vue";import{simplifyMessage as s}from"../utils/index.js";import{cloneDeep as n,isArray as t,uniqBy as i}from"lodash-es";import{CHAT_TYPE as o}from"../constants/index.js";import{groupUserApi as r}from"../api/index.js";function a(e){return e.chatType===o.GROUP}function u(e){const{lastMessage:n,lastSenderName:t=""}=e,i=s(n)||"";return a(e)&&t?t+": "+i:i}function c(s){const c=e((()=>a(s.currentSessionItem)));function m(e){Object.assign(s.currentSessionItem,e,{lastMessageContent:Reflect.has(e,"lastMessageContent")?e.lastMessageContent:Reflect.has(e,"lastMessage")?u({...e,chatType:e.chatType||s.currentSessionItem.chatType}):s.currentSessionItem.lastMessageContent}),s.isChangeSession=!0,s.id!==s.currentSessionItem.id&&(s.msgList=[],s.id=s.currentSessionItem.id)}function d(e){s.sessionList=n(i(e,"id")),s.sessionList.forEach((e=>{Object.assign(e,{defaultName:Reflect.has(e,"defaultName")?e.defaultName:e.name||"",lastMessageContent:Reflect.has(e,"lastMessageContent")?e.lastMessageContent:u(e)}),e.receiver===s.userInfo.id&&(e.unreadNum=0),e.chatType!==o.GROUP||e.name||r({id:e.receiver}).then((s=>{t(s)&&(e.name=s.map((e=>e.name)).join(","))}))}))}return{openSession:async function(e){const i=s.currentSessionItem.sessionKey;if(m(e),i!==s.currentSessionItem.sessionKey)if(c.value){const n=await r({id:e.receiver});s.currentGroupUser=t(n)?n:[]}else s.currentGroupUser=[s.userInfo,{...n(e),id:e.receiver}]},closeSession:function(){if(!s.id)return null;const{currentSessionItem:e}=s;return s.currentSessionItem={},s.msgList=[],s.id="",s.currentGroupUser=[],e},getCurrentSession:function(){return s.id?s.currentSessionItem:null},setCurrentSessionItem:m,setUpdateSessionItem:function(e){const t=s.sessionList.find((s=>s.sessionKey===e.sessionKey)),i={...e,lastMessageContent:u({...e,chatType:e.chatType||(null==t?void 0:t.chatType)})};s.updateSessionItem=t?{...n(t),...i}:i,s.isUpdateSession=!0},setSessionList:d,isGroupChat:c,updateSessionList:function(e){!e.id||s.sessionList.map((e=>e.id)).includes(e.id)?s.sessionList.some((n=>{if(n.sessionKey===e.sessionKey){let{unreadNum:t=0}=n;return Object.assign(n,e),e.sessionKey!==s.currentSessionItem.sessionKey&&n.sender&&n.sender!==s.userInfo.id&&(n.unreadNum=++t),!0}})):d([...s.sessionList,e])}}}export{c as useSession};
@@ -9,4 +9,9 @@ export declare function useState(): {
9
9
  content: AnyObject;
10
10
  receiver?: string;
11
11
  }) => Promise<void>;
12
+ relayMessage: (param: {
13
+ checkedIds: string[];
14
+ remark: string;
15
+ content: AnyObject;
16
+ }) => Promise<void>;
12
17
  };
@@ -1 +1 @@
1
- import{inject as e}from"vue";import{cloneDeep as t}from"lodash-es";import{formatTime as s,transformMessage as n,getFileSize as i}from"../utils/index.js";import{InjectionIChatState as m,InjectionIChatStompClient as o,InjectionIChatEmits as r}from"../types/index.js";import{MESSAGE_TYPE as c}from"../constants/index.js";import{useIntervalFn as a}from"@vueuse/core";function T(){const T=e(m),d=e(o),g=e(r),{pause:u,resume:p,isActive:f}=a((()=>{const e=t(T.msgList);e.some((e=>{const{sendTime:t}=e;return!(Date.now()-new Date(t).getTime()>=36e5)&&(e.__sendTime=s(t).recordTime,!0)})),T.msgList=e,_()||u()}),6e4,{immediate:!1});function _(){return!!T.msgList.length&&T.msgList.some((e=>Date.now()-new Date(e.sendTime).getTime()<36e5))}return{state:T,setMsgList:function(e=[]){u(),T.msgList=t(e).sort(((e,t)=>new Date(t.sendTime).getTime()-new Date(e.sendTime).getTime())),T.msgList.forEach((e=>{var t,m;Object.assign(e,{__time:s(e.sendTime).msgTime,__content:(m=e.content.chatMessageType,[c.TEXT,c.TEXT,c.BLEND].includes(m)?n(e.content):null==(t=e.content)?void 0:t.msg),__sendTime:s(e.sendTime).recordTime}),e.content.chatMessageType!==c.FILE||e.__size||i(e.content.fileUrl).then((t=>{e.__size=t}))})),_()&&p()},stompClient:d,emit:g,sendMessage:async function(e){try{d.value.send("/app/chat/send",{},JSON.stringify({chatType:T.currentSessionItem.chatType,receiver:T.currentSessionItem.receiver,...e}))}catch(e){}}}}export{T as useState};
1
+ import{inject as e}from"vue";import{cloneDeep as t}from"lodash-es";import{formatTime as s,transformMessage as n,getFileSize as i}from"../utils/index.js";import{InjectionIChatState as r,InjectionIChatStompClient as o,InjectionIChatEmits as c}from"../types/index.js";import{MESSAGE_TYPE as m,CHAT_TYPE as a}from"../constants/index.js";import{useIntervalFn as T,promiseTimeout as d}from"@vueuse/core";import{openSessionApi as g}from"../api/index.js";function p(){const p=e(r),u=e(o),f=e(c),{pause:h,resume:l,isActive:y}=T((()=>{const e=t(p.msgList);e.some((e=>{const{sendTime:t}=e;return!(Date.now()-new Date(t).getTime()>=36e5)&&(e.__sendTime=s(t).recordTime,!0)})),p.msgList=e,v()||h()}),6e4,{immediate:!1});function v(){return!!p.msgList.length&&p.msgList.some((e=>Date.now()-new Date(e.sendTime).getTime()<36e5))}async function L(e){try{u.value.send("/app/chat/send",{},JSON.stringify({chatType:p.currentSessionItem.chatType,receiver:p.currentSessionItem.receiver,...e}))}catch(e){}}return{state:p,setMsgList:function(e=[]){h(),p.msgList=t(e).sort(((e,t)=>new Date(t.sendTime).getTime()-new Date(e.sendTime).getTime())),p.msgList.forEach((e=>{var t,r;Object.assign(e,{__time:s(e.sendTime).msgTime,__content:(r=e.content.chatMessageType,[m.TEXT,m.TEXT,m.BLEND].includes(r)?n(e.content):null==(t=e.content)?void 0:t.msg),__sendTime:s(e.sendTime).recordTime}),e.content.chatMessageType!==m.FILE||e.__size||i(e.content.fileUrl).then((t=>{e.__size=t}))})),v()&&l()},stompClient:u,emit:f,sendMessage:L,relayMessage:async function(e){const{checkedIds:t,remark:s,content:n}=e;for(let e=0;e<t.length;e++){const i=t[e],r=p.sessionList.find((e=>e.receiver===i));r||await g({chatType:"SINGLE",receiver:i,sender:p.userInfo.id});const o=(null==r?void 0:r.chatType)||a.SINGLE;L({chatType:o,receiver:i,content:n}),await d(100),s&&L({chatType:o,receiver:i,content:{chatMessageType:m.TEXT,msg:s}}),await d(100)}}}}export{p as useState};
@@ -1 +1 @@
1
- import t from"stompjs";import i from"sockjs-client/dist/sockjs.min.js";class s{constructor(t,i){this.reconnectionCount=0,this.options={},this.url="",this.url=t,this.options=i,this.connection()}connection(){if(!this.url)return;const s=new i(this.url);this.stompClient=t.over(s),this.stompClient.connect(this.options.headers||{},(()=>{const{connectCb:t}=this.options;t&&t(this.reconnectionCount>0),this.startHeartbeat(),this.subscribe(this.options.subscribeCbs),this.reconnectionCount=0}),(t=>{const i=this.reconnectionCount,{errorCb:s,reconnectMaxCount:e=60}=this.options;s&&s(t,i),i<=e&&this.reconnect()}))}disconnect(){var t;this.heartbeatTimer&&clearTimeout(this.heartbeatTimer),this.reconnectTimer&&clearTimeout(this.reconnectTimer),null==(t=this.stompClient)||t.disconnect(),this.stompClient=void 0}reconnect(){this.reconnectionCount++,this.disconnect(),this.reconnectTimer=setTimeout((()=>{this.connection()}),1e3)}subscribe(...t){const i=this.stompClient;if(i){if(1!==t.length||!Array.isArray(t[0]))return 2===t.length?i.subscribe(...t):void 0;t[0].forEach((t=>{this.subscribe(t.action,t.cb)}))}}startHeartbeat(){const t=this.options.heartbeatFn;if(!t)return;const i=this.options.heartbeatRate||1e4;this.heartbeatTimer=setTimeout((()=>{t(),this.startHeartbeat()}),i)}send(...t){var i;return null==(i=this.stompClient)?void 0:i.send(...t)}}export{s as ChatSock};
1
+ import t from"stompjs";import i from"sockjs-client/dist/sockjs.min.js";class s{constructor(t,i){this.reconnectionCount=0,this.options={},this.url="",this.url=t,this.options=i,this.connection()}connection(){if(!this.url)return;const s=new i(this.url);this.stompClient=t.over(s),this.stompClient.debug=null,this.stompClient.connect(this.options.headers||{},(()=>{const{connectCb:t}=this.options;t&&t(this.reconnectionCount>0),this.startHeartbeat(),this.subscribe(this.options.subscribeCbs),this.reconnectionCount=0}),(t=>{const i=this.reconnectionCount,{errorCb:s,reconnectMaxCount:e=60}=this.options;s&&s(t,i),i<=e&&this.reconnect()}))}disconnect(){var t;this.heartbeatTimer&&clearTimeout(this.heartbeatTimer),this.reconnectTimer&&clearTimeout(this.reconnectTimer),null==(t=this.stompClient)||t.disconnect(),this.stompClient=void 0}reconnect(){this.reconnectionCount++,this.disconnect(),this.reconnectTimer=setTimeout((()=>{this.connection()}),1e3)}subscribe(...t){const i=this.stompClient;if(i){if(1!==t.length||!Array.isArray(t[0]))return 2===t.length?i.subscribe(...t):void 0;t[0].forEach((t=>{this.subscribe(t.action,t.cb)}))}}startHeartbeat(){const t=this.options.heartbeatFn;if(!t)return;const i=this.options.heartbeatRate||1e4;this.heartbeatTimer=setTimeout((()=>{t(),this.startHeartbeat()}),i)}send(...t){var i;return null==(i=this.stompClient)?void 0:i.send(...t)}}export{s as ChatSock};