cnhis-design-vue 3.2.9-beta.27 → 3.2.9-beta.30

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 (29) hide show
  1. package/es/components/button-print/src/utils/print.d.ts +5 -4
  2. package/es/components/button-print/src/utils/print.js +1 -1
  3. package/es/components/classification/src/components/table-modal/index.vue.d.ts +3 -0
  4. package/es/components/field-set/index.d.ts +1 -1
  5. package/es/components/field-set/src/FieldColor.vue.d.ts +6 -4
  6. package/es/components/field-set/src/FieldFilter.vue.d.ts +6 -4
  7. package/es/components/field-set/src/FieldSet.vue.d.ts +7 -6
  8. package/es/components/field-set/src/FieldSet.vue2.js +1 -1
  9. package/es/components/field-set/src/Index.vue.d.ts +1 -1
  10. package/es/components/field-set/src/Index.vue2.js +1 -1
  11. package/es/components/field-set/src/components/table-row.vue.d.ts +4 -4
  12. package/es/components/field-set/src/types/index.d.ts +1 -0
  13. package/es/components/field-set/style/index.css +1 -1
  14. package/es/components/iho-chat/index.d.ts +17 -4
  15. package/es/components/iho-chat/src/Index.vue.d.ts +17 -4
  16. package/es/components/iho-chat/src/Index.vue2.js +1 -1
  17. package/es/components/iho-chat/src/components/ChatMain.vue2.js +1 -1
  18. package/es/components/iho-chat/src/components/PersonProfile.vue2.js +1 -1
  19. package/es/components/iho-chat/src/components/SiderList.vue.d.ts +1 -3
  20. package/es/components/iho-chat/src/components/SiderList.vue2.js +1 -1
  21. package/es/components/iho-chat/src/hooks/useState.d.ts +1 -0
  22. package/es/components/iho-chat/src/hooks/useState.js +1 -1
  23. package/es/components/iho-chat/src/types/index.d.ts +2 -1
  24. package/es/components/iho-chat/src/types/index.js +1 -1
  25. package/es/components/index.css +1 -1
  26. package/es/components/scale-view/src/ScaleView.vue2.js +1 -1
  27. package/es/env.d.ts +25 -25
  28. package/es/shared/package.json.js +1 -1
  29. package/package.json +2 -2
@@ -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 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">\n\t\t\t\t\t\t\t\t\t\t\t\t<template #icon>\n\t\t\t\t\t\t\t\t\t\t\t\t\t<i class="chat--iconfont chat--icon-face" />\n\t\t\t\t\t\t\t\t\t\t\t\t</template>\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};
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};
@@ -1 +1 @@
1
- import{defineComponent as t,ref as e,reactive as a,computed as o,openBlock as l,createBlock as n,unref as s,withCtx as r,renderSlot as i,createElementBlock as c,Fragment as u,withDirectives as d,createElementVNode as p,createVNode as m,createCommentVNode as v,toDisplayString as f,createTextVNode as g,renderList as y,vShow as k}from"vue";import{NPopover as h,NAvatar as b,NButton as w,NIcon as j}from"naive-ui";import{ChatbubbleEllipses as C,EyeOffOutline as I,EyeOutline as _,Close as x}from"@vicons/ionicons5";import{useState as z}from"../hooks/useState.js";import{useSession as N}from"../hooks/useSession.js";import{CHAT_TYPE as S}from"../constants/index.js";import"trtc-sdk-v5";import"date-fns";import"lodash-es";import"../utils/emoji.js";import"../../../../shared/utils/index.js";import{openSessionApi as $,getUserDetailApi as D}from"../api/index.js";const E={class:"person-profile-main"},L={class:"left"},P={class:"profile"},q={class:"profile__text"},B={class:"right"},G={class:"right__content"},O={class:"label"},T={class:"content"};var U=t({__name:"PersonProfile",props:{userId:{type:String,required:!0},disabled:{type:Boolean,default:!1}},emits:["close"],setup(t,{emit:U}){const A=t,{state:F}=z(),{openSession:H}=N(F),J=e(!1),K=e(!1),M=e(!1),Q=a({}),R=[{label:"机构",value:"",key:"orgName"},{label:"姓名",value:"",key:"name"},{label:"归属科室",value:"",key:"deptName"},{label:"业务科室",value:"",key:"businessDeptNames"},{label:"手机号",value:"",key:"phone"},{label:"岗位",value:"",key:"post"},{label:"工号",value:"",key:"jobId"},{label:"性别",value:"",key:"orgName"}],V=o((()=>(Q.id&&R.forEach((t=>{const{key:e}=t;t.value=Q[e]})),R)));async function W(){J.value=!1;let t=F.sessionList.find((t=>t.receiver===A.userId));if(!t)try{t=await $({chatType:S.SINGLE,receiver:A.userId,sender:F.userInfo.id})}catch(t){console.log("error :>> ",t)}t&&H(t),U("close")}async function X(t){if(!t)return;const e=await D({userId:A.userId});(null==e?void 0:e.id)?Object.assign(Q,e):Q.id=""}function Y(t){const{key:e,value:a}=t;return"phone"!==e||M.value?a:(a||"").replace(/(\d{3})\d{4}(\d{4})/,"$1****$2")}return(e,a)=>(l(),n(s(h),{raw:"",class:"person-profile-wrapper",show:J.value,"onUpdate:show":[a[3]||(a[3]=t=>J.value=t),X],trigger:t.disabled?"manual":"click","show-arrow":!1,to:"body",shift:""},{trigger:r((()=>[i(e.$slots,"trigger")])),default:r((()=>[Q.id?(l(),c(u,{key:0},[d(p("div",E,[p("div",L,[p("div",P,[m(s(b),{src:Q.avatar,bordered:"",round:"",size:100,onClickCapture:a[0]||(a[0]=t=>K.value=!0)},null,8,["src"]),v(' <n-upload abstract accept="image/*" @change="onChange">\n\t\t\t\t\t\t\t<n-upload-trigger #="{ handleClick }" abstract>\n\t\t\t\t\t\t\t\t<n-button\n\t\t\t\t\t\t\t\t\tcircle\n\t\t\t\t\t\t\t\t\tsecondary\n\t\t\t\t\t\t\t\t\tclass="edit-avatar"\n\t\t\t\t\t\t\t\t\tv-show="userDetail.id === state.userInfo.id"\n\t\t\t\t\t\t\t\t\t@click="handleClick"\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t<template #icon>\n\t\t\t\t\t\t\t\t\t\t<n-icon size="16" color="#666666" :component="Camera" />\n\t\t\t\t\t\t\t\t\t</template>\n\t\t\t\t\t\t\t\t</n-button>\n\t\t\t\t\t\t\t</n-upload-trigger>\n\t\t\t\t\t\t</n-upload> '),p("div",q,[p("h4",null,f(Q.name),1),p("p",null,f(Q.orgName),1)]),m(s(w),{strong:"",secondary:"",onClick:W},{default:r((()=>[m(s(j),{size:"13",color:"#666666",component:s(C),style:{"margin-right":"6px"}},null,8,["component"]),g(" 发消息 ")])),_:1})])]),p("div",B,[p("div",G,[(l(!0),c(u,null,y(s(V),((t,e)=>(l(),c("div",{class:"info-item",key:e},[p("span",O,f(t.label),1),p("div",T,[p("span",null,f(Y(t)),1),"phone"===t.key&&Y(t)?(l(),n(s(j),{key:0,size:"16",color:"#666666",component:M.value?s(I):s(_),style:{"margin-left":"10px"},onClick:a[1]||(a[1]=t=>M.value=!M.value)},null,8,["component"])):v("v-if",!0)])])))),128))])])],512),[[k,!K.value]]),d(p("div",{class:"large-avatar",onClick:a[2]||(a[2]=t=>K.value=!1)},[m(s(w),{circle:"",size:"small",secondary:""},{icon:r((()=>[m(s(j),{size:24,component:s(x),color:"#fff"},null,8,["component"])])),_:1}),m(s(b),{size:310,round:"",src:Q.avatar},null,8,["src"])],512),[[k,K.value]])],64)):v("v-if",!0)])),_:3},8,["show","trigger"]))}});export{U as default};
1
+ import{defineComponent as t,ref as e,reactive as a,computed as o,openBlock as l,createBlock as r,unref as n,withCtx as s,renderSlot as i,createElementBlock as c,Fragment as u,withDirectives as d,createElementVNode as p,createVNode as m,createCommentVNode as v,toDisplayString as f,createTextVNode as g,renderList as y,vShow as k}from"vue";import{NPopover as h,NAvatar as b,NButton as w,NIcon as j}from"naive-ui";import{ChatbubbleEllipses as C,EyeOffOutline as I,EyeOutline as _,Close as x}from"@vicons/ionicons5";import{useState as z}from"../hooks/useState.js";import{useSession as N}from"../hooks/useSession.js";import{CHAT_TYPE as S}from"../constants/index.js";import"trtc-sdk-v5";import"date-fns";import"lodash-es";import"../utils/emoji.js";import"../../../../shared/utils/index.js";import{openSessionApi as $,getUserDetailApi as D}from"../api/index.js";const E={class:"person-profile-main"},L={class:"left"},P={class:"profile"},q={class:"profile__text"},B={class:"right"},G={class:"right__content"},O={class:"label"},T={class:"content"};var U=t({__name:"PersonProfile",props:{userId:{type:String,required:!0},disabled:{type:Boolean,default:!1}},emits:["close"],setup(t,{emit:U}){const A=t,{state:F}=z(),{openSession:H}=N(F),J=e(!1),K=e(!1),M=e(!1),Q=a({}),R=[{label:"机构",value:"",key:"orgName"},{label:"姓名",value:"",key:"name"},{label:"归属科室",value:"",key:"deptName"},{label:"业务科室",value:"",key:"businessDeptNames"},{label:"手机号",value:"",key:"phone"},{label:"岗位",value:"",key:"post"},{label:"工号",value:"",key:"jobId"},{label:"性别",value:"",key:"orgName"}],V=o((()=>(Q.id&&R.forEach((t=>{const{key:e}=t;t.value=Q[e]})),R)));async function W(){J.value=!1;let t=F.sessionList.find((t=>t.receiver===A.userId));if(!t)try{t=await $({chatType:S.SINGLE,receiver:A.userId,sender:F.userInfo.id})}catch(t){console.log("error :>> ",t)}t&&H(t),U("close")}async function X(t){if(!t)return;const e=await D({userId:A.userId});(null==e?void 0:e.id)?Object.assign(Q,e):Q.id=""}function Y(t){const{key:e,value:a}=t;return"phone"!==e||M.value?a:(a||"").replace(/(\d{3})\d{4}(\d{4})/,"$1****$2")}return(e,a)=>(l(),r(n(h),{raw:"",class:"person-profile-wrapper",show:J.value,"onUpdate:show":[a[3]||(a[3]=t=>J.value=t),X],trigger:t.disabled?"manual":"click","show-arrow":!1,to:"body",shift:""},{trigger:s((()=>[i(e.$slots,"trigger")])),default:s((()=>[Q.id?(l(),c(u,{key:0},[d(p("div",E,[p("div",L,[p("div",P,[m(n(b),{src:Q.avatar,bordered:"",round:"",size:100,onClickCapture:a[0]||(a[0]=t=>K.value=!0)},null,8,["src"]),v(' <n-upload abstract accept="image/*" @change="onChange">\r\n\t\t\t\t\t\t\t<n-upload-trigger #="{ handleClick }" abstract>\r\n\t\t\t\t\t\t\t\t<n-button\r\n\t\t\t\t\t\t\t\t\tcircle\r\n\t\t\t\t\t\t\t\t\tsecondary\r\n\t\t\t\t\t\t\t\t\tclass="edit-avatar"\r\n\t\t\t\t\t\t\t\t\tv-show="userDetail.id === state.userInfo.id"\r\n\t\t\t\t\t\t\t\t\t@click="handleClick"\r\n\t\t\t\t\t\t\t\t>\r\n\t\t\t\t\t\t\t\t\t<template #icon>\r\n\t\t\t\t\t\t\t\t\t\t<n-icon size="16" color="#666666" :component="Camera" />\r\n\t\t\t\t\t\t\t\t\t</template>\r\n\t\t\t\t\t\t\t\t</n-button>\r\n\t\t\t\t\t\t\t</n-upload-trigger>\r\n\t\t\t\t\t\t</n-upload> '),p("div",q,[p("h4",null,f(Q.name),1),p("p",null,f(Q.orgName),1)]),m(n(w),{strong:"",secondary:"",onClick:W},{default:s((()=>[m(n(j),{size:"13",color:"#666666",component:n(C),style:{"margin-right":"6px"}},null,8,["component"]),g(" 发消息 ")])),_:1})])]),p("div",B,[p("div",G,[(l(!0),c(u,null,y(n(V),((t,e)=>(l(),c("div",{class:"info-item",key:e},[p("span",O,f(t.label),1),p("div",T,[p("span",null,f(Y(t)),1),"phone"===t.key&&Y(t)?(l(),r(n(j),{key:0,size:"16",color:"#666666",component:M.value?n(I):n(_),style:{"margin-left":"10px"},onClick:a[1]||(a[1]=t=>M.value=!M.value)},null,8,["component"])):v("v-if",!0)])])))),128))])])],512),[[k,!K.value]]),d(p("div",{class:"large-avatar",onClick:a[2]||(a[2]=t=>K.value=!1)},[m(n(w),{circle:"",size:"small",secondary:""},{icon:s((()=>[m(n(j),{size:24,component:n(x),color:"#fff"},null,8,["component"])])),_:1}),m(n(b),{size:310,round:"",src:Q.avatar},null,8,["src"])],512),[[k,K.value]])],64)):v("v-if",!0)])),_:3},8,["show","trigger"]))}});export{U as default};
@@ -15,12 +15,10 @@ declare const _default: import("vue").DefineComponent<{}, {
15
15
  }[]>;
16
16
  currentFilterKey: import("vue").Ref<string>;
17
17
  state: import("../types").IState;
18
- emit: (event: string, ...args: any[]) => void;
18
+ unreadTotal: import("vue").ComputedRef<number>;
19
19
  openSession: (item: AnyObject) => Promise<void>;
20
- updateSessionList: (sessionItem: AnyObject) => void;
21
20
  currentWidth: import("vue").ComputedRef<number>;
22
21
  sessionList: import("vue").ComputedRef<AnyObject[]>;
23
- unreadTotal: import("vue").ComputedRef<number>;
24
22
  changeWidth: ({ distance }: AnyObject) => void;
25
23
  handleFilter: (key: string) => void;
26
24
  showSession: (item: AnyObject, currentKey?: string) => boolean | undefined;
@@ -1 +1 @@
1
- import{defineComponent as e,ref as s,computed as i,watch as a,withDirectives as t,openBlock as n,createElementBlock as l,normalizeStyle as r,unref as o,createBlock as u,createCommentVNode as d,createElementVNode as v,Fragment as m,renderList as c,withCtx as p,createTextVNode as f,toDisplayString as k,normalizeClass as y,createVNode as _,vShow as h}from"vue";import{NSpin as S,NTag as g,NAvatar as x,NBadge as M}from"naive-ui";import{useState as b}from"../hooks/useState.js";import{useSession as C}from"../hooks/useSession.js";import"trtc-sdk-v5";import{listSort as N,formatTime as L}from"../utils/index.js";import{vFlexibleResize as T}from"../../../../shared/directive/flexibleResize.js";import{promiseTimeout as j}from"@vueuse/shared";const w={class:"sider-list__filter box-shadow"},R=["onClick"],H={class:"avatar-right"},I={class:"name"},z={class:"msg-tip"},K={class:"msg-tip__content"},U={key:0},W=["innerHTML"];var A=e({__name:"SiderList",setup(e){const A="all",B="unread";let D=[];const V=s(300),q=s(),E=s(!1),F=s([{label:"全部",key:A},{label:"未读",key:B}]),G=s("all"),{state:J,emit:O}=b(),{openSession:P,updateSessionList:Q}=C(J),X=i((()=>Math.min(Math.max(V.value,240),360))),Y=i((()=>N(J.sessionList))),Z=i((()=>J.sessionList.reduce(((e,s)=>e+ +s.unreadNum),0)));function $({distance:e}){V.value=V.value+e}function ee(e,s=o(G)){var i;return s===A||(s===B?D.includes(e.sessionKey)||(null!=(i=e.unreadNum)?i:0)>0:void 0)}return a([()=>J.isChangeSession,()=>J.isUpdateSession],(([e,s])=>{e&&(Q(J.currentSessionItem),J.isChangeSession=!1),s&&(Q(J.updateSessionItem),J.isUpdateSession=!1)}),{immediate:!0}),a((()=>Z.value),(e=>{!async function s(i=0){const a=Y.value.every((e=>!!e.name));if(!(i>2))if(a){const s=Y.value.filter((e=>{var s;return+(null!=(s=e.unreadNum)?s:0)>0}));O("unread-message-update",e,s)}else await j(100),s(++i)}()})),(e,s)=>t((n(),l("section",{class:"sider-list",style:r({width:o(X)+"px"})},[E.value?(n(),u(o(S),{key:0,stroke:"#5585f5"})):d("v-if",!0),d(' <n-input v-else placeholder="输入用户名模糊搜索" v-model:value="keyword" @keyup.enter="handleSearch"></n-input> '),v("div",w,[(n(!0),l(m,null,c(F.value,(e=>(n(),u(o(g),{type:G.value===e.key?"info":"default",round:"",bordered:!1,key:e.key,onClick:()=>{return s=e.key,G.value=s,void(s===B&&(D=(Y.value.filter((e=>{var s;return(null!=(s=e.unreadNum)?s:0)>0}))||[]).map((e=>e.sessionKey))));var s}},{default:p((()=>[f(k(e.label)+"("+k(o(Z))+") ",1)])),_:2},1032,["type","onClick"])))),128))]),v("div",{class:"sider-list__box",ref_key:"listBoxRef",ref:q},[(n(!0),l(m,null,c(o(Y),(e=>t((n(),l("div",{key:e.id,onClick:()=>o(P)(e),class:y(["sider-list__box__item",{active:e.id===o(J).id},e.topping?"sider-list__box__item--top":""])},[_(o(x),{round:"",size:"large",src:e.avatar},null,8,["src"]),v("div",H,[v("div",I,[v("h4",null,k(e.name),1),v("span",null,k(e.lastMessage?o(L)(e.lastMessageSendTime).siderMsgTime:""),1)]),v("div",z,[v("div",K,["WITHDRAWN"===e.lastMessageStatus?(n(),l("div",U,"撤回了一条消息")):(n(),l("div",{key:1,innerHTML:e.lastMessageContent},null,8,W))]),_(o(M),{value:e.unreadNum>99?"99+":e.unreadNum},null,8,["value"])])])],10,R)),[[h,ee(e)]]))),128))],512)],4)),[[o(T),{mode:"VR",onMove:$}]])}});export{A as default};
1
+ import{defineComponent as e,ref as s,computed as l,withDirectives as i,openBlock as a,createElementBlock as t,normalizeStyle as n,unref as r,createBlock as o,createCommentVNode as u,createElementVNode as d,Fragment as v,renderList as m,withCtx as c,createTextVNode as p,toDisplayString as k,normalizeClass as f,createVNode as y,vShow as _}from"vue";import{NSpin as h,NTag as g,NAvatar as x,NBadge as M}from"naive-ui";import{useState as b}from"../hooks/useState.js";import{useSession as S}from"../hooks/useSession.js";import"trtc-sdk-v5";import{listSort as T,formatTime as C}from"../utils/index.js";import{vFlexibleResize as N}from"../../../../shared/directive/flexibleResize.js";const j={class:"sider-list__filter box-shadow"},L=["onClick"],R={class:"avatar-right"},w={class:"name"},H={class:"msg-tip"},z={class:"msg-tip__content"},K={key:0},W=["innerHTML"];var A=e({__name:"SiderList",setup(e){const A="all",B="unread";let D=[];const I=s(300),V=s(),q=s(!1),E=s([{label:"全部",key:A},{label:"未读",key:B}]),F=s("all"),{state:G,unreadTotal:J}=b(),{openSession:O}=S(G),P=l((()=>Math.min(Math.max(I.value,240),360))),Q=l((()=>T(G.sessionList)));function U({distance:e}){I.value=I.value+e}function X(e,s=r(F)){var l;return s===A||(s===B?D.includes(e.sessionKey)||(null!=(l=e.unreadNum)?l:0)>0:void 0)}return(e,s)=>i((a(),t("section",{class:"sider-list",style:n({width:r(P)+"px"})},[q.value?(a(),o(r(h),{key:0,stroke:"#5585f5"})):u("v-if",!0),u(' <n-input v-else placeholder="输入用户名模糊搜索" v-model:value="keyword" @keyup.enter="handleSearch"></n-input> '),d("div",j,[(a(!0),t(v,null,m(E.value,(e=>(a(),o(r(g),{type:F.value===e.key?"info":"default",round:"",bordered:!1,key:e.key,onClick:()=>{return s=e.key,F.value=s,void(s===B&&(D=(Q.value.filter((e=>{var s;return(null!=(s=e.unreadNum)?s:0)>0}))||[]).map((e=>e.sessionKey))));var s}},{default:c((()=>[p(k(e.label)+"("+k(r(J))+") ",1)])),_:2},1032,["type","onClick"])))),128))]),d("div",{class:"sider-list__box",ref_key:"listBoxRef",ref:V},[(a(!0),t(v,null,m(r(Q),(e=>i((a(),t("div",{key:e.id,onClick:()=>r(O)(e),class:f(["sider-list__box__item",{active:e.id===r(G).id},e.topping?"sider-list__box__item--top":""])},[y(r(x),{round:"",size:"large",src:e.avatar},null,8,["src"]),d("div",R,[d("div",w,[d("h4",null,k(e.name),1),d("span",null,k(e.lastMessage?r(C)(e.lastMessageSendTime).siderMsgTime:""),1)]),d("div",H,[d("div",z,["WITHDRAWN"===e.lastMessageStatus?(a(),t("div",K,"撤回了一条消息")):(a(),t("div",{key:1,innerHTML:e.lastMessageContent},null,8,W))]),y(r(M),{value:e.unreadNum>99?"99+":e.unreadNum},null,8,["value"])])])],10,L)),[[_,X(e)]]))),128))],512)],4)),[[r(N),{mode:"VR",onMove:U}]])}});export{A as default};
@@ -1,6 +1,7 @@
1
1
  import { AnyObject } from '../../../../shared/types';
2
2
  export declare function useState(): {
3
3
  state: import("../types").IState;
4
+ unreadTotal: import("vue").ComputedRef<number>;
4
5
  setMsgList: (list?: AnyObject[]) => void;
5
6
  stompClient: import("vue").Ref<import("../utils/chatSock").ChatSock>;
6
7
  emit: (event: string, ...args: any[]) => void;
@@ -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 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:a.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
+ 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,InjectionIChatUnreadTotal as m}from"../types/index.js";import{MESSAGE_TYPE as a,CHAT_TYPE as T}from"../constants/index.js";import{useIntervalFn as d,promiseTimeout as g}from"@vueuse/core";import{openSessionApi as p}from"../api/index.js";function u(){const u=e(r),f=e(o),h=e(c),l=e(m),{pause:y,resume:v,isActive:L}=d((()=>{const e=t(u.msgList);e.some((e=>{const{sendTime:t}=e;return!(Date.now()-new Date(t).getTime()>=36e5)&&(e.__sendTime=s(t).recordTime,!0)})),u.msgList=e,_()||y()}),6e4,{immediate:!1});function _(){return!!u.msgList.length&&u.msgList.some((e=>Date.now()-new Date(e.sendTime).getTime()<36e5))}async function w(e){try{f.value.send("/app/chat/send",{},JSON.stringify({chatType:u.currentSessionItem.chatType,receiver:u.currentSessionItem.receiver,...e}))}catch(e){}}return{state:u,unreadTotal:l,setMsgList:function(e=[]){y(),u.msgList=t(e).sort(((e,t)=>new Date(t.sendTime).getTime()-new Date(e.sendTime).getTime())),u.msgList.forEach((e=>{var t,r;Object.assign(e,{__time:s(e.sendTime).msgTime,__content:(r=e.content.chatMessageType,[a.TEXT,a.TEXT,a.BLEND].includes(r)?n(e.content):null==(t=e.content)?void 0:t.msg),__sendTime:s(e.sendTime).recordTime}),e.content.chatMessageType!==a.FILE||e.__size||i(e.content.fileUrl).then((t=>{e.__size=t}))})),_()&&v()},stompClient:f,emit:h,sendMessage:w,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=u.sessionList.find((e=>e.receiver===i));r||await p({chatType:T.SINGLE,receiver:i,sender:u.userInfo.id});const o=(null==r?void 0:r.chatType)||T.SINGLE;w({chatType:o,receiver:i,content:n}),await g(100),s&&w({chatType:o,receiver:i,content:{chatMessageType:a.TEXT,msg:s}}),await g(100)}}}}export{u as useState};
@@ -1,4 +1,4 @@
1
- import { InjectionKey, Ref } from 'vue';
1
+ import { InjectionKey, Ref, ComputedRef } from 'vue';
2
2
  import { AnyObject } from '../../../../shared/types';
3
3
  import { ChatSock } from '../utils/chatSock';
4
4
  import { UploadFileInfo } from 'naive-ui';
@@ -28,3 +28,4 @@ export type FileOptions = {
28
28
  export declare const InjectionIChatState: InjectionKey<IState>;
29
29
  export declare const InjectionIChatStompClient: InjectionKey<Ref<ChatSock>>;
30
30
  export declare const InjectionIChatEmits: InjectionKey<(event: string, ...args: any[]) => void>;
31
+ export declare const InjectionIChatUnreadTotal: InjectionKey<ComputedRef<number>>;
@@ -1 +1 @@
1
- const t=Symbol("InjectionIChatState"),o=Symbol("InjectionIChatStompClient"),n=Symbol("InjectionIChatEmits");export{n as InjectionIChatEmits,t as InjectionIChatState,o as InjectionIChatStompClient};
1
+ const t=Symbol("InjectionIChatState"),o=Symbol("InjectionIChatStompClient"),n=Symbol("InjectionIChatEmits"),e=Symbol("InjectionIChatUnreadTotal");export{n as InjectionIChatEmits,t as InjectionIChatState,o as InjectionIChatStompClient,e as InjectionIChatUnreadTotal};