cnhis-design-vue 3.2.14-beta.14 → 3.2.14-beta.19
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.
- package/es/components/ai-chat/src/components/ChatCard.js +1 -1
- package/es/components/field-set/src/FieldFilter.vue.d.ts +3 -2
- package/es/components/field-set/src/FieldFilter.vue2.js +1 -1
- package/es/components/field-set/src/components/table-row.vue2.js +1 -1
- package/es/components/field-set/src/constants/filter.d.ts +21 -12
- package/es/components/field-set/src/constants/filter.js +1 -1
- package/es/components/field-set/src/types/index.d.ts +1 -1
- package/es/components/form-render/src/hooks/useFieldListAdaptor.js +1 -1
- package/es/components/form-render/src/hooks/usePresetScope.d.ts +1 -1
- package/es/components/form-render/src/hooks/usePresetScope.js +1 -1
- package/es/components/iho-chat/index.d.ts +437 -49
- package/es/components/iho-chat/src/Index.vue.d.ts +440 -56
- package/es/components/iho-chat/src/Index.vue2.js +1 -1
- package/es/components/iho-chat/src/components/ChatAdd.vue.d.ts +19 -1
- package/es/components/iho-chat/src/components/ChatAdd.vue2.js +1 -1
- package/es/components/iho-chat/src/components/ChatFile.vue.d.ts +39 -3
- package/es/components/iho-chat/src/components/ChatFile.vue2.js +1 -1
- package/es/components/iho-chat/src/components/ChatFooter.vue.d.ts +38 -2
- package/es/components/iho-chat/src/components/ChatFooter.vue2.js +1 -1
- package/es/components/iho-chat/src/components/ChatHeader.vue.d.ts +172 -10
- package/es/components/iho-chat/src/components/ChatHeader.vue2.js +1 -1
- package/es/components/iho-chat/src/components/ChatMain.vue.d.ts +58 -4
- package/es/components/iho-chat/src/components/ChatMain.vue2.js +1 -1
- package/es/components/iho-chat/src/components/ChatRecord.vue.d.ts +19 -1
- package/es/components/iho-chat/src/components/ChatRecord.vue2.js +1 -1
- package/es/components/iho-chat/src/components/ChatSearch.vue.d.ts +20 -2
- package/es/components/iho-chat/src/components/ChatSearch.vue2.js +1 -1
- package/es/components/iho-chat/src/components/ChatSet.vue.d.ts +57 -3
- package/es/components/iho-chat/src/components/ChatSet.vue2.js +1 -1
- package/es/components/iho-chat/src/components/ContextMenu.js +1 -1
- package/es/components/iho-chat/src/components/MessageTemplate.vue.d.ts +1 -1
- package/es/components/iho-chat/src/components/MessageTemplate.vue2.js +1 -1
- package/es/components/iho-chat/src/components/MultipleVideo.vue.d.ts +38 -2
- package/es/components/iho-chat/src/components/MultipleVideo.vue2.js +1 -1
- package/es/components/iho-chat/src/components/PersonProfile.vue.d.ts +19 -1
- package/es/components/iho-chat/src/components/PersonProfile.vue2.js +1 -1
- package/es/components/iho-chat/src/components/SiderList.vue.d.ts +19 -1
- package/es/components/iho-chat/src/components/SiderList.vue2.js +1 -1
- package/es/components/iho-chat/src/components/Video.vue.d.ts +19 -1
- package/es/components/iho-chat/src/components/Video.vue2.js +1 -1
- package/es/components/iho-chat/src/hooks/index.d.ts +2 -2
- package/es/components/iho-chat/src/hooks/index.js +1 -1
- package/es/components/iho-chat/src/hooks/useData.d.ts +94 -0
- package/es/components/iho-chat/src/hooks/useData.js +1 -0
- package/es/components/iho-chat/src/hooks/useSearchUserList.js +1 -1
- package/es/components/iho-chat/src/hooks/useVideo.d.ts +19 -1
- package/es/components/iho-chat/src/hooks/useVideo.js +1 -1
- package/es/components/iho-chat/src/hooks/useWebSocket.d.ts +3 -0
- package/es/components/iho-chat/src/hooks/useWebSocket.js +1 -0
- package/es/components/iho-chat/src/types/index.d.ts +0 -6
- package/es/components/iho-chat/src/types/index.js +1 -1
- package/es/components/iho-chat/src/utils/index.js +1 -1
- package/es/shared/package.json.js +1 -1
- package/package.json +2 -2
- package/es/components/iho-chat/src/hooks/useSession.d.ts +0 -14
- package/es/components/iho-chat/src/hooks/useSession.js +0 -1
- package/es/components/iho-chat/src/hooks/useState.d.ts +0 -18
- package/es/components/iho-chat/src/hooks/useState.js +0 -1
@@ -1 +1 @@
|
|
1
|
-
import{defineComponent as t,ref as e,reactive as a,computed as l,openBlock as n,createBlock as o,unref as r,withCtx as s,renderSlot as i,createElementBlock as c,Fragment as u,withDirectives as d,createElementVNode as p,createVNode as
|
1
|
+
import{defineComponent as t,ref as e,reactive as a,computed as l,openBlock as n,createBlock as o,unref as r,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 k,vShow as y}from"vue";import{NPopover as b,NAvatar as h,NButton as j,NIcon as w}from"naive-ui";import{ChatbubbleEllipses as C,EyeOffOutline as I,EyeOutline as _,Close as x}from"@vicons/ionicons5";import{useData as z}from"../hooks/useData.js";import"stompjs";import"sockjs-client/dist/sockjs.min.js";import{CHAT_TYPE as N}from"../constants/index.js";import{openSessionApi as D,getUserDetailApi as S}from"../api/index.js";import"../utils/index.js";import"trtc-sdk-v5";const $={class:"person-profile-main"},E={class:"left"},L={class:"profile"},P={class:"profile__text"},q={class:"right"},B={class:"right__content"},G={class:"label"},O={class:"content"};var T=t({__name:"PersonProfile",props:{userId:{type:String,required:!0},disabled:{type:Boolean,default:!1}},emits:["close"],setup(t,{emit:T}){const U=t,{state:A,openSession:F}=z(),H=e(!1),J=e(!1),K=e(!1),M=a({}),Q=[{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"}],R=l((()=>(M.id&&Q.forEach((t=>{const{key:e}=t;t.value=M[e]})),Q)));async function V(){H.value=!1;let t=A.sessionList.find((t=>t.receiver===U.userId));if(!t)try{t=await D({chatType:N.SINGLE,receiver:U.userId,sender:A.userInfo.id})}catch(t){console.log("error :>> ",t)}t&&F(t),T("close")}async function W(t){if(!t)return;const e=await S({userId:U.userId});(null==e?void 0:e.id)?Object.assign(M,e):M.id=""}function X(t){const{key:e,value:a}=t;return"phone"!==e||K.value?a:(a||"").replace(/(\d{3})\d{4}(\d{4})/,"$1****$2")}return(e,a)=>(n(),o(r(b),{raw:"",class:"person-profile-wrapper",show:H.value,"onUpdate:show":[a[3]||(a[3]=t=>H.value=t),W],trigger:t.disabled?"manual":"click","show-arrow":!1,to:"body",shift:""},{trigger:s((()=>[i(e.$slots,"trigger")])),default:s((()=>[M.id?(n(),c(u,{key:0},[d(p("div",$,[p("div",E,[p("div",L,[m(r(h),{src:M.avatar,bordered:"",round:"",size:100,onClickCapture:a[0]||(a[0]=t=>J.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",P,[p("h4",null,f(M.name),1),p("p",null,f(M.orgName),1)]),m(r(j),{strong:"",secondary:"",onClick:V},{default:s((()=>[m(r(w),{size:"13",color:"#666666",component:r(C),style:{"margin-right":"6px"}},null,8,["component"]),g(" 发消息 ")])),_:1})])]),p("div",q,[p("div",B,[(n(!0),c(u,null,k(r(R),((t,e)=>(n(),c("div",{class:"info-item",key:e},[p("span",G,f(t.label),1),p("div",O,[p("span",null,f(X(t)),1),"phone"===t.key&&X(t)?(n(),o(r(w),{key:0,size:"16",color:"#666666",component:K.value?r(I):r(_),style:{"margin-left":"10px"},onClick:a[1]||(a[1]=t=>K.value=!K.value)},null,8,["component"])):v("v-if",!0)])])))),128))])])],512),[[y,!J.value]]),d(p("div",{class:"large-avatar",onClick:a[2]||(a[2]=t=>J.value=!1)},[m(r(j),{circle:"",size:"small",secondary:""},{icon:s((()=>[m(r(w),{size:24,component:r(x),color:"#fff"},null,8,["component"])])),_:1}),m(r(h),{size:310,round:"",src:M.avatar},null,8,["src"])],512),[[y,J.value]])],64)):v("v-if",!0)])),_:3},8,["show","trigger"]))}});export{T as default};
|
@@ -15,7 +15,25 @@ declare const _default: import("vue").DefineComponent<{}, {
|
|
15
15
|
key: string;
|
16
16
|
}[]>;
|
17
17
|
currentFilterKey: import("vue").Ref<string>;
|
18
|
-
state:
|
18
|
+
state: {
|
19
|
+
orgId: string | number;
|
20
|
+
currentSessionItem: AnyObject;
|
21
|
+
id: string;
|
22
|
+
userInfo: AnyObject;
|
23
|
+
msgList: AnyObject[];
|
24
|
+
currentMsg: AnyObject;
|
25
|
+
isAppendMsg: boolean;
|
26
|
+
sessionList: AnyObject[];
|
27
|
+
isChangeSession: boolean;
|
28
|
+
updateSessionItem: AnyObject;
|
29
|
+
isUpdateSession: boolean;
|
30
|
+
currentReferenceMsg: AnyObject | null;
|
31
|
+
currentReEditMsg: AnyObject | null;
|
32
|
+
showVideo: boolean;
|
33
|
+
currentAVMsg: AnyObject;
|
34
|
+
currentGroupUser: AnyObject[];
|
35
|
+
showMultipleVideo: boolean;
|
36
|
+
};
|
19
37
|
unreadTotal: import("vue").ComputedRef<number>;
|
20
38
|
openSession: (item: AnyObject) => Promise<void>;
|
21
39
|
currentWidth: import("vue").ComputedRef<number>;
|
@@ -1 +1 @@
|
|
1
|
-
import{defineComponent as e,ref as s,computed as
|
1
|
+
import{defineComponent as e,ref as s,computed as i,withDirectives as t,openBlock as l,createElementBlock as a,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 x,NAvatar as g,NBadge as b}from"naive-ui";import{useData as M}from"../hooks/useData.js";import"stompjs";import"sockjs-client/dist/sockjs.min.js";import{STATUS as j}from"../constants/index.js";import"../api/index.js";import{listSort as N,formatTime as D}from"../utils/index.js";import"trtc-sdk-v5";import{vFlexibleResize as T}from"../../../../shared/directive/flexibleResize.js";const C={class:"sider-list__filter box-shadow"},S=["onClick"],E={class:"avatar-right"},L={class:"name"},R={class:"msg-tip"},w={class:"msg-tip__content"},H={key:0},z=["innerHTML"];var K=e({__name:"SiderList",setup(e){const K="all",W="unread",A="ended";let B=[];const I=s(300),V=s(),q=s(!1),F=s([{label:"全部",key:K},{label:"未读",key:W},{label:"结束",key:A}]),G=s("all"),{state:J,unreadTotal:O,openSession:P}=M(),Q=i((()=>Math.min(Math.max(I.value,240),360))),U=i((()=>N(J.sessionList)));function X({distance:e}){I.value=I.value+e}function Y(e,s=r(G)){var i;return s===K||(s===W?B.includes(e.sessionKey)||(null!=(i=e.unreadNum)?i:0)>0:s===A?e.status===j.ENDED:void 0)}return(e,s)=>t((l(),a("section",{class:"sider-list",style:n({width:r(Q)+"px"})},[q.value?(l(),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",C,[(l(!0),a(v,null,m(F.value,(e=>(l(),o(r(x),{type:G.value===e.key?"info":"default",round:"",bordered:!1,key:e.key,onClick:()=>{return s=e.key,G.value=s,void(s===W&&(B=(U.value.filter((e=>{var s;return(null!=(s=e.unreadNum)?s:0)>0}))||[]).map((e=>e.sessionKey))));var s}},{default:c((()=>{return[p(k(e.label)+"("+k((s=e,s.key===A?U.value.filter((e=>e.status===j.ENDED)).length:O.value))+") ",1)];var s})),_:2},1032,["type","onClick"])))),128))]),d("div",{class:"sider-list__box",ref_key:"listBoxRef",ref:V},[(l(!0),a(v,null,m(r(U),(e=>t((l(),a("div",{key:e.id,onClick:()=>r(P)(e),class:f(["sider-list__box__item",{active:e.id===r(J).id},e.topping?"sider-list__box__item--top":""])},[y(r(g),{round:"",size:"large",src:e.avatar},null,8,["src"]),d("div",E,[d("div",L,[d("h4",null,k(e.name),1),d("span",null,k(e.lastMessage?r(D)(e.lastMessageSendTime).siderMsgTime:""),1)]),d("div",R,[d("div",w,["WITHDRAWN"===e.lastMessageStatus?(l(),a("div",H,"撤回了一条消息")):(l(),a("div",{key:1,innerHTML:e.lastMessageContent},null,8,z))]),y(r(b),{value:e.unreadNum>99?"99+":e.unreadNum},null,8,["value"])])])],10,S)),[[_,Y(e)]]))),128))],512)],4)),[[r(T),{mode:"VR",onMove:X}]])}});export{K as default};
|
@@ -6,7 +6,25 @@ declare const _default: import("vue").DefineComponent<{}, {
|
|
6
6
|
content: import("../../../../shared/types").AnyObject;
|
7
7
|
receiver?: string | undefined;
|
8
8
|
}) => Promise<void>;
|
9
|
-
state:
|
9
|
+
state: {
|
10
|
+
orgId: string | number;
|
11
|
+
currentSessionItem: import("../../../../shared/types").AnyObject;
|
12
|
+
id: string;
|
13
|
+
userInfo: import("../../../../shared/types").AnyObject;
|
14
|
+
msgList: import("../../../../shared/types").AnyObject[];
|
15
|
+
currentMsg: import("../../../../shared/types").AnyObject;
|
16
|
+
isAppendMsg: boolean;
|
17
|
+
sessionList: import("../../../../shared/types").AnyObject[];
|
18
|
+
isChangeSession: boolean;
|
19
|
+
updateSessionItem: import("../../../../shared/types").AnyObject;
|
20
|
+
isUpdateSession: boolean;
|
21
|
+
currentReferenceMsg: import("../../../../shared/types").AnyObject | null;
|
22
|
+
currentReEditMsg: import("../../../../shared/types").AnyObject | null;
|
23
|
+
showVideo: boolean;
|
24
|
+
currentAVMsg: import("../../../../shared/types").AnyObject;
|
25
|
+
currentGroupUser: import("../../../../shared/types").AnyObject[];
|
26
|
+
showMultipleVideo: boolean;
|
27
|
+
};
|
10
28
|
trtc: TRTC;
|
11
29
|
timing: import("vue").Ref<string>;
|
12
30
|
voiceOpen: import("vue").Ref<boolean>;
|
@@ -1 +1 @@
|
|
1
|
-
import{defineComponent as e,ref as o,computed as
|
1
|
+
import{defineComponent as e,ref as o,computed as s,watch as t,onBeforeUnmount as r,openBlock as n,createElementBlock as a,withDirectives as i,createElementVNode as l,vShow as c,createVNode as u,unref as d,toDisplayString as v,Fragment as m,normalizeClass as p,withCtx as f}from"vue";import{NAvatar as h,NButton as g,NIcon as I}from"naive-ui";import{Mic as A,MicOffCircle as k,Call as y}from"@vicons/ionicons5";import{avFinishApi as E}from"../api/index.js";import"@vueuse/core";import"../utils/index.js";import"lodash-es";import{AV_STATUS as V,CHAT_TYPE as R}from"../constants/index.js";import"../../../../shared/utils/index.js";import"date-fns";import"@vue/shared";import"@vueuse/shared";import"../../../../shared/hooks/selectHooks/useSearchContent.js";import"../../../../shared/hooks/useScrollLoading.js";import"stompjs";import"sockjs-client/dist/sockjs.min.js";import{useVideo as S}from"../hooks/useVideo.js";import w from"trtc-sdk-v5";const M={class:"video-wrapper"},b={class:"user"},T={class:"name"},j={class:"tip"},x={class:"opt-btn"},C={class:"btn"},_=l("span",null,"静音",-1),L=l("span",null,"拒接",-1),N={class:"btn"},H=l("span",null,"挂断",-1),D=l("span",null,"接听",-1);var z=e({__name:"Video",setup(e){const{sendMessage:z,state:U,trtc:F,timing:O,voiceOpen:G,isAudio:J,isCall:P,startTimer:$,resetTimer:q,toggleAudio:B,messageTypeText:K,time:Q,installEventHandlers:W,uninstallEventHandlers:X}=S(),Y=o(),Z=o(),ee=o(!1);let oe=null;const se=s((()=>{var e,o,s;return P.value?{avatar:U.currentSessionItem.avatar,name:U.currentSessionItem.name,userId:U.currentSessionItem.receiver}:{avatar:null==(e=U.currentAVMsg.currentMsg)?void 0:e.senderAvatar,name:null==(o=U.currentAVMsg.currentMsg)?void 0:o.senderName,userId:null==(s=U.currentAVMsg.currentMsg)?void 0:s.sender}})),te=s((()=>ee.value?J.value?O.value:"":P.value?"正在呼叫...":`邀请你${K.value}问诊...`)),re=s((()=>{var e,o;return null==(o=null==(e=U.currentAVMsg.currentMsg)?void 0:e.content)?void 0:o.avStatus}));async function ne(e=V.FINISHED){z({chatType:R.SINGLE,content:{msg:e===V.FINISHED?""+Q.seconds:"s",chatMessageType:U.currentAVMsg.chatMessageType,avStatus:e},receiver:se.value.userId}),await E({recordId:U.currentAVMsg.currentMsg.id,status:e,duration:e===V.FINISHED?Q.seconds:0})}async function ae(){const e=await w.isSupported();if(!e.result||!e.detail.isH264EncodeSupported||!e.detail.isH264DecodeSupported)return console.log("checkResult :>> ",e),void(U.showVideo=!1);try{if(await F.enterRoom({strRoomId:U.currentAVMsg.strRoomId,sdkAppId:parseInt(U.userInfo.sdkAppID),userId:U.userInfo.id,userSig:U.userInfo.userSig}),P.value||(ee.value=!0,$()),W({handleError:me,handleRemoteUserEnter:de,handleRemoteAudioAvailable:ue,handleRemoteUserExit:ve,handleRemoteVideoAvailable:ce}),await F.startLocalAudio(),J.value)return;await F.startLocalVideo({view:Z.value})}catch(e){console.log("error :>> ",e),U.showVideo=!1}}function ie(){P.value&&!ee.value?ne(V.CANCELED):ne()}async function le(){try{if(U.showVideo=!1,X({handleError:me,handleRemoteUserEnter:de,handleRemoteAudioAvailable:ue,handleRemoteUserExit:ve,handleRemoteVideoAvailable:ce}),await F.exitRoom(),await F.stopLocalAudio(),J.value)return;await F.stopLocalVideo()}catch(e){console.log("error :>> ",e)}}async function ce(e){const{userId:o,streamType:s}=e;try{await F.startRemoteVideo({userId:o,streamType:s,view:Y.value})}catch(e){console.log("error :>> ",e)}}function ue(e){}function de(){ee.value=!0,$()}function ve(e){console.log("event :>> 对方已挂断",e),le()}function me(e){console.log("error :>> ",e),U.showVideo=!1}return t((()=>re.value),(e=>{U.showVideo&&(e===V.IN_CALL?async function(){P.value?ae():(oe&&clearTimeout(oe),oe=setTimeout((async()=>{ee.value||ne(V.NO_RESPONSE)}),6e4))}():le())}),{immediate:!0}),r((()=>{le()})),(e,o)=>(n(),a("div",M,[i(l("div",{class:"video-box",ref_key:"videoRef",ref:Y},null,512),[[c,ee.value]]),i(l("div",{class:"video-box--self",ref_key:"selfVideoRef",ref:Z},null,512),[[c,ee.value]]),i(l("div",b,[u(d(h),{size:58,round:"",src:d(se).avatar},null,8,["src"]),l("span",T,v(d(se).name),1),l("span",j,v(d(te)),1)],512),[[c,d(J)||!ee.value]]),l("div",x,[l("div",C,[d(P)&&!ee.value||ee.value?(n(),a(m,{key:0},[u(d(g),{circle:"",onClick:d(B),class:p({bordered:d(G)})},{icon:f((()=>[u(d(I),{size:"30",color:d(G)?"#fff":"#626262",component:d(G)?d(A):d(k)},null,8,["color","component"])])),_:1},8,["onClick","class"]),_],64)):(n(),a(m,{key:1},[u(d(g),{circle:"",color:"#f17568",class:"btn--rotate",onClick:o[0]||(o[0]=()=>ne(d(V).REJECTED))},{icon:f((()=>[u(d(I),{size:"30",component:d(y)},null,8,["component"])])),_:1}),L],64))]),l("div",N,[d(P)&&!ee.value||ee.value?(n(),a(m,{key:0},[u(d(g),{circle:"",color:"#f17568",class:"btn--rotate",onClick:ie},{icon:f((()=>[u(d(I),{size:"30",component:d(y)},null,8,["component"])])),_:1}),H],64)):(n(),a(m,{key:1},[u(d(g),{circle:"",color:"#2ac98b",onClick:ae},{icon:f((()=>[u(d(I),{size:"30",component:d(y)},null,8,["component"])])),_:1}),D],64))])])]))}});export{z as default};
|
@@ -1,3 +1,3 @@
|
|
1
|
-
export * from './
|
2
|
-
export * from './
|
1
|
+
export * from './useData';
|
2
|
+
export * from './useWebSocket';
|
3
3
|
export * from './useVideo';
|
@@ -1 +1 @@
|
|
1
|
-
export{
|
1
|
+
export{InjectionIChatData,initData,useData}from"./useData.js";export{useWebSocket}from"./useWebSocket.js";export{useVideo}from"./useVideo.js";
|
@@ -0,0 +1,94 @@
|
|
1
|
+
import { InjectionKey } from 'vue';
|
2
|
+
import { ChatSock } from '../utils/chatSock';
|
3
|
+
import { AnyObject } from '../../../../shared/types';
|
4
|
+
export declare const InjectionIChatData: InjectionKey<ReturnType<typeof initData>>;
|
5
|
+
export declare function initData(props: AnyObject, emit: (event: 'template-click' | 'unread-message-update' | 'session-change', ...args: any[]) => void): {
|
6
|
+
cssVars: import("vue").ComputedRef<AnyObject>;
|
7
|
+
stompClient: import("vue").Ref<ChatSock | undefined>;
|
8
|
+
state: {
|
9
|
+
orgId: string | number;
|
10
|
+
currentSessionItem: AnyObject;
|
11
|
+
id: string;
|
12
|
+
userInfo: AnyObject;
|
13
|
+
msgList: AnyObject[];
|
14
|
+
currentMsg: AnyObject;
|
15
|
+
isAppendMsg: boolean;
|
16
|
+
sessionList: AnyObject[];
|
17
|
+
isChangeSession: boolean;
|
18
|
+
updateSessionItem: AnyObject;
|
19
|
+
isUpdateSession: boolean;
|
20
|
+
currentReferenceMsg: AnyObject | null;
|
21
|
+
currentReEditMsg: AnyObject | null;
|
22
|
+
showVideo: boolean;
|
23
|
+
currentAVMsg: AnyObject;
|
24
|
+
currentGroupUser: AnyObject[];
|
25
|
+
showMultipleVideo: boolean;
|
26
|
+
};
|
27
|
+
unreadTotal: import("vue").ComputedRef<number>;
|
28
|
+
isGroupChat: import("vue").ComputedRef<boolean>;
|
29
|
+
isGroupLeader: import("vue").ComputedRef<boolean>;
|
30
|
+
isEnded: import("vue").ComputedRef<boolean>;
|
31
|
+
setMsgList: (list?: AnyObject[]) => void;
|
32
|
+
sendMessage: (message: {
|
33
|
+
chatType?: string;
|
34
|
+
content: AnyObject;
|
35
|
+
receiver?: string;
|
36
|
+
}) => Promise<void>;
|
37
|
+
relayMessage: (param: {
|
38
|
+
checkedIds: string[];
|
39
|
+
remark: string;
|
40
|
+
content: AnyObject;
|
41
|
+
}) => Promise<void>;
|
42
|
+
openSession: (item: AnyObject) => Promise<void>;
|
43
|
+
closeSession: () => AnyObject | null;
|
44
|
+
getCurrentSession: () => AnyObject | null;
|
45
|
+
setCurrentSessionItem: (item: AnyObject) => void;
|
46
|
+
setUpdateSessionItem: (item: AnyObject) => void;
|
47
|
+
setSessionList: (list: AnyObject[]) => void;
|
48
|
+
emit: (event: 'template-click' | 'unread-message-update' | 'session-change', ...args: any[]) => void;
|
49
|
+
};
|
50
|
+
export declare const useData: () => {
|
51
|
+
cssVars: import("vue").ComputedRef<AnyObject>;
|
52
|
+
stompClient: import("vue").Ref<ChatSock | undefined>;
|
53
|
+
state: {
|
54
|
+
orgId: string | number;
|
55
|
+
currentSessionItem: AnyObject;
|
56
|
+
id: string;
|
57
|
+
userInfo: AnyObject;
|
58
|
+
msgList: AnyObject[];
|
59
|
+
currentMsg: AnyObject;
|
60
|
+
isAppendMsg: boolean;
|
61
|
+
sessionList: AnyObject[];
|
62
|
+
isChangeSession: boolean;
|
63
|
+
updateSessionItem: AnyObject;
|
64
|
+
isUpdateSession: boolean;
|
65
|
+
currentReferenceMsg: AnyObject | null;
|
66
|
+
currentReEditMsg: AnyObject | null;
|
67
|
+
showVideo: boolean;
|
68
|
+
currentAVMsg: AnyObject;
|
69
|
+
currentGroupUser: AnyObject[];
|
70
|
+
showMultipleVideo: boolean;
|
71
|
+
};
|
72
|
+
unreadTotal: import("vue").ComputedRef<number>;
|
73
|
+
isGroupChat: import("vue").ComputedRef<boolean>;
|
74
|
+
isGroupLeader: import("vue").ComputedRef<boolean>;
|
75
|
+
isEnded: import("vue").ComputedRef<boolean>;
|
76
|
+
setMsgList: (list?: AnyObject[]) => void;
|
77
|
+
sendMessage: (message: {
|
78
|
+
chatType?: string;
|
79
|
+
content: AnyObject;
|
80
|
+
receiver?: string;
|
81
|
+
}) => Promise<void>;
|
82
|
+
relayMessage: (param: {
|
83
|
+
checkedIds: string[];
|
84
|
+
remark: string;
|
85
|
+
content: AnyObject;
|
86
|
+
}) => Promise<void>;
|
87
|
+
openSession: (item: AnyObject) => Promise<void>;
|
88
|
+
closeSession: () => AnyObject | null;
|
89
|
+
getCurrentSession: () => AnyObject | null;
|
90
|
+
setCurrentSessionItem: (item: AnyObject) => void;
|
91
|
+
setUpdateSessionItem: (item: AnyObject) => void;
|
92
|
+
setSessionList: (list: AnyObject[]) => void;
|
93
|
+
emit: (event: 'template-click' | 'unread-message-update' | 'session-change', ...args: any[]) => void;
|
94
|
+
};
|
@@ -0,0 +1 @@
|
|
1
|
+
import{ref as e,reactive as s,computed as t,watch as n,inject as i,toRaw as r}from"vue";import{openSessionApi as o,groupUserApi as a}from"../api/index.js";import{promiseTimeout as c,useIntervalFn as u}from"@vueuse/core";import{listSort as m,formatTime as d,transformMessage as l,getFileSize as p,simplifyMessage as g}from"../utils/index.js";import{cloneDeep as h,isArray as f,uniqBy as S}from"lodash-es";import{STATUS as T,CHAT_TYPE as I,MESSAGE_TYPE as y}from"../constants/index.js";import{useTheme as v}from"../../../../shared/hooks/useTheme.js";import"date-fns";import"@vue/shared";import"../../../../shared/utils/index.js";import"@vueuse/shared";import"../../../../shared/hooks/selectHooks/useSearchContent.js";import"@vicons/ionicons5";import"naive-ui";import"../../../../shared/hooks/useScrollLoading.js";const L=Symbol("InjectionIChatData");function M(e){return e.chatType===I.GROUP}function C(e){const{lastMessage:s,lastSenderName:t=""}=e,n=g(s)||"";return M(e)&&t?t+": "+n:n}function N(i,g){const L=e(),N=s({orgId:i.orgId,currentSessionItem:{},id:"",userInfo:{id:i.userId},msgList:[],currentMsg:{},isAppendMsg:!1,sessionList:[],isChangeSession:!1,updateSessionItem:{},isUpdateSession:!1,currentReferenceMsg:null,currentReEditMsg:null,showVideo:!1,currentAVMsg:{},currentGroupUser:[],showMultipleVideo:!1}),U=v(),j=t((()=>N.sessionList.reduce(((e,s)=>e+ +s.unreadNum),0))),w=t((()=>M(N.currentSessionItem))),E=t((()=>{var e,s,t;return(null==(e=N.userInfo)?void 0:e.id)===(null==(t=null==(s=N.currentGroupUser)?void 0:s[0])?void 0:t.id)})),G=t((()=>{var e;return(null==(e=N.currentSessionItem)?void 0:e.status)===T.ENDED}));n((()=>j.value),(e=>{!async function s(t=0){if(t>2)return;const n=N.sessionList.filter((e=>{var s;return+(null!=(s=e.unreadNum)?s:0)>0}));n.every((e=>!!e.name))?g("unread-message-update",e,m(n)):(await c(300),s(++t))}()})),n([()=>N.isChangeSession,()=>N.isUpdateSession],(([e,s])=>{e&&(x(N.currentSessionItem),N.isChangeSession=!1),s&&(x(N.updateSessionItem),N.isUpdateSession=!1)}),{immediate:!0});const{pause:_,resume:D,isActive:K}=u((()=>{const e=h(N.msgList);e.some((e=>{const{sendTime:s}=e;return!(Date.now()-new Date(s).getTime()>=36e5)&&(e.__sendTime=d(s).recordTime,!0)})),N.msgList=e,R()||_()}),6e4,{immediate:!1});function R(){return!!N.msgList.length&&N.msgList.some((e=>Date.now()-new Date(e.sendTime).getTime()<36e5))}async function O(e){var s;try{null==(s=L.value)||s.send("/app/chat/send",{},JSON.stringify({chatType:N.currentSessionItem.chatType,receiver:N.currentSessionItem.receiver,...e}))}catch(e){}}function k(e){Object.assign(N.currentSessionItem,e,{lastMessageContent:Reflect.has(e,"lastMessageContent")?e.lastMessageContent:Reflect.has(e,"lastMessage")?C({...e,chatType:e.chatType||N.currentSessionItem.chatType}):N.currentSessionItem.lastMessageContent}),N.isChangeSession=!0,N.id!==N.currentSessionItem.id&&(N.msgList=[],N.id=N.currentSessionItem.id)}function b(e){N.sessionList=h(S(e,"id")),N.sessionList.forEach((e=>{Object.assign(e,{defaultName:Reflect.has(e,"defaultName")?e.defaultName:e.name||"",lastMessageContent:Reflect.has(e,"lastMessageContent")?e.lastMessageContent:C(e)}),e.receiver===N.userInfo.id&&(e.unreadNum=0),e.chatType!==I.GROUP||e.name||a({id:e.receiver}).then((s=>{f(s)&&(e.name=s.map((e=>e.name)).join(","))}))}))}function x(e){!e.id||N.sessionList.map((e=>e.id)).includes(e.id)?N.sessionList.some((s=>{if(s.sessionKey===e.sessionKey){let{unreadNum:t=0}=s;return Object.assign(s,e),e.sessionKey!==N.currentSessionItem.sessionKey&&s.sender&&s.sender!==N.userInfo.id&&(s.unreadNum=++t),!0}})):b([...N.sessionList,e])}return{cssVars:U,stompClient:L,state:N,unreadTotal:j,isGroupChat:w,isGroupLeader:E,isEnded:G,setMsgList:function(e=[]){_(),N.msgList=h(e).sort(((e,s)=>new Date(s.sendTime).getTime()-new Date(e.sendTime).getTime())),N.msgList.forEach((e=>{var s,t;Object.assign(e,{__time:d(e.sendTime).msgTime,__content:(t=e.content.chatMessageType,[y.TEXT,y.TEXT,y.BLEND].includes(t)?l(e.content):null==(s=e.content)?void 0:s.msg),__sendTime:d(e.sendTime).recordTime}),e.content.chatMessageType!==y.FILE||e.__size||p(e.content.fileUrl).then((s=>{e.__size=s}))})),R()&&D()},sendMessage:O,relayMessage:async function(e){const{checkedIds:s,remark:t,content:n}=e;for(let e=0;e<s.length;e++){const i=s[e],r=N.sessionList.find((e=>e.receiver===i));r||await o({chatType:I.SINGLE,receiver:i,sender:N.userInfo.id});const a=(null==r?void 0:r.chatType)||I.SINGLE;O({chatType:a,receiver:i,content:n}),await c(100),t&&O({chatType:a,receiver:i,content:{chatMessageType:y.TEXT,msg:t}}),await c(100)}},openSession:async function(e){const s=N.currentSessionItem.sessionKey;if(k(e),s!==N.currentSessionItem.sessionKey){if(w.value){const s=await a({id:e.receiver});N.currentGroupUser=f(s)?s:[]}else N.currentGroupUser=S([N.userInfo,{...h(e),id:e.receiver}],"id");g("session-change",{...r(N.currentSessionItem),userList:N.currentGroupUser.map((e=>r(e)))})}},closeSession:function(){if(!N.id)return null;const{currentSessionItem:e}=N;return N.currentSessionItem={},N.msgList=[],N.id="",N.currentGroupUser=[],e},getCurrentSession:function(){return N.id?N.currentSessionItem:null},setCurrentSessionItem:k,setUpdateSessionItem:function(e){const s=N.sessionList.find((s=>s.sessionKey===e.sessionKey)),t={...e,lastMessageContent:C({...e,chatType:e.chatType||(null==s?void 0:s.chatType)})};N.updateSessionItem=s?{...h(s),...t}:t,N.isUpdateSession=!0},setSessionList:b,emit:g}}const U=()=>i(L);export{L as InjectionIChatData,N as initData,U as useData};
|
@@ -1 +1 @@
|
|
1
|
-
import{ref as e}from"vue";import{isArray as o}from"lodash-es";import{listUserApi as r}from"../api/index.js";import{useDebounceFn as
|
1
|
+
import{ref as e}from"vue";import{isArray as o}from"lodash-es";import{listUserApi as r}from"../api/index.js";import{useDebounceFn as s}from"@vueuse/core";import"../../../../shared/utils/index.js";import"naive-ui";import"date-fns";import"@vue/shared";import"@vueuse/shared";import"../../../../shared/hooks/selectHooks/useSearchContent.js";import"@vicons/ionicons5";import{useScrollLoading as t}from"../../../../shared/hooks/useScrollLoading.js";import{useData as a}from"./useData.js";import"stompjs";import"sockjs-client/dist/sockjs.min.js";import"../utils/index.js";import"trtc-sdk-v5";function i({wrapperRef:i,keywordRef:n,before:p,after:u}){const m={page:0,hasMore:!0},{state:c}=a(),d=e([]),l=s((function(){Object.assign(m,{page:0,hasMore:!0}),f()}),300);async function f(){const e=(n.value||"").replace(/^\s+|\s+$/g,"");if(!e)return void(p?p():d.value=[]);if(!m.hasMore)return;m.page++,1==m.page&&(d.value=[]);const s=await r({orgId:c.orgId,keyword:e,page:m.page,pageSize:10});o(s.records)&&d.value.length<=+s.total&&(d.value=m.page>1?d.value.concat(s.records):s.records,null==u||u(),d.value.length>=+s.total&&(m.hasMore=!1))}return t(i,(()=>{f()})),{userList:d,handleInput:l}}export{i as useSearchUserList};
|
@@ -8,7 +8,25 @@ type EventHandlers = {
|
|
8
8
|
handleRemoteVideoAvailable: AnyFn;
|
9
9
|
};
|
10
10
|
export declare function useVideo(): {
|
11
|
-
state:
|
11
|
+
state: {
|
12
|
+
orgId: string | number;
|
13
|
+
currentSessionItem: import("../../../../shared/types").AnyObject;
|
14
|
+
id: string;
|
15
|
+
userInfo: import("../../../../shared/types").AnyObject;
|
16
|
+
msgList: import("../../../../shared/types").AnyObject[];
|
17
|
+
currentMsg: import("../../../../shared/types").AnyObject;
|
18
|
+
isAppendMsg: boolean;
|
19
|
+
sessionList: import("../../../../shared/types").AnyObject[];
|
20
|
+
isChangeSession: boolean;
|
21
|
+
updateSessionItem: import("../../../../shared/types").AnyObject;
|
22
|
+
isUpdateSession: boolean;
|
23
|
+
currentReferenceMsg: import("../../../../shared/types").AnyObject | null;
|
24
|
+
currentReEditMsg: import("../../../../shared/types").AnyObject | null;
|
25
|
+
showVideo: boolean;
|
26
|
+
currentAVMsg: import("../../../../shared/types").AnyObject;
|
27
|
+
currentGroupUser: import("../../../../shared/types").AnyObject[];
|
28
|
+
showMultipleVideo: boolean;
|
29
|
+
};
|
12
30
|
sendMessage: (message: {
|
13
31
|
chatType?: string | undefined;
|
14
32
|
content: import("../../../../shared/types").AnyObject;
|
@@ -1 +1 @@
|
|
1
|
-
import{ref as e,computed as t,onBeforeUnmount as
|
1
|
+
import{ref as e,computed as t,onBeforeUnmount as o}from"vue";import{useData as n}from"./useData.js";import"stompjs";import"sockjs-client/dist/sockjs.min.js";import{MESSAGE_TYPE as a}from"../constants/index.js";import"../api/index.js";import{formatSeconds as E}from"../utils/index.js";import i from"trtc-sdk-v5";function s(){const s={timer:null,seconds:0},{state:l,sendMessage:r}=n(),d=e(""),m=e(!0),u=e(!0),c=t((()=>l.currentAVMsg.chatMessageType===a.AUDIO)),R=t((()=>"call"===l.currentAVMsg.callMode)),T=t((()=>c.value?"语音":"视频")),A=i.create();function v(){d.value="00:00:00",s.timer&&clearInterval(s.timer),s.timer=null,s.seconds=0}return o((()=>{v()})),{state:l,sendMessage:r,trtc:A,timing:d,voiceOpen:m,videocamOpen:u,isAudio:c,isCall:R,startTimer:function(){v(),s.timer=setInterval((()=>{s.seconds++,d.value=E(s.seconds)}),1e3)},resetTimer:v,toggleAudio:async function(){await A.updateLocalAudio({mute:!m.value}),m.value=!m.value},toggleVideo:async function(){await A.updateLocalVideo({mute:!u.value}),u.value=!u.value},messageTypeText:T,time:s,installEventHandlers:function({handleError:e,handleRemoteUserEnter:t,handleRemoteAudioAvailable:o,handleRemoteUserExit:n,handleRemoteVideoAvailable:a}){A.on(i.EVENT.ERROR,e),A.on(i.EVENT.REMOTE_USER_ENTER,t),A.on(i.EVENT.REMOTE_AUDIO_AVAILABLE,o),A.on(i.EVENT.REMOTE_USER_EXIT,n),c.value||A.on(i.EVENT.REMOTE_VIDEO_AVAILABLE,a)},uninstallEventHandlers:function({handleError:e,handleRemoteUserEnter:t,handleRemoteAudioAvailable:o,handleRemoteUserExit:n,handleRemoteVideoAvailable:a}){A.off(i.EVENT.ERROR,e),A.off(i.EVENT.REMOTE_USER_ENTER,t),A.off(i.EVENT.REMOTE_AUDIO_AVAILABLE,o),A.off(i.EVENT.REMOTE_USER_EXIT,n),c.value||A.off(i.EVENT.REMOTE_VIDEO_AVAILABLE,a)}}}export{s as useVideo};
|
@@ -0,0 +1 @@
|
|
1
|
+
import{onBeforeUnmount as e}from"vue";import{ChatSock as s}from"../utils/chatSock.js";import{CHAT_TYPE as t,SUBSCRIBE_MESSAGE_TYPE as n,AV_STATUS as o}from"../constants/index.js";import{readMessageApi as i}from"../api/index.js";import{isAudioOrVideoMessage as c}from"../utils/index.js";function r(r,a){const{stompClient:d,state:u,openSession:l,closeSession:p,setSessionList:h,setUpdateSessionItem:y,setCurrentSessionItem:S}=a,g=[];async function m(e,s){if(u.currentMsg=e,e.sessionKey===u.currentSessionItem.sessionKey)return u.isAppendMsg=!0,e.sender!==u.userInfo.id&&await i({chatType:s,messageIdSet:[e.id],receiver:u.userInfo.id,sender:e.sender}),void S({lastMessageSendTime:e.sendTime,lastMessage:e.content,sortTime:e.sendTime,unreadNum:0,lastSenderName:e.senderName});const t={lastMessageSendTime:e.sendTime,sortTime:e.sendTime,lastMessage:e.content,sessionKey:e.sessionKey,lastSenderName:e.senderName,sender:e.sender};y(t)}async function b({body:e,chatType:s}){try{const i=JSON.parse(e),{messageVo:r,sessionVo:a,chatAvStatusVo:l}=i;switch(i.event){case n.MESSAGE:c(r.content)?!u.showVideo&&!u.showMultipleVideo||r.content.avStatus!==o.IN_CALL?(u.currentMsg=r,Object.assign(u.currentAVMsg,{strRoomId:r.sessionKey,chatMessageType:r.content.chatMessageType,callMode:r.sender===u.userInfo.id?"call":"invite",currentMsg:r}),u.showVideo||u.showMultipleVideo?m(r,s):u.showVideo=!0):(d.value.send("/app/chat/send",{},JSON.stringify({chatType:t.SINGLE,receiver:r.sender,content:{chatMessageType:r.content.chatMessageType,avStatus:o.CALL_BUSY}})),console.log("用户忙!")):m(r,s);break;case n.RECALL_MESSAGE:break;case n.AV_STATUS:Object.assign(u.currentAVMsg,l,{callMode:l.sender===u.userInfo.id?"call":"invite",checkedIds:[]}),u.showVideo||u.showMultipleVideo?console.log("用户忙!"):u.showMultipleVideo=!0;break;case n.NEW_SESSION:if(s===t.GROUP)return;y(a);break;case n.JOIN_GROUP:if(s===t.GROUP)return;y(a),d.value.subscribe(`/topic/group/${a.receiver}`,(({body:e})=>b({body:e,chatType:t.GROUP})));case n.LEAVE_GROUP:}}catch(e){console.log(e)}}!function e(){const n={headers:{AccessToken:r.token,UserId:r.userId},heartbeatFn(){try{d.value.send("test")}catch(s){d.value.disconnect(),e()}},connectCb(){console.log("连接成功"),d.value.subscribe("/user/topic/single",(({body:e})=>b({body:e,chatType:t.SINGLE}))),d.value.subscribe("/app/sessionList",(({body:e})=>{try{const s=JSON.parse(e),{authentication:n,currentUser:o,sessionVos:i}=s;if(Object.assign(u.userInfo,o,n),!(null==i?void 0:i.length))return;h(i),g.splice(0,g.length),g.push(...i.filter((e=>e.chatType===t.GROUP))),g.forEach((e=>{d.value.subscribe(`/topic/group/${e.receiver}`,(({body:e})=>b({body:e,chatType:t.GROUP})))})),function(){const e=u.sessionList.find((e=>e.sessionKey===r.defaultSessionKey));e&&l(e)}()}catch(e){console.log(e)}}))},errorCb(e,s){}};d.value=new s("/fdp-chat/websocket",n)}(),e((()=>{var e;null==(e=d.value)||e.disconnect()}))}export{r as useWebSocket};
|
@@ -1,6 +1,4 @@
|
|
1
|
-
import { InjectionKey, Ref, ComputedRef } from 'vue';
|
2
1
|
import { AnyObject } from '../../../../shared/types';
|
3
|
-
import { ChatSock } from '../utils/chatSock';
|
4
2
|
import { UploadFileInfo } from 'naive-ui';
|
5
3
|
export type IState = {
|
6
4
|
orgId: number | string;
|
@@ -25,7 +23,3 @@ export type FileOptions = {
|
|
25
23
|
file: UploadFileInfo;
|
26
24
|
fileList: Array<UploadFileInfo>;
|
27
25
|
};
|
28
|
-
export declare const InjectionIChatState: InjectionKey<IState>;
|
29
|
-
export declare const InjectionIChatStompClient: InjectionKey<Ref<ChatSock>>;
|
30
|
-
export declare const InjectionIChatEmits: InjectionKey<(event: string, ...args: any[]) => void>;
|
31
|
-
export declare const InjectionIChatUnreadTotal: InjectionKey<ComputedRef<number>>;
|
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
|
@@ -1 +1 @@
|
|
1
|
-
import{isToday as e,format as t,isYesterday as n,startOfDay as r}from"date-fns";import{cloneDeep as s,isNumber as o,isNaN as a}from"lodash-es";import{MESSAGE_TYPE as i}from"../constants/index.js";import{emojis as c}from"./emoji.js";import{uuidGenerator as l}from"../../../../shared/utils/index.js";import{createDiscreteApi as m}from"naive-ui";const{message:u}=m(["message"]);function p(r){const s=new Date(r);let o,a;if(e(s))o=a=t(s,"HH:mm");else{o=n(s)?"昨天":t(s,"MM-dd");const e=s.getFullYear(),r=(new Date).getFullYear();a=t(s,e<r?"yyyy年M月d日 HH:mm":"M月d日 HH:mm")}return{siderMsgTime:o,msgTime:a,recordTime:function(r){const s=new Date(r),o=Date.now()-s.getTime();if(o<6e4)return"刚刚";if(o<36e5)return Math.ceil(o/1e3/60)+"分钟前";if(e(s))return"今天 "+t(s,"HH:mm");if(n(s))return"昨天 "+t(s,"HH:mm");{const e=s.getFullYear(),n=(new Date).getFullYear();return t(s,e<n?"yyyy年M月d日 HH:mm":"M月d日 HH:mm")}}(r)}}function d(e){return s(e).sort(((e,t)=>e.topping&&!t.topping?-1:!e.topping&&t.topping?1:new Date(t.sortTime).getTime()-new Date(e.sortTime).getTime()))}function g(e){if(!(null==e?void 0:e.msg))return"";const{chatMessageType:t="",msg:n=""}=e;let r=n.toString();if(t===i.BLEND){const e=r.match(/\[([^\]]+)\]/g);return null==e||e.forEach((e=>{const n=e.match(/\[([^\]]+)\]/);if(n&&n.length>1){const s=c.findEmoji(n[1]);s&&(r=r.replace(e,`<img data-msg=${n[1]} data-type=${t} class="emoji--min" src=${s} />`))}})),r}const s=e=>new RegExp("\\n*\\["+(e||"")+"(code|pre|div|span|p|table|thead|th|tbody|tr|td|ul|li|ol|li|dl|dt|dd|h2|h3|h4|h5)([\\s\\S]*?)]\\n*","g");return r=r.replace(/&(?!#?[a-zA-Z0-9]+;)/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/'/g,"'").replace(/"/g,""").replace(/@(\S+)(\s+?|$)/g,'@<a href="javascript:;">$1</a>$2').replace(s(),"<$1 $2>").replace(s("/"),"</$1>").replace(/\n/g,"<br>"),r}function f(e){if(e&&o(+e)&&!a(+e)){const t=M(+e),n=t.split(":");let r=t;return 3===n.length&&"00"===n[0]&&(r=`${n[1]}:${n[2]}`),"通话时长 "+r}return"已取消"}function h(e){var t;if(!e)return"";const{chatMessageType:n,msg:r,messageTemplate:s}=e,o=E(e)?f(r):"";switch(n){case i.TEXT:return g(e);case i.IMAGE:return"[图片]";case i.FILE:return"[文件]";case i.EMOJI:return`<img class="emoji--min" alt=${r} src=${c.findEmoji(r)}>`;case i.TEMPLATE:return null==(t=null==s?void 0:s.setting)?void 0:t.title;case i.VIDEO:return`[视频通话]${o}`;case i.AUDIO:return`[语音通话]${o}`;default:return"[消息]"}}function w(e,t){const n=new XMLHttpRequest;n.open("GET",e,!0),n.responseType="blob",n.onload=function(e){if(200===n.status){const e=window.URL.createObjectURL(n.response),r=document.createElement("a");r.href=e,r.download=t,r.dispatchEvent(new MouseEvent("click")),window.URL.revokeObjectURL(e)}},n.send()}function y(e){return new Promise(((t,n)=>{const r=new XMLHttpRequest;r.open("HEAD",e,!0),r.onreadystatechange=()=>{var e;if(4===r.readyState&&200===r.status){let n=null!=(e=r.getResponseHeader("Content-Length"))?e:0;const s=+n;s>1048576?n=(s/1048576).toFixed(2)+"M":s>1024?n=(s/1024).toFixed(2)+"K":n+="B",t(n)}},r.send()}))}async function H(e){try{const t=await fetch(e),n=await t.blob();return new File([n],`${l()}.${n.type.split("/")[1]}`,{type:n.type})}catch(e){return}}function E(e){return e&&[i.AUDIO,i.VIDEO].includes(e.chatMessageType)}function M(e){const n=r(new Date);return n.setSeconds(e),t(n,"HH:mm:ss")}export{u as $message,H as base64ToFile,w as downloadFile,M as formatSeconds,p as formatTime,f as getAVTime,y as getFileSize,E as isAudioOrVideoMessage,d as listSort,h as simplifyMessage,g as transformMessage};
|
1
|
+
import{isToday as e,format as t,isYesterday as n,startOfDay as r}from"date-fns";import{cloneDeep as s,isNumber as o,isNaN as a}from"lodash-es";import{MESSAGE_TYPE as i}from"../constants/index.js";import{emojis as c}from"./emoji.js";import{uuidGenerator as l}from"../../../../shared/utils/index.js";import{createDiscreteApi as m}from"naive-ui";const{message:u}=m(["message"]);function p(r){const s=new Date(r);let o,a;if(e(s))o=a=t(s,"HH:mm");else{o=n(s)?"昨天":t(s,"MM-dd");const e=s.getFullYear(),r=(new Date).getFullYear();a=t(s,e<r?"yyyy年M月d日 HH:mm":"M月d日 HH:mm")}return{siderMsgTime:o,msgTime:a,recordTime:function(r){const s=new Date(r),o=Date.now()-s.getTime();if(o<6e4)return"刚刚";if(o<36e5)return Math.ceil(o/1e3/60)+"分钟前";if(e(s))return"今天 "+t(s,"HH:mm");if(n(s))return"昨天 "+t(s,"HH:mm");{const e=s.getFullYear(),n=(new Date).getFullYear();return t(s,e<n?"yyyy年M月d日 HH:mm":"M月d日 HH:mm")}}(r)}}function d(e){return s(e||[]).sort(((e,t)=>e.topping&&!t.topping?-1:!e.topping&&t.topping?1:new Date(t.sortTime).getTime()-new Date(e.sortTime).getTime()))}function g(e){if(!(null==e?void 0:e.msg))return"";const{chatMessageType:t="",msg:n=""}=e;let r=n.toString();if(t===i.BLEND){const e=r.match(/\[([^\]]+)\]/g);return null==e||e.forEach((e=>{const n=e.match(/\[([^\]]+)\]/);if(n&&n.length>1){const s=c.findEmoji(n[1]);s&&(r=r.replace(e,`<img data-msg=${n[1]} data-type=${t} class="emoji--min" src=${s} />`))}})),r}const s=e=>new RegExp("\\n*\\["+(e||"")+"(code|pre|div|span|p|table|thead|th|tbody|tr|td|ul|li|ol|li|dl|dt|dd|h2|h3|h4|h5)([\\s\\S]*?)]\\n*","g");return r=r.replace(/&(?!#?[a-zA-Z0-9]+;)/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/'/g,"'").replace(/"/g,""").replace(/@(\S+)(\s+?|$)/g,'@<a href="javascript:;">$1</a>$2').replace(s(),"<$1 $2>").replace(s("/"),"</$1>").replace(/\n/g,"<br>"),r}function f(e){if(e&&o(+e)&&!a(+e)){const t=M(+e),n=t.split(":");let r=t;return 3===n.length&&"00"===n[0]&&(r=`${n[1]}:${n[2]}`),"通话时长 "+r}return"已取消"}function h(e){var t;if(!e)return"";const{chatMessageType:n,msg:r,messageTemplate:s}=e,o=E(e)?f(r):"";switch(n){case i.TEXT:return g(e);case i.IMAGE:return"[图片]";case i.FILE:return"[文件]";case i.EMOJI:return`<img class="emoji--min" alt=${r} src=${c.findEmoji(r)}>`;case i.TEMPLATE:return null==(t=null==s?void 0:s.setting)?void 0:t.title;case i.VIDEO:return`[视频通话]${o}`;case i.AUDIO:return`[语音通话]${o}`;default:return"[消息]"}}function w(e,t){const n=new XMLHttpRequest;n.open("GET",e,!0),n.responseType="blob",n.onload=function(e){if(200===n.status){const e=window.URL.createObjectURL(n.response),r=document.createElement("a");r.href=e,r.download=t,r.dispatchEvent(new MouseEvent("click")),window.URL.revokeObjectURL(e)}},n.send()}function y(e){return new Promise(((t,n)=>{const r=new XMLHttpRequest;r.open("HEAD",e,!0),r.onreadystatechange=()=>{var e;if(4===r.readyState&&200===r.status){let n=null!=(e=r.getResponseHeader("Content-Length"))?e:0;const s=+n;s>1048576?n=(s/1048576).toFixed(2)+"M":s>1024?n=(s/1024).toFixed(2)+"K":n+="B",t(n)}},r.send()}))}async function H(e){try{const t=await fetch(e),n=await t.blob();return new File([n],`${l()}.${n.type.split("/")[1]}`,{type:n.type})}catch(e){return}}function E(e){return e&&[i.AUDIO,i.VIDEO].includes(e.chatMessageType)}function M(e){const n=r(new Date);return n.setSeconds(e),t(n,"HH:mm:ss")}export{u as $message,H as base64ToFile,w as downloadFile,M as formatSeconds,p as formatTime,f as getAVTime,y as getFileSize,E as isAudioOrVideoMessage,d as listSort,h as simplifyMessage,g as transformMessage};
|
@@ -1 +1 @@
|
|
1
|
-
var e="@cnhis-design-vue/shared",i="3.2.14-beta.
|
1
|
+
var e="@cnhis-design-vue/shared",i="3.2.14-beta.19",s="index.ts",n={"naive-ui":"^2.30.0",vue:"^3.2.0"},a={"@vicons/ionicons5":"^0.12.0","lodash-es":"^4.17.21",moment:"^2.29.1","video.js":"^7.19.2","videojs-contrib-hls":"^5.15.0",viewerjs:"^1.10.5","xe-utils":"^3.5.4"},d={name:e,version:"3.2.14-beta.19",private:!0,main:"index.ts",peerDependencies:n,dependencies:a};export{d as default,a as dependencies,s as main,e as name,n as peerDependencies,i as version};
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "cnhis-design-vue",
|
3
|
-
"version": "3.2.14-beta.
|
3
|
+
"version": "3.2.14-beta.19",
|
4
4
|
"license": "ISC",
|
5
5
|
"module": "./es/components/index.js",
|
6
6
|
"main": "./es/components/index.js",
|
@@ -72,5 +72,5 @@
|
|
72
72
|
"iOS 7",
|
73
73
|
"last 3 iOS versions"
|
74
74
|
],
|
75
|
-
"gitHead": "
|
75
|
+
"gitHead": "41c96e5a3143620b383f1f29d0df9374b2565111"
|
76
76
|
}
|
@@ -1,14 +0,0 @@
|
|
1
|
-
import { AnyObject } from '../../../../shared/types';
|
2
|
-
import { IState } from '../types';
|
3
|
-
export declare function useSession(state: IState): {
|
4
|
-
openSession: (item: AnyObject) => Promise<void>;
|
5
|
-
closeSession: () => AnyObject | null;
|
6
|
-
getCurrentSession: () => AnyObject | null;
|
7
|
-
setCurrentSessionItem: (item: AnyObject) => void;
|
8
|
-
setUpdateSessionItem: (item: AnyObject) => void;
|
9
|
-
setSessionList: (list: AnyObject[]) => void;
|
10
|
-
isGroupChat: import("vue").ComputedRef<boolean>;
|
11
|
-
updateSessionList: (sessionItem: AnyObject) => void;
|
12
|
-
isGroupLeader: import("vue").ComputedRef<boolean>;
|
13
|
-
isEnded: import("vue").ComputedRef<boolean>;
|
14
|
-
};
|
@@ -1 +0,0 @@
|
|
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{STATUS as r,CHAT_TYPE as o}from"../constants/index.js";import{groupUserApi as u}from"../api/index.js";function a(e){return e.chatType===o.GROUP}function c(e){const{lastMessage:n,lastSenderName:t=""}=e,i=s(n)||"";return a(e)&&t?t+": "+i:i}function d(s){const d=e((()=>a(s.currentSessionItem))),m=e((()=>{var e,n,t;return(null==(e=s.userInfo)?void 0:e.id)===(null==(t=null==(n=s.currentGroupUser)?void 0:n[0])?void 0:t.id)})),l=e((()=>{var e;return(null==(e=s.currentSessionItem)?void 0:e.status)===r.ENDED}));function f(e){Object.assign(s.currentSessionItem,e,{lastMessageContent:Reflect.has(e,"lastMessageContent")?e.lastMessageContent:Reflect.has(e,"lastMessage")?c({...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 p(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:c(e)}),e.receiver===s.userInfo.id&&(e.unreadNum=0),e.chatType!==o.GROUP||e.name||u({id:e.receiver}).then((s=>{t(s)&&(e.name=s.map((e=>e.name)).join(","))}))}))}return{openSession:async function(e){const r=s.currentSessionItem.sessionKey;if(f(e),r!==s.currentSessionItem.sessionKey)if(d.value){const n=await u({id:e.receiver});s.currentGroupUser=t(n)?n:[]}else s.currentGroupUser=i([s.userInfo,{...n(e),id:e.receiver}],"id")},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:f,setUpdateSessionItem:function(e){const t=s.sessionList.find((s=>s.sessionKey===e.sessionKey)),i={...e,lastMessageContent:c({...e,chatType:e.chatType||(null==t?void 0:t.chatType)})};s.updateSessionItem=t?{...n(t),...i}:i,s.isUpdateSession=!0},setSessionList:p,isGroupChat:d,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}})):p([...s.sessionList,e])},isGroupLeader:m,isEnded:l}}export{d as useSession};
|
@@ -1,18 +0,0 @@
|
|
1
|
-
import { AnyObject } from '../../../../shared/types';
|
2
|
-
export declare function useState(): {
|
3
|
-
state: import("../types").IState;
|
4
|
-
unreadTotal: import("vue").ComputedRef<number>;
|
5
|
-
setMsgList: (list?: AnyObject[]) => void;
|
6
|
-
stompClient: import("vue").Ref<import("../utils/chatSock").ChatSock>;
|
7
|
-
emit: (event: string, ...args: any[]) => void;
|
8
|
-
sendMessage: (message: {
|
9
|
-
chatType?: string;
|
10
|
-
content: AnyObject;
|
11
|
-
receiver?: string;
|
12
|
-
}) => Promise<void>;
|
13
|
-
relayMessage: (param: {
|
14
|
-
checkedIds: string[];
|
15
|
-
remark: string;
|
16
|
-
content: AnyObject;
|
17
|
-
}) => Promise<void>;
|
18
|
-
};
|
@@ -1 +0,0 @@
|
|
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};
|