cnhis-design-vue 3.2.8-beta.16 → 3.2.8-beta.18
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/ChatMain.js +1 -1
- package/es/components/fabric-chart/src/hooks/temperature/useCenter.js +1 -1
- package/es/components/fabric-chart/src/hooks/temperature/useOther.js +1 -1
- package/es/components/fabric-chart/src/hooks/temperature/useTemperatureChart.js +1 -1
- package/es/components/fabric-chart/src/hooks/useCumputedPoint.d.ts +1 -1
- package/es/components/fabric-chart/src/hooks/useCumputedPoint.js +1 -1
- package/es/components/iho-chat/index.d.ts +3 -1
- package/es/components/iho-chat/src/Index.vue.d.ts +3 -1
- package/es/components/iho-chat/src/components/ChatFooter.vue.d.ts +1 -1
- package/es/components/iho-chat/src/components/ChatFooter.vue2.js +1 -1
- package/es/components/iho-chat/src/components/ChatMain.vue.d.ts +2 -0
- package/es/components/iho-chat/src/components/ChatMain.vue2.js +1 -1
- package/es/components/iho-chat/src/components/ContextMenu.js +1 -1
- package/es/components/iho-chat/src/utils/index.js +1 -1
- package/es/components/iho-chat/style/index.css +1 -1
- package/es/components/index.css +1 -1
- package/es/components/table-filter/src/components/render-widget/components/Select.vue.d.ts +3 -0
- package/es/components/table-filter/src/components/render-widget/components/Select.vue2.js +1 -1
- package/es/components/table-filter/src/components/render-widget/components/index.d.ts +3 -0
- package/es/components/table-filter/src/components/render-widget/widgetCfgMaps.d.ts +3 -0
- package/es/shared/package.json.js +1 -1
- package/package.json +2 -2
@@ -1 +1 @@
|
|
1
|
-
import{defineComponent as e,inject as t,ref as n,watch as l,createVNode as s,createTextVNode as a,mergeProps as o,isVNode as r}from"vue";import{NAvatar as i,NSpin as u,NButton as c,NSpace as d}from"naive-ui";import{InjectionAIChat as p}from"../types/index.js";import m from"../../../../shared/assets/img/ai__avatar.png.js";import{isArray as v,isFunction as f}from"lodash";import"../../../../shared/utils/index.js";import"@vueuse/core";import"date-fns";import"lodash-es";import"@vue/shared";import"@vueuse/shared";import"../../../../shared/hooks/selectHooks/useSearchContent.js";import"@vicons/ionicons5";import{useScrollLoading as g}from"../../../../shared/hooks/useScrollLoading.js";function h(e){return"function"==typeof e||"[object Object]"===Object.prototype.toString.call(e)&&!r(e)}var b=e({name:"ChatMain",inheritAttrs:!1,props:{},emits:[],setup(e,{attrs:r,slots:b,emit:y}){const{userAvatar:k,queryData:C,state:S,queryRecord:j,defaultShortcutList:x,hideInput:z=!1}=t(p),w=n(null),M=n([]),A=n(!1),_={page:0,hasMore:!0};let q=!1;async function E(e=!1){if(!_.hasMore)return;_.page++,1==_.page&&(M.value=[]);const{records:t,rows:n}=await j.value({page:_.page});v(n)&&M.value.length<=+t&&(M.value=_.page>1?[...M.value,...n]:n,M.value.length>=+t&&(e&&(A.value=!0),_.hasMore=!1,console.log("没有更多消息了")))}function H({content:e="",button:t={}}){const n=e.replace(/\\n|\n|\r/g,"<br>").split("<br>").map(((e,t,n)=>[e,t===n.length-1?null:s("br",null,null)])),l=t.content?[s("br",null,null),s(c,o({secondary:!0,class:"gradient",disabled:t.disabled},t.link?{tag:"a",href:t.link,target:"_blank"}:{},{onClick:()=>function(e){e.link||(q=!0,S.beingSent=!0,S.sendContent=e.content,e.disabled=!0)}(t)}),{default:()=>[t.content]})]:null;return[n,l]}function I({role:e=""}){return"user"===e}function L(){let e;return s("div",{class:"message-item"},[s(i,{round:!0,size:40,src:m},null),s("div",{class:"content fillet-10 default"},[s("h2",null,[a("Hi,我是你的AI助理")]),s("p",null,[a("
|
1
|
+
import{defineComponent as e,inject as t,ref as n,watch as l,createVNode as s,createTextVNode as a,mergeProps as o,isVNode as r}from"vue";import{NAvatar as i,NSpin as u,NButton as c,NSpace as d}from"naive-ui";import{InjectionAIChat as p}from"../types/index.js";import m from"../../../../shared/assets/img/ai__avatar.png.js";import{isArray as v,isFunction as f}from"lodash";import"../../../../shared/utils/index.js";import"@vueuse/core";import"date-fns";import"lodash-es";import"@vue/shared";import"@vueuse/shared";import"../../../../shared/hooks/selectHooks/useSearchContent.js";import"@vicons/ionicons5";import{useScrollLoading as g}from"../../../../shared/hooks/useScrollLoading.js";function h(e){return"function"==typeof e||"[object Object]"===Object.prototype.toString.call(e)&&!r(e)}var b=e({name:"ChatMain",inheritAttrs:!1,props:{},emits:[],setup(e,{attrs:r,slots:b,emit:y}){const{userAvatar:k,queryData:C,state:S,queryRecord:j,defaultShortcutList:x,hideInput:z=!1}=t(p),w=n(null),M=n([]),A=n(!1),_={page:0,hasMore:!0};let q=!1;async function E(e=!1){if(!_.hasMore)return;_.page++,1==_.page&&(M.value=[]);const{records:t,rows:n}=await j.value({page:_.page});v(n)&&M.value.length<=+t&&(M.value=_.page>1?[...M.value,...n]:n,M.value.length>=+t&&(e&&(A.value=!0),_.hasMore=!1,console.log("没有更多消息了")))}function H({content:e="",button:t={}}){const n=e.replace(/\\n|\n|\r/g,"<br>").split("<br>").map(((e,t,n)=>[e,t===n.length-1?null:s("br",null,null)])),l=t.content?[s("br",null,null),s(c,o({secondary:!0,class:"gradient",disabled:t.disabled},t.link?{tag:"a",href:t.link,target:"_blank"}:{},{onClick:()=>function(e){e.link||(q=!0,S.beingSent=!0,S.sendContent=e.content,e.disabled=!0)}(t)}),{default:()=>[t.content]})]:null;return[n,l]}function I({role:e=""}){return"user"===e}function L(){let e;return s("div",{class:"message-item"},[s(i,{round:!0,size:40,src:m},null),s("div",{class:"content fillet-10 default"},[s("h2",null,[a("Hi,我是你的AI助理")]),s("p",null,[a("我汇集了医生站/护士站各项智能服务,可以向我进行提问哦 ~ "),s("br",null,null),a("你的反馈助我成长,期待我们一起探索未来!下次可以在首页和应用页找到我~")]),v(x.value)&&x.value.length>0?[s("p",{style:"margin: 5px 0 5px"},[a("你可以试着问我:")]),s(d,{"wrap-item":!1},h(e=x.value.map((e=>s(c,{size:"large",secondary:!0,onClick:()=>S.sendContent=e,disabled:S.beingSent},h(e)?e:{default:()=>[e]}))))?e:{default:()=>[e]})]:null])])}return g(w,(()=>{E()}),z.value?"bottom":"top"),E(!0),l((()=>S.beingSent),(async e=>{if(e){q||M.value.unshift({role:"user",content:S.sendContent}),q=!1;const e=await C.value({content:S.sendContent,contentType:"text"});v(e)&&M.value.unshift(...e),S.beingSent=!1,S.sendContent=""}})),()=>s("section",{class:"chat-main",ref:w,style:{"flex-direction":z.value?"column":"column-reverse"}},[[S.beingSent?s("div",{class:"message-item"},[s(i,{round:!0,size:40,src:m},null),s("div",{class:"content fillet-10 loading"},[s(u,{size:22,stroke:"#4170EE"},null),s("span",null,[a("正在加载中,请稍等...")])])]):null,M.value.map((e=>s("div",{class:"message-item"},[s(i,{round:!0,size:40,src:I(e)?k.value:m},null),s("div",{class:["content",I(e)?"fillet-8 mine":"fillet-10"]},[f(e.render)?e.render():H(e)])]))),A.value?L():null]])}});export{b as default};
|
@@ -1 +1 @@
|
|
1
|
-
import{fabric as e}from"../../../../../shared/utils/fabricjs/index.js";import{useShadow as t}from"./useShadow.js";import{drawLine as i,defaultStyle as n,drawPoint as o,drawText as l,drawArrow as s}from"../useDraw.js";import{useGrid as r}from"../useGrid.js";import{format as u}from"date-fns";import{getType as a,getTime as c,isOneLine as d,isOverlapPoint as p,getFloorNumber as f,isValidValue as h,setOtherType as v,isEffectiveNode as g,deleteProperty as y,getIndex as m}from"../../utils/index.js";import{cloneDeep as x,flatten as b,last as j}from"lodash-es";import"../useEvent.js";import{useCommon as w}from"../useCommon.js";import"vue";import"naive-ui";import"@vueuse/core";import{TEMPERATURE_MENU as k,PAIN_MENU as L,OVERLAP as S}from"../../constants/index.js";import{promiseTimeout as Y}from"@vueuse/shared";function E(E,$,O,T,V,C,P,R,A,I){r(E,$);const{getEqualXTypes:X,handleAddPrevent:D,getPointEventProps:H}=w(E,O,$),{createShadowLines:W}=t(),{left:z,xScaleList:F,xCellWidth:_,yCellHeight:q,originX:G,endX:N,originY:B,endY:J,itemList:K,event:Q,vitalSignsOriginY:U,painOriginY:Z,hospitalizationDate:ee,config:te,canvasHeight:ie,painSurplusCell:ne,iconsWidth:oe,canvasWidth:le,borderStyle:se}=$,re=new Set,ue=["xinmai","mai"],ae=new Map,ce=new Set,de=new Set,pe=new Set,fe=x(z.yScaleValue),he=new Set;function ve(t){var o;const l=fe.find((e=>"pulse"===e.type));if(l&&(null==(o=l.dataList)?void 0:o.length)&&(re.size&&E.value.remove(...re),re.clear(),ae.size>1)){if(t){const{type:e,key:i}=t.origin||{};if("pulse"===e){const e=ae.get(i),n=null==e?void 0:e.findIndex((e=>e[0]===t.left));e.splice(n,1,[t.left,t.top])}}const o=function(){const e=[],t=[],i=[];for(const e of ae)t.push(e[1]),e[0]===ue[0]&&e[1].forEach((e=>{(ae.get(ue[1])||[]).findIndex((t=>t[0]===e[0]))>-1&&i.push(e[0])}));const[n,o]=t;let l=[],s=[];return i.forEach((t=>{const i=n.findIndex((e=>e[0]===t)),r=o.findIndex((e=>e[0]===t)),u=n[i],a=o[r],c=n[i-1],d=n[i+1],p=o[r-1],f=o[r+1];if(c&&p){if(c[0]!==p[0]){const e=Math.max(c[0],p[0]);l.push([c,p].find((t=>t[0]===e)))}}else c?l.push(c):p&&s.push(p);const h=Math.min(u[1],a[1]);l.push([u,a].find((e=>e[1]===h)));const v=Math.max(u[1],a[1]);s.push([u,a].find((e=>e[1]===v)));const g=()=>{const t=[...l,...s.reverse()],[i]=t,n=j(t);i[0]===n[0]&&i[1]===n[1]&&t.splice(-1,1),e.push(t),l=[],s=[]};if(d&&f){if(d[0]!==f[0]){const e=Math.min(d[0],f[0]);l.push([d,f].find((t=>t[0]===e))),g()}}else d?(l.push(d),g()):f?(s.push(f),g()):g()})),e}();o.length>0&&function(e){Y(0).then((()=>{e.forEach((e=>{const t=[],i=[];Array.from(pe).forEach((n=>{var o,l;"pulse"===(null==(o=null==n?void 0:n.origin)?void 0:o.type)&&e.find((e=>Math.abs(n.left-e[0])<=1&&Math.abs(n.top-e[1])<=1))&&((null==(l=null==n?void 0:n.origin)?void 0:l.key)===ue[0]?t.push(n):i.push(n))})),[t,i].forEach((e=>{1!==(null==e?void 0:e.length)&&e.sort(((e,t)=>e.left-t.left)).forEach(((e,t)=>{t>0&&e.leftLine&&E.value.remove(e.leftLine)}))}))}))}))}(o);const{mode:s,style:r={}}=l.shadow||{};o.forEach((t=>{const o=t.map((e=>({x:e[0],y:e[1]}))),l=new e.Polygon(o,{...n,...r,strokeWidth:1});if(["slash","line"].includes(s)){l.set({fill:"transparent",stroke:r.stroke||"#f00"});const e=[];if(["slash"].includes(s))e.push(...W(t,r._angle,r.space)),e.forEach((e=>{Object.assign(e,{...n,...r}),re.add(e)}));else{const n=function(e){const t=e.reduce(((e,t)=>{const i=Math.trunc(t[0]);return e[i]=e[i]?e[i].concat([t]):[t],e}),{}),i=Object.values(t).filter((e=>2===e.length&&Math.trunc(e[0][1])!==Math.trunc(e[1][1])));return i}(t);n.forEach((t=>{const n=i([...b(t)],{...r,originX:"center"});e.push(n),re.add(n)}))}E.value.add(...e)}re.add(l),E.value.add(l)}))}}function ge(e,t,r){var u;const{type:a,riseStyle:c={},noRiseStyle:p={},verifiedStyle:g={},reduceStyle:y={},pacemaker:m={},upArrowStyle:x={},limitValueStyle:b={},nonePainPointStyle:j={},belowMinValueStyle:w={},respiratorStyle:k={},dataList:L=[],list:S=[]}=r,{type:Y,textStyle:$,showConnectLine:C=!1}=j,R=[],I=[],X=[];let D=null;const W=e=>"breathe"==a&&e.respirator&&k.type&&k.fixedValue&&!e.value&&xe(e.time);if(null==(u=e.list)||u.forEach(((u,j)=>{const z=d(a)?L.find((e=>e.key===u.key)):e,F=be(W(u)?{...u,value:k.fixedValue}:u,r),G=e.list[j+1],N=G?be(W(G)?{...G,value:k.fixedValue}:G,r):void 0,B=G?d(a)?L.find((e=>e.key===G.key)):e:{},{title:J=""}=z;if("脉搏"===J&&"脉搏"!==B.title||"脉搏"!==J&&"脉搏"===B.title||!F||!N||f(F[0],1)!==f(N[0],1))F&&D&&(F[0]=D),D=null;else{const e=F[0]-_/2;F[0]=e+_/4,N[0]=D=F[0]+_/2}const K={};K.value=function(e,t,i){if(!(null==e?void 0:e.length)||!te.showValue)return;const{lineAttr:n={}}=i,o=e[1]<=U.originY+q?e[1]+q:e[1]-q,s=l([e[0],o],{value:W(t)?k.fixedValue:t.value,originX:"center",originY:"center",fill:n.stroke||"#000"});return X.push(s),{obj:s,top:-q}}(F,u,z),function(e,t,r,u){var d,f;if(!["temperature","pain","breathe"].includes(a))return;if(!(null==e?void 0:e.length)&&"temperature"===a&&!xe(t.time))return;if(!(null==e?void 0:e.length)&&"pain"===a)return;if(!t.value&&"breathe"===a)return;const{lineAttr:v={}}=r,{value:m}=u,x=T(t.time);let b,j,w,L,Y,E;if(t.noRise&&p.show){const i=M(p,t)?V(a,S,35):(null==e?void 0:e[1])||0;if(p.text)w=l([x,M(p,t)?i:i+5],{value:p.text.split("").join("\n"),originY:"top",...p.style}),t.value||pe.add(w);else if(t.value){w=s([x,i,i+2*q],{...p.style})}w&&X.push(w),w&&M(p,t)&&he.add(w)}if(null==e?void 0:e[1]){if(t.rise&&c.show&&c.text&&(L=l([x,e[1]-(m?q:0)-5],{value:c.text.split("").join("\n"),originY:"bottom",...c.style}),X.push(L)),t.verified&&(Y=l([x,e[1]-(m?q:0)-5],{value:"v",originX:"center",originY:"bottom",...g}),X.push(Y)),h(t.physicsReduce)||h(t.drugReduce)){const l=V(a,S,null!=(d=t.physicsReduce)?d:t.drugReduce),s=l<e[1]&&(null==te?void 0:te.hypothermyViewCustom)?x+_/2:x;b=i([...e,s,l],{...v,...y.line,...n}),j=o((null==(f=null==y?void 0:y.point)?void 0:f.type)||"circle",{left:s,top:l,...y.point,...n,originY:l===ie?"bottom":"center"}),b&&X.push(b),j&&X.push(j)}t.respirator&&(E=o(k.type,{left:x,top:e[1]-(m?q:0)-5,originX:"center",originY:"bottom",...k.style}),X.push(E))}Object.assign(u,{reduceLine:{obj:b,type:"line"},noRiseText:{obj:w,top:p.text?5:2*q,isFixed:M(p,t)},riseText:{obj:L,top:(m?-q:0)-5},verifiedText:{obj:Y,top:(m?-q:0)-5},reducePoint:{obj:j,type:"reduce"},respirator:{obj:E,top:(m?-q:0)-5}})}(F,u,z,K),function(e,t,i,n){if(!(null==e?void 0:e.length)||!["pulse"].includes(a))return;const o=Math.max(...S),r=Math.min(...S);let u,c,d;const{upArrowShow:p=!1,limitValueShow:f=!1}=i;if(p&&+t.value>180){let t=e[1]-2.5*q,i=[e[1]-q/2,t];t<U.originY&&(t=e[1]+2.5*q,i=[t,e[1]+q/2]),u=s([e[0],i[0],i[1]],x,"up"),X.push(u)}if(f){const i={value:t.value,originX:"center",originY:"center",...b};if(+t.value>o){const t=u?e[1]+q/2+u.height:e[1]+q;c=l([e[0],t],i),X.push(c)}+t.value<r&&(c=l([e[0],e[1]-q],i),X.push(c))}if(w.show&&+t.value<r){const t=e[1];if(w.text)d=l([e[0],e[1]+5],{value:w.text.split("").join("\n"),originY:"top",...w.style});else{const i=t+2*q;d=s([e[0],t,i],{...w.style})}X.push(d)}Object.assign(n,{upArrow:{obj:u},limitValue:{obj:c,top:-q},belowMinValue:{obj:d,top:w.text?5:2*q,moveHide:!0}})}(F,u,z,K),function(n,l,s,u,c,d){let p,f;const{pointAttr:h={},lineAttr:g={},title:y="",key:x,type:b="circle"}=c,j=e.list[u+1],w=ye(a,e.list[u].value),L=l&&ye(a,j.value),S=()=>"pulse"==a&&s.pacemakerShow?m.value:W(s)?k.type:w&&"number"===Y?0:b;if(n&&l&&!s.breakpoint&&(!w&&!L||C)){f=i([...n,...l],{...g});const{obj:e}=(null==d?void 0:d.reducePoint)||{};if((null==e?void 0:e.top)<n[1]&&(null==te?void 0:te.hypothermyViewCustom)){const t=i([e.left,e.top,...l],{...g});X.unshift(t),Object.assign(d,{reduceRightLine:{obj:t,type:"reduce"}}),f.set("stroke","transparent")}}const M=S(),T=I[u-1],V={origin:{data:W(s)?{...s,value:k.fixedValue}:s,title:y,key:x||"",unit:r.unit,type:a,_type:v(y,a),dataIndex:t,index:u},leftLine:T,rightLine:f,otherObj:d,...s.pacemakerShow&&"pulse"==a?m.style:W(s)?k.style:h,lockMovementX:!0,...H(),...w?{selectable:!1,evented:!1,..."number"===Y?$:{}}:{}};n&&(T?V.leftLine.set("x2",n[0]):V.leftLine=null,p=o(M,{left:n[0],top:w&&!ne[1]?n[1]-5:n[1],...V}));I.push(f),p&&(x===ue[1]?ce.add(p):W(s)||de.add(p),function(e){Q.hovered&&(e.on("mouseover",(()=>{me(e,"hover")})),e.on("mouseout",(()=>{A.show=!1})));if(e.lockMovementX&&e.lockMovementY)return;e.on("moving",(()=>{!function(e){e.setCoords();const t="pain"===e.origin.type?Z:U;e.top<t.originY&&e.set("top",t.originY);e.top>t.endY&&e.set("top",t.endY)}(e),function(e){var t,i;null==(t=e.leftLine)||t.setCoords().set({x2:e.left,y2:e.top}),null==(i=e.rightLine)||i.setCoords().set({x1:e.left,y1:e.top}),Object.values(e.otherObj).forEach((t=>{const{obj:i,type:n="",top:o=0,isFixed:l,moveHide:s=!1}=t||{};"reduce"!==n&&i&&("line"===n?i.setCoords().set({x1:e.left,y1:e.top}):(l||i.setCoords().set({left:e.left,top:e.top+o}),s&&(E.value.remove(i),delete e.otherObj.obj)))})),ve(e)}(e),Q.hovered&&me(e)})),e.on("mouseup",(t=>{if(A.show=!1,1===t.button){const{type:t}=e.origin,i=P(t,e.top),n={...e.origin,data:{...e.origin.data,value:i}};E.value.discardActiveObject(),O("change",n),we(n,"change")}}))}(p),R.push(p),pe.add(p))}(F,N,u,j,z,K)})),"pulse"===a){const{key:t}=e;let i=null;ae.set(t,R.map(((e,t,n)=>{var o,l;const s=n[t+1];if(s&&f(e.left,1)===f(s.left,1)){const t=e.left-_/2;e.set("left",t+_/4),null==(o=e.rightLine)||o.set("x1",e.left),i=e.left+_/2,s.set("left",i)}else i&&(null==(l=e.leftLine)||l.set("x2",i),e.set("left",i)),i=null;return[e.left,e.top]})))}const z=I.filter((e=>e));E.value.add(...z,...R,...X)}function ye(e,t){return"pain"===e&&0==t}function me(e,t="moving"){const{title:i,unit:n,type:o,data:l}=e.origin;A.point={x:e.left,y:e.top};let s=`时间 ${((null==l?void 0:l.time)||C(e.left)).slice(-5)}`;A.list=[function(){const{drugReduce:r,physicsReduce:u}=l||{},a="hover"===t?l.value:P(o,e.top);if(h(r))return s+=(null==l?void 0:l.changeTime)?"—>"+(null==l?void 0:l.changeTime.slice(-5)):"",`药物降${"pain"==o?"痛":"温"} ${a}—>${r}${n||""}`;if(h(u))return s+=(null==l?void 0:l.changeTime)?"—>"+(null==l?void 0:l.changeTime.slice(-5)):"",`物理降${"pain"==o?"痛":"温"} ${a}—>${u}${n||""}`;return`${i} ${a}${n||""}`}(),s],A.show=!0}function xe(e){const[t]=F,i=j(F),n=t.start,o=i.end,l=c(e);return l>=n&&l<=o}function be(e,t){const i="pain"===t.type?Z:U;if(!g(e)||!xe(e.time))return;const n=T(e.time),o=V(t.type,t.list,e.value);return[n,o<i.originY?i.originY:o>i.endY?i.endY:o]}function je(e){const t=new Date,i=String(t.getMonth()+1).padStart(2,"0"),n=String(t.getDate()).padStart(2,"0"),o=c(`${t.getFullYear()}-${i}-${n} 23:59:59`),l=c(`${C(e)}:00`);return ee&&l<c(ee)?(D("exceedMin"),!1):!(l>o)||(D("exceedMax"),!1)}function we(e,t="add"){const{type:i,dataIndex:n,index:o,data:l,key:s}=e,r=fe.find((e=>e.type===i));if("add"===t){const e=d(i)?r.dataList.find((e=>e.enable)):r.dataList[n],t=m(l.time,e.list);e.list.splice(t,0,l)}else r.dataList[n].list[o]=l;ke()}function ke(){var e;pe.size&&(null==(e=E.value)||e.remove(...function(e){const t=[];return e.forEach((e=>{e&&t.push(e),(null==e?void 0:e.leftLine)&&t.push(null==e?void 0:e.leftLine),(null==e?void 0:e.rightLine)&&t.push(null==e?void 0:e.rightLine),Object.values((null==e?void 0:e.otherObj)||{}).forEach((e=>{(null==e?void 0:e.obj)&&t.push(null==e?void 0:e.obj)}))})),t}([...pe]))),pe.clear(),Le()}function Le(e){ae.clear(),pe.clear(),ce.clear(),he.clear(),de.clear(),fe.forEach((t=>{null==e||e(t),t.dataList.forEach(((e,i)=>{!e.show||d(t.type)&&!e.enable||ge(e,i,t)}))})),ve(),[...pe].forEach((e=>{null==e||e.bringToFront()})),function(){var e;const t=fe.find((e=>"pulse"===e.type));if(!t||!(null==(e=t.dataList)?void 0:e.length))return;if(!t.dataList.some((e=>e.title.includes("脉搏"))))return;const i=Object.assign({},S,z.overlap||{}),l=[];ce.size&&[...ce].forEach((e=>{[...de].forEach((t=>{if(t.origin&&p(e,t)){const e=t.origin.key;if(e){const s={left:t.left,top:t.top,...n,hoverCursor:"default"};let r="koumai";"yemai"===e&&(r=e),l.push(o(r,{...i[e],...s}))}}}))})),setTimeout((()=>{E.value.add(...l),l.forEach((e=>{null==e||e.bringToFront(),pe.add(e)}))}))}()}return function(){const t=new e.Rect({left:oe,top:0,width:le-oe-se.strokeWidth,height:ie-se.strokeWidth,fill:"transparent",...se});E.value.add(t)}(),Le((e=>function(e){if("temperature"!==e.type||!e.positionLine)return;const t=V(e.type,e.list,e.positionLine.value),n=i([G,t,N,t],e.positionLine);E.value.add(n)}(e))),E.value.on("mouse:up",(e=>{const{button:t,target:i,pointer:n={}}=e;if(3===t){if(!$.event.evented)return;const{x:e=0,y:t=0}=n;if(e>=G&&e<=N&&t>=B&&t<=J){I.point={x:e,y:t},I.show=!0;const{type:o}=(null==i?void 0:i.origin)||{};if(i&&["temperature","pain"].includes(o))"temperature"===o&&(I.list=[...k]),"pain"===o&&(I.list=[...L]),I.target=i;else{I.target=null,I.list=["新增节点"],K.forEach((i=>{if(!X([...pe],e,"_type").includes(i.bigType)){const e=["pain"].includes(i.bigType)?Z:U;t>=e.originY&&t<=e.endY&&I.list.push({renderItem:R?R(i):()=>i.title,origin:{title:i.title,unit:i.unit,type:a(i.bigType),dataIndex:i.dataIndex,key:i.key},pointer:n})}}));const i=je(e);i&&1!==I.list.length||(I.show=!1,1===I.list.length&&i&&D("repeat"))}}}if(1===t){if(i)return;const{x:e=0,y:t=0}=n;e>=G&&e<=N&&t>0&&t<ie&&O("click:grid",{x:e,y:t,time:C(e)})}})),{clickMenu:function({item:e,target:t}){if(t){const{data:i,type:n,dataIndex:o,index:l}=t.origin,s=y(i,[...k,...L]);s[`${e.type}`]=e.value,s.changeTime=u(new Date,"yyyy-MM-dd HH:mm"),d(n)&&(s.key=t.origin.key);const r={...t.origin,data:s};O("change",r),we(r,"change")}else{const t={data:{time:C(e.pointer.x),value:P(e.origin.type,e.pointer.y),...d(e.origin.type)?{key:e.origin.key}:{}},...e.origin};O("add",t),we(t)}},setPopup:me,isAddPoint:je,updateData:we,redrawPoints:ke,gridPoints:pe,fixedNoRisePoints:he}}function M(e,t){return e.fixed||!t.value&&0!==t.value}export{E as useCenter};
|
1
|
+
import{fabric as e}from"../../../../../shared/utils/fabricjs/index.js";import{useShadow as t}from"./useShadow.js";import{drawLine as i,defaultStyle as n,drawPoint as o,drawText as l,drawArrow as s}from"../useDraw.js";import{useGrid as r}from"../useGrid.js";import{format as u}from"date-fns";import{getType as a,getTime as c,isOneLine as d,isOverlapPoint as p,getFloorNumber as f,isValidValue as h,setOtherType as v,isEffectiveNode as g,deleteProperty as y,getIndex as m}from"../../utils/index.js";import{cloneDeep as x,flatten as b,last as j}from"lodash-es";import"../useEvent.js";import{useCommon as w}from"../useCommon.js";import"vue";import"naive-ui";import"@vueuse/core";import{TEMPERATURE_MENU as k,PAIN_MENU as L,OVERLAP as S}from"../../constants/index.js";import{promiseTimeout as Y}from"@vueuse/shared";function E(E,$,O,T,V,C,P,R,A,I){r(E,$);const{getEqualXTypes:X,handleAddPrevent:D,getPointEventProps:H}=w(E,O,$),{createShadowLines:W}=t(),{left:z,xScaleList:F,xCellWidth:_,yCellHeight:q,originX:G,endX:N,originY:B,endY:J,itemList:K,event:Q,vitalSignsOriginY:U,painOriginY:Z,hospitalizationDate:ee,config:te,canvasHeight:ie,painSurplusCell:ne,iconsWidth:oe,canvasWidth:le,borderStyle:se}=$,re=new Set,ue=["xinmai","mai"],ae=new Map,ce=new Set,de=new Set,pe=new Set,fe=x(z.yScaleValue),he=new Set;function ve(t){var o;const l=fe.find((e=>"pulse"===e.type));if(l&&(null==(o=l.dataList)?void 0:o.length)&&(re.size&&E.value.remove(...re),re.clear(),ae.size>1)){if(t){const{type:e,key:i}=t.origin||{};if("pulse"===e){const e=ae.get(i),n=null==e?void 0:e.findIndex((e=>e[0]===t.left));e.splice(n,1,[t.left,t.top])}}const o=function(){const e=[],t=[],i=[];for(const e of ae)t.push(e[1]),e[0]===ue[0]&&e[1].forEach((e=>{(ae.get(ue[1])||[]).findIndex((t=>t[0]===e[0]))>-1&&i.push(e[0])}));const[n,o]=t;let l=[],s=[];return i.forEach((t=>{const i=n.findIndex((e=>e[0]===t)),r=o.findIndex((e=>e[0]===t)),u=n[i],a=o[r],c=n[i-1],d=n[i+1],p=o[r-1],f=o[r+1];if(c&&p){if(c[0]!==p[0]){const e=Math.max(c[0],p[0]);l.push([c,p].find((t=>t[0]===e)))}}else c?l.push(c):p&&s.push(p);const h=Math.min(u[1],a[1]);l.push([u,a].find((e=>e[1]===h)));const v=Math.max(u[1],a[1]);s.push([u,a].find((e=>e[1]===v)));const g=()=>{const t=[...l,...s.reverse()],[i]=t,n=j(t);i[0]===n[0]&&i[1]===n[1]&&t.splice(-1,1),e.push(t),l=[],s=[]};if(d&&f){if(d[0]!==f[0]){const e=Math.min(d[0],f[0]);l.push([d,f].find((t=>t[0]===e))),g()}}else d?(l.push(d),g()):f?(s.push(f),g()):g()})),e}();o.length>0&&function(e){Y(0).then((()=>{e.forEach((e=>{const t=[],i=[];Array.from(pe).forEach((n=>{var o,l;"pulse"===(null==(o=null==n?void 0:n.origin)?void 0:o.type)&&e.find((e=>Math.abs(n.left-e[0])<=1&&Math.abs(n.top-e[1])<=1))&&((null==(l=null==n?void 0:n.origin)?void 0:l.key)===ue[0]?t.push(n):i.push(n))})),[t,i].forEach((e=>{1!==(null==e?void 0:e.length)&&e.sort(((e,t)=>e.left-t.left)).forEach(((e,t)=>{t>0&&e.leftLine&&E.value.remove(e.leftLine)}))}))}))}))}(o);const{mode:s,style:r={}}=l.shadow||{};o.forEach((t=>{const o=t.map((e=>({x:e[0],y:e[1]}))),l=new e.Polygon(o,{...n,...r,strokeWidth:1});if(["slash","line"].includes(s)){l.set({fill:"transparent",stroke:r.stroke||"#f00"});const e=[];if(["slash"].includes(s))e.push(...W(t,r._angle,r.space)),e.forEach((e=>{Object.assign(e,{...n,...r}),re.add(e)}));else{const n=function(e){const t=e.reduce(((e,t)=>{const i=Math.trunc(t[0]);return e[i]=e[i]?e[i].concat([t]):[t],e}),{}),i=Object.values(t).filter((e=>2===e.length&&Math.trunc(e[0][1])!==Math.trunc(e[1][1])));return i}(t);n.forEach((t=>{const n=i([...b(t)],{...r,originX:"center"});e.push(n),re.add(n)}))}E.value.add(...e)}re.add(l),E.value.add(l)}))}}function ge(e,t,r){var u;const{type:a,riseStyle:c={},noRiseStyle:p={},verifiedStyle:g={},reduceStyle:y={},pacemaker:m={},upArrowStyle:x={},limitValueStyle:b={},nonePainPointStyle:j={},belowMinValueStyle:w={},respiratorStyle:k={},dataList:L=[],list:S=[]}=r,{type:Y,textStyle:$,showConnectLine:C=!1}=j,R=[],I=[],X=[];let D=null;const W=e=>"breathe"==a&&e.respirator&&k.type&&k.fixedValue&&!e.value&&xe(e.time);if(null==(u=e.list)||u.forEach(((u,j)=>{const z=d(a)?L.find((e=>e.key===u.key)):e,F=be(W(u)?{...u,value:k.fixedValue}:u,r),G=e.list[j+1],N=G?be(W(G)?{...G,value:k.fixedValue}:G,r):void 0,B=G?d(a)?L.find((e=>e.key===G.key)):e:{},{title:J=""}=z;if("脉搏"===J&&"脉搏"!==B.title||"脉搏"!==J&&"脉搏"===B.title||!F||!N||f(F[0],1)!==f(N[0],1))F&&D&&(F[0]=D),D=null;else{const e=F[0]-_/2;F[0]=e+_/4,N[0]=D=F[0]+_/2}const K={};K.value=function(e,t,i){if(!(null==e?void 0:e.length)||!te.showValue)return;const{lineAttr:n={}}=i,o=e[1]<=U.originY+q?e[1]+q:e[1]-q,s=l([e[0],o],{value:W(t)?k.fixedValue:t.value,originX:"center",originY:"center",fill:n.stroke||"#000"});return X.push(s),{obj:s,top:-q}}(F,u,z),function(e,t,r,u){var d,f;if(!["temperature","pain","breathe"].includes(a))return;if(!(null==e?void 0:e.length)&&"temperature"===a&&!xe(t.time))return;if(!(null==e?void 0:e.length)&&"pain"===a)return;if(!t.value&&"breathe"===a)return;const{lineAttr:v={}}=r,{value:m}=u,x=T(t.time);let b,j,w,L,S,Y;if(t.noRise&&p.show){const i=M(p,t)?V(a,35):(null==e?void 0:e[1])||0;if(p.text)w=l([x,M(p,t)?i:i+5],{value:p.text.split("").join("\n"),originY:"top",...p.style}),t.value||pe.add(w);else if(t.value){w=s([x,i,i+2*q],{...p.style})}w&&X.push(w),w&&M(p,t)&&he.add(w)}if(null==e?void 0:e[1]){if(t.rise&&c.show&&c.text&&(L=l([x,e[1]-(m?q:0)-5],{value:c.text.split("").join("\n"),originY:"bottom",...c.style}),X.push(L)),t.verified&&(S=l([x,e[1]-(m?q:0)-5],{value:"v",originX:"center",originY:"bottom",...g}),X.push(S)),h(t.physicsReduce)||h(t.drugReduce)){const l=V(a,null!=(d=t.physicsReduce)?d:t.drugReduce),s=l<e[1]&&(null==te?void 0:te.hypothermyViewCustom)?x+_/2:x;b=i([...e,s,l],{...v,...y.line,...n}),j=o((null==(f=null==y?void 0:y.point)?void 0:f.type)||"circle",{left:s,top:l,...y.point,...n,originY:l===ie?"bottom":"center"}),b&&X.push(b),j&&X.push(j)}t.respirator&&(Y=o(k.type,{left:x,top:e[1]-(m?q:0)-5,originX:"center",originY:"bottom",...k.style}),X.push(Y))}Object.assign(u,{reduceLine:{obj:b,type:"line"},noRiseText:{obj:w,top:p.text?5:2*q,isFixed:M(p,t)},riseText:{obj:L,top:(m?-q:0)-5},verifiedText:{obj:S,top:(m?-q:0)-5},reducePoint:{obj:j,type:"reduce"},respirator:{obj:Y,top:(m?-q:0)-5}})}(F,u,z,K),function(e,t,i,n){if(!(null==e?void 0:e.length)||!["pulse"].includes(a))return;const o=Math.max(...S),r=Math.min(...S);let u,c,d;const{upArrowShow:p=!1,limitValueShow:f=!1}=i;if(p&&+t.value>180){let t=e[1]-2.5*q,i=[e[1]-q/2,t];t<U.originY&&(t=e[1]+2.5*q,i=[t,e[1]+q/2]),u=s([e[0],i[0],i[1]],x,"up"),X.push(u)}if(f){const i={value:t.value,originX:"center",originY:"center",...b};if(+t.value>o){const t=u?e[1]+q/2+u.height:e[1]+q;c=l([e[0],t],i),X.push(c)}+t.value<r&&(c=l([e[0],e[1]-q],i),X.push(c))}if(w.show&&+t.value<r){const t=e[1];if(w.text)d=l([e[0],e[1]+5],{value:w.text.split("").join("\n"),originY:"top",...w.style});else{const i=t+2*q;d=s([e[0],t,i],{...w.style})}X.push(d)}Object.assign(n,{upArrow:{obj:u},limitValue:{obj:c,top:-q},belowMinValue:{obj:d,top:w.text?5:2*q,moveHide:!0}})}(F,u,z,K),function(n,l,s,u,c,d){let p,f;const{pointAttr:h={},lineAttr:g={},title:y="",key:x,type:b="circle"}=c,j=e.list[u+1],w=ye(a,e.list[u].value),L=l&&ye(a,j.value),S=()=>"pulse"==a&&s.pacemakerShow?m.value:W(s)?k.type:w&&"number"===Y?0:b;if(n&&l&&!s.breakpoint&&(!w&&!L||C)){f=i([...n,...l],{...g});const{obj:e}=(null==d?void 0:d.reducePoint)||{};if((null==e?void 0:e.top)<n[1]&&(null==te?void 0:te.hypothermyViewCustom)){const t=i([e.left,e.top,...l],{...g});X.unshift(t),Object.assign(d,{reduceRightLine:{obj:t,type:"reduce"}}),f.set("stroke","transparent")}}const M=S(),T=I[u-1],V={origin:{data:W(s)?{...s,value:k.fixedValue}:s,title:y,key:x||"",unit:r.unit,type:a,_type:v(y,a),dataIndex:t,index:u},leftLine:T,rightLine:f,otherObj:d,...s.pacemakerShow&&"pulse"==a?m.style:W(s)?k.style:h,lockMovementX:!0,...H(),...w?{selectable:!1,evented:!1,..."number"===Y?$:{}}:{}};n&&(T?V.leftLine.set("x2",n[0]):V.leftLine=null,p=o(M,{left:n[0],top:w&&!ne[1]?n[1]-5:n[1],...V}));I.push(f),p&&(x===ue[1]?ce.add(p):W(s)||de.add(p),function(e){Q.hovered&&(e.on("mouseover",(()=>{me(e,"hover")})),e.on("mouseout",(()=>{A.show=!1})));if(e.lockMovementX&&e.lockMovementY)return;e.on("moving",(()=>{!function(e){e.setCoords();const t="pain"===e.origin.type?Z:U;e.top<t.originY&&e.set("top",t.originY);e.top>t.endY&&e.set("top",t.endY)}(e),function(e){var t,i;null==(t=e.leftLine)||t.setCoords().set({x2:e.left,y2:e.top}),null==(i=e.rightLine)||i.setCoords().set({x1:e.left,y1:e.top}),Object.values(e.otherObj).forEach((t=>{const{obj:i,type:n="",top:o=0,isFixed:l,moveHide:s=!1}=t||{};"reduce"!==n&&i&&("line"===n?i.setCoords().set({x1:e.left,y1:e.top}):(l||i.setCoords().set({left:e.left,top:e.top+o}),s&&(E.value.remove(i),delete e.otherObj.obj)))})),ve(e)}(e),Q.hovered&&me(e)})),e.on("mouseup",(t=>{if(A.show=!1,1===t.button){const{type:t}=e.origin,i=P(t,e.top),n={...e.origin,data:{...e.origin.data,value:i}};E.value.discardActiveObject(),O("change",n),we(n,"change")}}))}(p),R.push(p),pe.add(p))}(F,N,u,j,z,K)})),"pulse"===a){const{key:t}=e;let i=null;ae.set(t,R.map(((e,t,n)=>{var o,l;const s=n[t+1];if(s&&f(e.left,1)===f(s.left,1)){const t=e.left-_/2;e.set("left",t+_/4),null==(o=e.rightLine)||o.set("x1",e.left),i=e.left+_/2,s.set("left",i)}else i&&(null==(l=e.leftLine)||l.set("x2",i),e.set("left",i)),i=null;return[e.left,e.top]})))}const z=I.filter((e=>e));E.value.add(...z,...R,...X)}function ye(e,t){return"pain"===e&&0==t}function me(e,t="moving"){const{title:i,unit:n,type:o,data:l}=e.origin;A.point={x:e.left,y:e.top};let s=`时间 ${((null==l?void 0:l.time)||C(e.left)).slice(-5)}`;A.list=[function(){const{drugReduce:r,physicsReduce:u}=l||{},a="hover"===t?l.value:P(o,e.top);if(h(r))return s+=(null==l?void 0:l.changeTime)?"—>"+(null==l?void 0:l.changeTime.slice(-5)):"",`药物降${"pain"==o?"痛":"温"} ${a}—>${r}${n||""}`;if(h(u))return s+=(null==l?void 0:l.changeTime)?"—>"+(null==l?void 0:l.changeTime.slice(-5)):"",`物理降${"pain"==o?"痛":"温"} ${a}—>${u}${n||""}`;return`${i} ${a}${n||""}`}(),s],A.show=!0}function xe(e){const[t]=F,i=j(F),n=t.start,o=i.end,l=c(e);return l>=n&&l<=o}function be(e,t){const i="pain"===t.type?Z:U;if(!g(e)||!xe(e.time))return;const n=T(e.time),o=V(t.type,e.value);return[n,o<i.originY?i.originY:o>i.endY?i.endY:o]}function je(e){const t=new Date,i=String(t.getMonth()+1).padStart(2,"0"),n=String(t.getDate()).padStart(2,"0"),o=c(`${t.getFullYear()}-${i}-${n} 23:59:59`),l=c(`${C(e)}:00`);return ee&&l<c(ee)?(D("exceedMin"),!1):!(l>o)||(D("exceedMax"),!1)}function we(e,t="add"){const{type:i,dataIndex:n,index:o,data:l,key:s}=e,r=fe.find((e=>e.type===i));if("add"===t){const e=d(i)?r.dataList.find((e=>e.enable)):r.dataList[n],t=m(l.time,e.list);e.list.splice(t,0,l)}else r.dataList[n].list[o]=l;ke()}function ke(){var e;pe.size&&(null==(e=E.value)||e.remove(...function(e){const t=[];return e.forEach((e=>{e&&t.push(e),(null==e?void 0:e.leftLine)&&t.push(null==e?void 0:e.leftLine),(null==e?void 0:e.rightLine)&&t.push(null==e?void 0:e.rightLine),Object.values((null==e?void 0:e.otherObj)||{}).forEach((e=>{(null==e?void 0:e.obj)&&t.push(null==e?void 0:e.obj)}))})),t}([...pe]))),pe.clear(),Le()}function Le(e){ae.clear(),pe.clear(),ce.clear(),he.clear(),de.clear(),fe.forEach((t=>{null==e||e(t),t.dataList.forEach(((e,i)=>{!e.show||d(t.type)&&!e.enable||ge(e,i,t)}))})),ve(),[...pe].forEach((e=>{null==e||e.bringToFront()})),function(){var e;const t=fe.find((e=>"pulse"===e.type));if(!t||!(null==(e=t.dataList)?void 0:e.length))return;if(!t.dataList.some((e=>e.title.includes("脉搏"))))return;const i=Object.assign({},S,z.overlap||{}),l=[];ce.size&&[...ce].forEach((e=>{[...de].forEach((t=>{if(t.origin&&p(e,t)){const e=t.origin.key;if(e){const s={left:t.left,top:t.top,...n,hoverCursor:"default"};let r="koumai";"yemai"===e&&(r=e),l.push(o(r,{...i[e],...s}))}}}))})),setTimeout((()=>{E.value.add(...l),l.forEach((e=>{null==e||e.bringToFront(),pe.add(e)}))}))}()}return function(){const t=new e.Rect({left:oe,top:0,width:le-oe-se.strokeWidth,height:ie-se.strokeWidth,fill:"transparent",...se});E.value.add(t)}(),Le((e=>function(e){if("temperature"!==e.type||!e.positionLine)return;const t=V(e.type,e.positionLine.value),n=i([G,t,N,t],e.positionLine);E.value.add(n)}(e))),E.value.on("mouse:up",(e=>{const{button:t,target:i,pointer:n={}}=e;if(3===t){if(!$.event.evented)return;const{x:e=0,y:t=0}=n;if(e>=G&&e<=N&&t>=B&&t<=J){I.point={x:e,y:t},I.show=!0;const{type:o}=(null==i?void 0:i.origin)||{};if(i&&["temperature","pain"].includes(o))"temperature"===o&&(I.list=[...k]),"pain"===o&&(I.list=[...L]),I.target=i;else{I.target=null,I.list=["新增节点"],K.forEach((i=>{if(!X([...pe],e,"_type").includes(i.bigType)){const e=["pain"].includes(i.bigType)?Z:U;t>=e.originY&&t<=e.endY&&I.list.push({renderItem:R?R(i):()=>i.title,origin:{title:i.title,unit:i.unit,type:a(i.bigType),dataIndex:i.dataIndex,key:i.key},pointer:n})}}));const i=je(e);i&&1!==I.list.length||(I.show=!1,1===I.list.length&&i&&D("repeat"))}}}if(1===t){if(i)return;const{x:e=0,y:t=0}=n;e>=G&&e<=N&&t>0&&t<ie&&O("click:grid",{x:e,y:t,time:C(e)})}})),{clickMenu:function({item:e,target:t}){if(t){const{data:i,type:n,dataIndex:o,index:l}=t.origin,s=y(i,[...k,...L]);s[`${e.type}`]=e.value,s.changeTime=u(new Date,"yyyy-MM-dd HH:mm"),d(n)&&(s.key=t.origin.key);const r={...t.origin,data:s};O("change",r),we(r,"change")}else{const t={data:{time:C(e.pointer.x),value:P(e.origin.type,e.pointer.y),...d(e.origin.type)?{key:e.origin.key}:{}},...e.origin};O("add",t),we(t)}},setPopup:me,isAddPoint:je,updateData:we,redrawPoints:ke,gridPoints:pe,fixedNoRisePoints:he}}function M(e,t){return e.fixed||!t.value&&0!==t.value}export{E as useCenter};
|
@@ -1 +1 @@
|
|
1
|
-
import{fabric as e}from"../../../../../shared/utils/fabricjs/index.js";import{defaultStyle as t}from"../useDraw.js";import"date-fns";import{cloneDeep as i,last as l}from"lodash-es";import"../useEvent.js";import"vue";import"./useShadow.js";import"@vueuse/shared";import"naive-ui";import"@vueuse/core";function n(n,o,r,u,a,s){const{left:h,other:f,vitalSignsOriginY:c,xCellWidth:g,yCellHeight:v,endX:p}=o;let d=0;function m(i,l,o,u=!1){const a=[],s=u&&i.fixed&&i.fixedValue?i.fixedValue:i.value;String(s).split("").forEach(((l,n)=>{const o=new e.Text(l,{left:0,top:v*n,originX:"center",...t,objectCaching:!1,...i.style||{}});d=(v-(o.height||0))/2,a.push(o)}));const h=new e.Rect({left:0,top:0,width:g,height:v*a.length,fill:"transparent",originX:"center",...t}),{eventHighlight:c=!1}=f||{},p={originX:"center",left:l,top:o+d,baseTop:(i.baseTop||0)*v,trueLeft:l,trueHeight:a.length*v,objectCaching:!1,hoverCursor:"pointer",highlightObject:h,originData:i,selectable:!1,evented:c},m=new e.Group([h,...a],p);return function(e){const{highlightColor:t="#ffff00"}=f||{};e.on("mouseover",(()=>{e.highlightObject.set("fill",t),n.value.requestRenderAll()})),e.on("mouseout",(()=>{e.highlightObject.set("fill","transparent"),n.value.requestRenderAll()})),e.on("mousedown",(function(){r("eventClick",e.originData)}))}(m),n.value.add(m),m}!function(){var e,t;if(!(null==f?void 0:f.list))return!1;const n=[],o=[];i(f.list).forEach(((e,t)=>{e.value=e.value||"";const i=0===t?"vertical":e.align||"vertical",l=u(e.time,!0);if(l>p)return;const n=o.find((e=>e.left==l));if(n)n[i].push(e);else{const t={left:l,vertical:[],horizontal:[]};t[i].push(e),o.push(t)}}));const r=null==(t=null==(e=h.yScaleValue)?void 0:e.find((e=>"temperature"===e.type)))?void 0:t.list,d=(null==r?void 0:r.length)?a("temperature",
|
1
|
+
import{fabric as e}from"../../../../../shared/utils/fabricjs/index.js";import{defaultStyle as t}from"../useDraw.js";import"date-fns";import{cloneDeep as i,last as l}from"lodash-es";import"../useEvent.js";import"vue";import"./useShadow.js";import"@vueuse/shared";import"naive-ui";import"@vueuse/core";function n(n,o,r,u,a,s){const{left:h,other:f,vitalSignsOriginY:c,xCellWidth:g,yCellHeight:v,endX:p}=o;let d=0;function m(i,l,o,u=!1){const a=[],s=u&&i.fixed&&i.fixedValue?i.fixedValue:i.value;String(s).split("").forEach(((l,n)=>{const o=new e.Text(l,{left:0,top:v*n,originX:"center",...t,objectCaching:!1,...i.style||{}});d=(v-(o.height||0))/2,a.push(o)}));const h=new e.Rect({left:0,top:0,width:g,height:v*a.length,fill:"transparent",originX:"center",...t}),{eventHighlight:c=!1}=f||{},p={originX:"center",left:l,top:o+d,baseTop:(i.baseTop||0)*v,trueLeft:l,trueHeight:a.length*v,objectCaching:!1,hoverCursor:"pointer",highlightObject:h,originData:i,selectable:!1,evented:c},m=new e.Group([h,...a],p);return function(e){const{highlightColor:t="#ffff00"}=f||{};e.on("mouseover",(()=>{e.highlightObject.set("fill",t),n.value.requestRenderAll()})),e.on("mouseout",(()=>{e.highlightObject.set("fill","transparent"),n.value.requestRenderAll()})),e.on("mousedown",(function(){r("eventClick",e.originData)}))}(m),n.value.add(m),m}!function(){var e,t;if(!(null==f?void 0:f.list))return!1;const n=[],o=[];i(f.list).forEach(((e,t)=>{e.value=e.value||"";const i=0===t?"vertical":e.align||"vertical",l=u(e.time,!0);if(l>p)return;const n=o.find((e=>e.left==l));if(n)n[i].push(e);else{const t={left:l,vertical:[],horizontal:[]};t[i].push(e),o.push(t)}}));const r=null==(t=null==(e=h.yScaleValue)?void 0:e.find((e=>"temperature"===e.type)))?void 0:t.list,d=(null==r?void 0:r.length)?a("temperature",35):0;o.forEach((e=>{let t=c.originY,i=e.left,o=0,r=d,u=i;function a(e,t){var o,a;if((e=>e.fixed&&d&&(e.fixedValue||e.value))(e)){const h=[...s].find((e=>Math.abs(e.left-i)<1));h&&(t||Math.abs(i-u)>1)&&(r=h.top+h.height),u=i,n.push(m(e,i,r,!0)),r+=null!=(a=null==(o=l(n))?void 0:o.trueHeight)?a:0}}e.vertical.forEach(((r,u)=>{var s,h,f;const p=(r.baseTop||0)*v,d=(null==(s=l(n))?void 0:s.left)||0;0===u&&e.left<=d&&(i=d+g);if(n.filter((e=>e.trueLeft===i)).length){const e=String(r.value).length;t+=o,t+e*v+p>c.endY&&(t=c.originY,i+=g)}t+=p,String(r.value).length&&(n.push(m(r,i,t)),o=null!=(f=null==(h=l(n))?void 0:h.trueHeight)?f:0),a(r,0===u)})),e.horizontal.forEach(((t,o)=>{var r,u;const s=c.originY+(t.baseTop||0)*v,h=(null==(r=l(n))?void 0:r.left)||0;e.left<=h&&(i=h+g),String(t.value).length&&n.push(m(t,i,s)),a(t,0===(null==(u=e.vertical)?void 0:u.length)&&0===o)}))}))}()}export{n as useOther};
|
@@ -1 +1 @@
|
|
1
|
-
import{reactive as e,computed as a,watch as t,toRefs as l}from"vue";import{defaultBorderStyle as u}from"../useDraw.js";import"../../../../../shared/utils/fabricjs/index.js";import{useCumputedPoint as i}from"../useCumputedPoint.js";import{useCanvasEvent as n}from"../useEvent.js";import{setOtherType as r,getFloorNumber as o}from"../../utils/index.js";import{flatten as v}from"lodash-es";import{format as s,addDays as d}from"date-fns";import"naive-ui";import"@vueuse/core";import{useTop as c}from"./useTop.js";import{useLeft as h}from"./useLeft.js";import{useRight as p}from"./useRight.js";import{useCenter as g}from"./useCenter.js";import{useBottom as m}from"./useBottom.js";import{useOther as f}from"./useOther.js";function y(y,S,b,Y,
|
1
|
+
import{reactive as e,computed as a,watch as t,toRefs as l}from"vue";import{defaultBorderStyle as u}from"../useDraw.js";import"../../../../../shared/utils/fabricjs/index.js";import{useCumputedPoint as i}from"../useCumputedPoint.js";import{useCanvasEvent as n}from"../useEvent.js";import{setOtherType as r,getFloorNumber as o}from"../../utils/index.js";import{flatten as v}from"lodash-es";import{format as s,addDays as d}from"date-fns";import"naive-ui";import"@vueuse/core";import{useTop as c}from"./useTop.js";import{useLeft as h}from"./useLeft.js";import{useRight as p}from"./useRight.js";import{useCenter as g}from"./useCenter.js";import{useBottom as m}from"./useBottom.js";import{useOther as f}from"./useOther.js";function y(y,S,w,b,Y,D){const x=15,C=e({select:null,redrawPoints:null,clickMenu:null}),j=a((()=>{const{painSurplusCell:e=[0,0]}=S.data.grid||{};return~J.value?e:[0,0]})),V=a((()=>{var e,a;const t=(null==(a=null==(e=S.data.grid)?void 0:e.surplusCell)?void 0:a.slice())||[0,0,0,0];return 0===J.value?t[0]=t[0]+j.value[1]:J.value>0&&(t[2]=t[2]+j.value[0]),t})),H=a((()=>0===J.value?[j.value[0],V.value[1],V.value[2],V.value[3]]:J.value>0?[V.value[0],V.value[1],j.value[1],V.value[3]]:V.value)),X=a((()=>{const{top:e}=S.data;return e.date.show&&(e.date.height||x)||0})),L=a((()=>{var e;const{top:a}=S.data;return(null==(e=a.hospitalDays)?void 0:e.show)&&(a.hospitalDays.height||x)||0})),P=a((()=>{var e;const{top:a}=S.data;return(null==(e=a.operationDays)?void 0:e.show)&&(a.operationDays.height||x)||0})),M=a((()=>{var e,a,t;const{top:l}=S.data;return((null==(e=l.xScalevalue)?void 0:e.show)&&(l.xScalevalue.height||x)||0)+((null==(a=l.xScalevalue)?void 0:a.show)&&null!=(t=l.dayHeight)?t:0)})),I=a((()=>{var e;const{top:a}=S.data;return(null==(e=a.childbirthDays)?void 0:e.show)&&(a.childbirthDays.height||x)||0})),N=a((()=>{var e;const{bottom:a}=S.data;return(null==(e=null==a?void 0:a.breathing)?void 0:e.show)&&(a.breathing.height||30)||0})),k=a((()=>{const{grid:e}=S.data;return e.mainXCell*e.subXCell+V.value[1]+V.value[3]})),O=a((()=>{const{grid:e}=S.data,a=J.value>0?j.value[1]:j.value[0];return e.mainYCell*e.subYCell+V.value[0]+V.value[2]+a})),R=a((()=>{var e;const{width:a,right:t=null,top:l}=S.data;if(!t)return a;return a-(null!=(e=t.width)?e:0)})),W=a((()=>R.value-V.value[1]*G.value)),$=a((()=>{const{top:e,left:a}=S.data;return e.titleWidth+A.value})),q=a((()=>{const{bottom:e=null,height:a}=S.data;if(!e)return a;return a-(e.height||30)})),z=a((()=>{var e;const{top:a}=S.data,t=a.xScalevalue.show&&(null!=(e=a.dayHeight)?e:0)||0,l=a.xScalevalue.show&&(a.xScalevalue.height||x)||0;return X.value+t+l+L.value+P.value+I.value})),G=a((()=>(R.value-$.value)/k.value)),T=a((()=>(q.value-z.value)/O.value)),A=a((()=>{var e,a;const{left:t}=S.data;return(null==(e=t.icons)?void 0:e.show)&&((null==(a=t.icons)?void 0:a.width)||100)||0})),B=a((()=>{var e,a;const{top:t,grid:l}=S.data,u=(null==(a=null==(e=t.date.list)?void 0:e.slice)?void 0:a.call(e,0,l.mainXCell))||[],i=t.xScalevalue.times;let n=$.value-G.value;const r=t.date.startDate||s(new Date,"yyyy-MM-dd"),o=u.reduce(((e,a,t)=>0===t?e.concat(r):e.concat(s(d(new Date(r.replace(/-/g,"/")),t),"yyyy-MM-dd"))),[]).map((e=>i.map((a=>{n+=G.value;const t=Date.parse(`${e} ${a.start}`),l=Date.parse(`${e} ${a.end}`);return{start:t,end:l,left:n,center:n+G.value/2,scaleCell:(l-t)/G.value}}))));return v(o)})),E=a((()=>{var e;return(null==(e=S.data.grid)?void 0:e.event)||{selectable:!0,evented:!0,hovered:!0}})),F=a((()=>{const{left:e}=S.data;return v(e.yScaleValue.map((e=>e.dataList.filter((e=>e.show)).map(((a,t)=>({...a,bigType:r(a.title,e.type),unit:e.unit,dataIndex:t}))))))})),J=a((()=>{var e,a;const{left:t}=S.data,l=t.yScaleValue.findIndex((e=>"pain"===e.type));return l>-1&&(null==(a=null==(e=t.yScaleValue[l].dataList)?void 0:e[0])?void 0:a.show)?l:-1})),K=a((()=>{const{grid:e}=S.data;return-1===J.value?0:T.value*e.subYCell})),Q=a((()=>{const{left:e}=S.data,a={originY:z.value+j.value[0]*T.value,endY:q.value-j.value[1]*T.value};return 0===J.value&&e.yScaleValue.length>1?a.endY=a.originY+K.value:J.value===e.yScaleValue.length-1&&(a.originY=a.endY-K.value),a})),U=a((()=>{const{left:e}=S.data,a={originY:z.value+V.value[0]*T.value,endY:q.value-V.value[2]*T.value};return 0===J.value&&e.yScaleValue.length>1?a.originY=Q.value.endY+V.value[0]*T.value:J.value===e.yScaleValue.length-1&&(a.endY=Q.value.originY-V.value[2]*T.value),a})),Z=a((()=>{var e,a;const{top:t,grid:l}=S.data,u=[];for(const i in t)t[i].show&&u.push({...t[i],list:(null==(a=null==(e=t[i].list)?void 0:e.slice)?void 0:a.call(e,0,l.mainXCell))||[],key:i});return u.sort(((e,a)=>e.seq-a.seq))})),_=a((()=>{var e;const{left:a,right:t}=S.data,l=a.yScaleValue.find((e=>"temperature"===e.type)),u=(null==t?void 0:t.yScaleValue)||{};if(null==(e=null==l?void 0:l.list)?void 0:e.length){const e=(null==u?void 0:u.showdetailedScale)?l.list.reduce((e=>{const a=e[e.length-1];return a?e.concat([a+1,a+2]):e.concat([92])}),[]):[],a=l.list.map((e=>o(1.8*e+32)));Object.assign(u,{list:a,detailedList:e,spaceGridNumber:l.spaceGridNumber})}return u})),ee=e({canvasWidth:S.data.width,canvasHeight:S.data.height,borderStyle:{...u,...S.data.borderStyle||{}},selectionStyle:S.data.selectionStyle||{},dateHeight:X.value,hospitalDaysHeight:L.value,operationDaysHeight:P.value,xScalevalueHeight:M.value,childbirthDaysHeight:I.value,topList:Z.value,breathingHeight:N.value,hospitalizationDate:S.data.hospitalizationDate,grid:S.data.grid,top:S.data.top,left:S.data.left,right:S.data.right,bottom:S.data.bottom,other:S.data.other,painIndex:J.value,painHeight:K.value,painOriginY:Q.value,vitalSignsOriginY:U.value,gridXNumber:k.value,gridYNumber:O.value,iconsWidth:A.value,originX:$.value,originY:z.value,endX:R.value,endXLimit:W.value,endY:q.value,xCellWidth:G.value,yCellHeight:T.value,xScaleList:B.value,event:E.value,itemList:F.value,getRightInfo:_.value,config:S.data.config||{},surplusCell:V.value,painSurplusCell:j.value,mainSurplusCell:H.value}),{computedX:ae,computedY:te,getXValue:le,getYValue:ue}=i(ee);return t((()=>y.value),(e=>{e&&function(){c(y,ee);const{setPopup:e,isAddPoint:a,updateData:t,redrawPoints:l,clickMenu:u,gridPoints:i,fixedNoRisePoints:r}=g(y,ee,w,ae,te,le,ue,S.addRenderItem,Y,D);C.redrawPoints=l,C.clickMenu=u;const{drawScaleValue:o}=h(y,ee,w,e,Y,ae,te,le,ue,a,t,i);p(y,ee,o),m(y,ee),f(y,ee,w,ae,te,r);const{select:v}=n(y,ee,w);C.select=v}()}),{immediate:!0}),{propItems:ee,...l(C)}}export{y as useTemperatureChart};
|
@@ -2,7 +2,7 @@ import { IPointType } from '../interface';
|
|
2
2
|
import { AnyObject } from '../../../../shared/types';
|
3
3
|
export declare function useCumputedPoint(propItems: AnyObject): {
|
4
4
|
computedX: (value: number | string, setAllCenter?: boolean) => any;
|
5
|
-
computedY: (type:
|
5
|
+
computedY: (type: string, value: number | string) => number;
|
6
6
|
getXValue: (pointX: number) => string | undefined;
|
7
7
|
getYValue: (type: IPointType, pointY: number) => number;
|
8
8
|
};
|
@@ -1 +1 @@
|
|
1
|
-
import{format as
|
1
|
+
import{format as e}from"date-fns";import{getTime as n,getFloorNumber as t}from"../utils/index.js";import{last as l}from"lodash-es";function i(i){const{xScaleList:u,xCellWidth:r,yCellHeight:c,left:o,vitalSignsOriginY:a,painOriginY:d,canvasWidth:s}=i;function f(e){let n=0;const t=o.yScaleValue.find((n=>n.type===e)),l=(null==t?void 0:t.list)||[];return l.length?(n=c/((l[1]-l[0])/t.spaceGridNumber),{yScaleCell:n,list:l}):{yScaleCell:n,list:l}}return{computedX:function(e,t=!1){const i=n(e),[r]=u,c=l(u);if(i<r.start)return 0;if(i>c.end)return s;const o=u.findIndex((e=>e.end>=i));if(o>-1){return u[o].center}},computedY:function(e,n){const{yScaleCell:t,list:l}=f(e),i=+n-Math.min(...l);return("pain"===e?d.endY:a.endY)-t*i},getXValue:function(n){const t=u.findIndex((e=>e.left+r>=n));if(t>-1){const l=u[t],i=n-l.left,r=l.scaleCell*i,c=l.start+r;return e(new Date(c),"yyyy-MM-dd HH:mm")}},getYValue:function(e,n){const{yScaleCell:l,list:i}=f(e),u=i.length?Math.min(...i):0,r="pain"===e?d.endY:a.endY;return t((r-n)/l+u)}}}function u(l){const{xAxis:i,originX:u,originY:r,xCellWidth:c,endY:o,timeXCell:a,startTime:d,scaleValues:s}=l;return{computedX:function(e){return(n(e)-d)/a+u},computedY:function(e,n,t){const[i]=n;return o-(+t-i)*l[`${e}YCell`]},getXValue:function(n){return e(new Date((n-u)*a+d),"yyyy-MM-dd HH:mm")},getYValue:function(e,n){const i=s.find((n=>[n.key,n.type||""].includes(e))),[u]=(null==i?void 0:i.range)||[0],r=(o-n)/l[`${e}YCell`]+u;return t(r)}}}function r(e){const{config:n,xCellWidth:l,yCellHeight:i}=e,{hz:u,mainXCellValue:r,valueUnit:c,mainYCellValue:o}=n;return{computedX:function(e){return e/u/r*l},computedY:function(e){return("uv"===c?.001*e:"v"===c?1e3*e:e)/o*i},getXValue:function(e){return t(r/l*e)},getYValue:function(e){return t(o/i*e)}}}export{u as useBirthProcessCumputedPoint,i as useCumputedPoint,r as useElectrocardiogramCumputedPoint};
|
@@ -776,6 +776,8 @@ declare const IhoChat: SFCWithInstall<import("vue").DefineComponent<{
|
|
776
776
|
handleContextmenu: (event: MouseEvent, msgId: string) => Promise<void>;
|
777
777
|
setMenuPosition: (event: MouseEvent) => Promise<void>;
|
778
778
|
showMessage: (item: import("../../shared/types").AnyObject) => boolean;
|
779
|
+
showReferenceMsg: (item: import("../../shared/types").AnyObject) => any;
|
780
|
+
showBlendMsg: (item: import("../../shared/types").AnyObject) => any;
|
779
781
|
showTemplateMsg: (item: import("../../shared/types").AnyObject, type: "template" | "system") => boolean | undefined;
|
780
782
|
isTemplate3: (content: import("../../shared/types").AnyObject) => boolean;
|
781
783
|
needShowTime: (item: import("../../shared/types").AnyObject, index: number) => boolean;
|
@@ -993,7 +995,7 @@ declare const IhoChat: SFCWithInstall<import("vue").DefineComponent<{
|
|
993
995
|
defaultValue: import("../../shared/types").AnyObject[];
|
994
996
|
}>;
|
995
997
|
btnDisabled: import("vue").ComputedRef<boolean>;
|
996
|
-
handleCall: (chatMessageType: string, checkedIds?:
|
998
|
+
handleCall: (chatMessageType: string, checkedIds?: string[]) => void;
|
997
999
|
handleKeyDown: (event: KeyboardEvent) => void;
|
998
1000
|
isWrap: (event: KeyboardEvent) => boolean;
|
999
1001
|
handleInput: () => void;
|
@@ -781,6 +781,8 @@ declare const _default: import("vue").DefineComponent<{
|
|
781
781
|
handleContextmenu: (event: MouseEvent, msgId: string) => Promise<void>;
|
782
782
|
setMenuPosition: (event: MouseEvent) => Promise<void>;
|
783
783
|
showMessage: (item: AnyObject) => boolean;
|
784
|
+
showReferenceMsg: (item: AnyObject) => any;
|
785
|
+
showBlendMsg: (item: AnyObject) => any;
|
784
786
|
showTemplateMsg: (item: AnyObject, type: "template" | "system") => boolean | undefined;
|
785
787
|
isTemplate3: (content: AnyObject) => boolean;
|
786
788
|
needShowTime: (item: AnyObject, index: number) => boolean;
|
@@ -998,7 +1000,7 @@ declare const _default: import("vue").DefineComponent<{
|
|
998
1000
|
defaultValue: AnyObject[];
|
999
1001
|
}>;
|
1000
1002
|
btnDisabled: import("vue").ComputedRef<boolean>;
|
1001
|
-
handleCall: (chatMessageType: string, checkedIds?:
|
1003
|
+
handleCall: (chatMessageType: string, checkedIds?: string[]) => void;
|
1002
1004
|
handleKeyDown: (event: KeyboardEvent) => void;
|
1003
1005
|
isWrap: (event: KeyboardEvent) => boolean;
|
1004
1006
|
handleInput: () => void;
|
@@ -18,7 +18,7 @@ declare const _default: import("vue").DefineComponent<{}, {
|
|
18
18
|
defaultValue: AnyObject[];
|
19
19
|
}>;
|
20
20
|
btnDisabled: import("vue").ComputedRef<boolean>;
|
21
|
-
handleCall: (chatMessageType: string, checkedIds?:
|
21
|
+
handleCall: (chatMessageType: string, checkedIds?: string[]) => void;
|
22
22
|
handleKeyDown: (event: KeyboardEvent) => void;
|
23
23
|
isWrap: (event: KeyboardEvent) => boolean;
|
24
24
|
handleInput: () => void;
|
@@ -1 +1 @@
|
|
1
|
-
import{defineComponent as e,ref as n,computed as t,watch as o,withDirectives as r,openBlock as s,createElementBlock as i,normalizeStyle as a,unref as c,createElementVNode as l,toDisplayString as u,createVNode as f,createCommentVNode as d,withCtx as m,Fragment as p,renderList as g,createBlock as h,createTextVNode as y,mergeProps as
|
1
|
+
import{defineComponent as e,ref as n,computed as t,watch as o,withDirectives as r,openBlock as s,createElementBlock as i,normalizeStyle as a,unref as c,createElementVNode as l,toDisplayString as u,createVNode as f,createCommentVNode as d,withCtx as m,Fragment as p,renderList as g,createBlock as h,createTextVNode as y,mergeProps as v,vShow as w}from"vue";import{NIcon as M,NTooltip as _,NPopover as k,NButton as C,NUpload as I,NUploadTrigger as E}from"naive-ui";import T from"./ChatAdd.vue.js";import{useState as b}from"../hooks/useState.js";import{useSession as x}from"../hooks/useSession.js";import{MESSAGE_TYPE as j,AV_STATUS as z}from"../constants/index.js";import"trtc-sdk-v5";import{simplifyMessage as L,base64ToFile as O}from"../utils/index.js";import{emojis as R}from"../utils/emoji.js";import{uploadFileApi as q}from"../api/index.js";import{CloseCircleOutline as D,CallOutline as A,VideocamOutline as V}from"@vicons/ionicons5";import{xor as H,trim as J,cloneDeep as K}from"lodash-es";import{uuidGenerator as F}from"../../../../shared/utils/index.js";const U={key:0,class:"reference-content-box"},$={class:"reference-content"},G=["innerHTML"],N={class:"tool-box"},B=l("i",{class:"chat--iconfont chat--icon-face"},null,-1),S=l("span",null,"默认表情",-1),X={class:"list-box"},P=["src"],Q=l("i",{class:"chat--iconfont chat--icon-good"},null,-1),W=l("i",{class:"chat--iconfont chat--icon-image"},null,-1),Y=l("i",{class:"chat--iconfont chat--icon-folder"},null,-1),Z={class:"btn-box"},ee=l("span",{class:"tip"},"Enter 发送, Ctrl + Enter 换行",-1);var ne=e({__name:"ChatFooter",setup(e){const ne=n(),{state:te,sendMessage:oe}=b(),{isGroupChat:re}=x(te),se=n(!1),ie=n(""),ae=t((()=>({options:te.currentGroupUser,defaultValue:[te.userInfo]}))),ce=t((()=>!ie.value.replace(/( |\s|<br>)+/g,"")));function le(e,n=[]){const t=F(),o=[],r=n.length>0;te.showVideo||te.showMultipleVideo||(r?(o.push(...H(n,[te.userInfo.id])),Object.assign(te.currentAVMsg,{callMode:"call",checkedIds:o,strRoomId:t,chatMessageType:e}),te.showMultipleVideo=!0):oe({content:{chatMessageType:e,msg:"",avStatus:z.IN_CALL}}))}function ue(e){["Enter"].includes(e.key)&&(e.ctrlKey&&(e.preventDefault(),document.execCommand("InsertLineBreak")),function(e){return e.altKey||e.ctrlKey||e.metaKey||e.shiftKey}(e)||(e.preventDefault(),pe()))}function fe(){var e;ie.value=(null==(e=ne.value)?void 0:e.innerHTML)||""}async function de(e){const n=new FormData;return n.append("sender",te.userInfo.id),n.append("file",e),await q(n)}async function me(e,n){const{file:t,name:o}=e.file,r=await de(t);if(!r)return console.log("上传失败");ge({chatMessageType:n,msg:n===j.FILE?o:r,url:r})}async function pe(){const{innerHTML:e="",innerText:n="",outerText:t=""}=ne.value||{};if(ce.value)return console.log("请输入内容");let o=j.TEXT,r="";if(e){const t=e.match(/<img[^>]*>/gi),s=(t||[]).length;if(n&&0===s)r=n;else if(n||1!==s){if(o=j.BLEND,r=e,null==t?void 0:t.length)for(let e=0;e<s;e++)if(t[e].includes(`data-type="${j.EMOJI}"`)){const n=t[e].match(/data-msg="(.*?)"/);n&&n.length>1&&(r=r.replace(t[e],`[${n[1]}]`))}else{const n=t[e].match(/src\s*=\s*"([^"]*)"/);if(n&&n.length>1){const e=O(n[1]);if(e){const t=await de(e);r=r.replace(n[1],t||"")}}}}else if(e.includes(j.EMOJI)){o=j.EMOJI;const n=e.match(/data-msg\s*=\s*"([^"]*)"/);n&&(r=n[1])}else{o=j.IMAGE;const n=e.match(/src\s*=\s*"([^"]*)"/);if(n){const e=O(n[1]);if(e){const n=await de(e);n&&(r=n)}}}}else r=J(n);r&&ge({msg:r,chatMessageType:o,origin:"btn"})}async function ge(e){const{chatMessageType:n=j.TEXT,msg:t,url:o,origin:r=""}=e,s={msg:t,chatMessageType:n};n===j.FILE&&(s.fileUrl=o),"btn"===r&&(ne.value.innerHTML="",ie.value=""),te.currentReferenceMsg&&([j.TEXT,j.EMOJI,j.BLEND].includes(n)&&(s.referenceContent=K(te.currentReferenceMsg)),te.currentReferenceMsg=null),oe({content:s})}return o((()=>te.currentReferenceMsg),(e=>{var n;e&&(null==(n=ne.value)||n.focus())})),(e,n)=>r((s(),i("section",{class:"chat-footer",style:a({cursor:c(te).id?"default":"not-allowed"})},[c(te).currentReferenceMsg?(s(),i("div",U,[l("div",$,[l("span",null,u(c(te).currentReferenceMsg.senderName)+":",1),l("pre",{innerHTML:c(L)(c(te).currentReferenceMsg.content)},null,8,G)]),f(c(M),{component:c(D),onClick:n[0]||(n[0]=()=>c(te).currentReferenceMsg=null)},null,8,["component"])])):d("v-if",!0),l("div",N,[f(c(_),{"show-arrow":!1},{trigger:m((()=>[f(c(k),{"content-class":"emoji-content",class:"emoji-wrapper",show:se.value,"onUpdate:show":n[1]||(n[1]=e=>se.value=e),placement:"top",trigger:"click","show-arrow":!1,"display-directive":"show",delay:0},{trigger:m((()=>[f(c(C),{quaternary:"",size:"tiny"},{icon:m((()=>[B])),_:1})])),default:m((()=>[S,l("div",X,[(s(!0),i(p,null,g(c(R).default,(([e,n])=>(s(),h(c(_),{key:e,"show-arrow":!1},{trigger:m((()=>[f(c(C),{quaternary:"",size:"tiny",onClick:()=>function(e){var n;se.value=!1,null==(n=ne.value)||n.focus(),document.execCommand("insertHTML",!1,`<img data-msg=${e} data-type=${j.EMOJI} class="emoji--min" src=${R.findEmoji(e)} />`)}(e)},{icon:m((()=>[l("img",{src:n},null,8,P)])),_:2},1032,["onClick"])])),default:m((()=>[y(" "+u(e),1)])),_:2},1024)))),128))])])),_:1},8,["show"])])),default:m((()=>[y(" 表情 ")])),_:1}),f(c(_),{"show-arrow":!1},{trigger:m((()=>[f(c(C),{quaternary:"",size:"tiny",onClick:n[2]||(n[2]=()=>ge({chatMessageType:c(j).EMOJI,msg:0}))},{icon:m((()=>[Q])),_:1})])),default:m((()=>[y(" 点赞 ")])),_:1}),f(c(I),{abstract:"",multiple:"",accept:"image/*",onChange:n[3]||(n[3]=e=>me(e,c(j).IMAGE))},{default:m((()=>[f(c(E),{abstract:""},{default:m((({handleClick:e})=>[f(c(_),{"show-arrow":!1},{trigger:m((()=>[f(c(C),{quaternary:"",size:"tiny",onClick:e},{icon:m((()=>[W])),_:2},1032,["onClick"])])),default:m((()=>[y(" 上传图片 ")])),_:2},1024)])),_:1})])),_:1}),f(c(I),{abstract:"",multiple:"",accept:"video/*,.pdf,.doc.docx,,.zip,.xlsx,.txt",onChange:n[4]||(n[4]=e=>me(e,c(j).FILE))},{default:m((()=>[f(c(E),{abstract:""},{default:m((({handleClick:e})=>[f(c(_),{"show-arrow":!1},{trigger:m((()=>[f(c(C),{quaternary:"",size:"tiny",onClick:e},{icon:m((()=>[Y])),_:2},1032,["onClick"])])),default:m((()=>[y(" 上传文件 ")])),_:2},1024)])),_:1})])),_:1}),c(re)?(s(),i(p,{key:0},[f(T,v(c(ae),{onComfirm:n[5]||(n[5]=e=>le(c(j).AUDIO,e))}),{trigger:m((()=>[f(c(_),{"show-arrow":!1},{trigger:m((()=>[f(c(C),{quaternary:"",size:"tiny"},{icon:m((()=>[f(c(M),{size:"18",component:c(A)},null,8,["component"])])),_:1})])),default:m((()=>[y(" 语音通话 ")])),_:1})])),_:1},16),f(T,v(c(ae),{onComfirm:n[6]||(n[6]=e=>le(c(j).VIDEO,e))}),{trigger:m((()=>[f(c(_),{"show-arrow":!1},{trigger:m((()=>[f(c(C),{quaternary:"",size:"tiny"},{icon:m((()=>[f(c(M),{size:"20",component:c(V)},null,8,["component"])])),_:1})])),default:m((()=>[y(" 视频会议 ")])),_:1})])),_:1},16)],64)):(s(),i(p,{key:1},[f(c(_),{"show-arrow":!1},{trigger:m((()=>[f(c(C),{quaternary:"",size:"tiny",onClick:n[7]||(n[7]=()=>le(c(j).AUDIO))},{icon:m((()=>[f(c(M),{size:"18",component:c(A)},null,8,["component"])])),_:1})])),default:m((()=>[y(" 语音通话 ")])),_:1}),f(c(_),{"show-arrow":!1},{trigger:m((()=>[f(c(C),{quaternary:"",size:"tiny",onClick:n[8]||(n[8]=()=>le(c(j).VIDEO))},{icon:m((()=>[f(c(M),{size:"20",component:c(V)},null,8,["component"])])),_:1})])),default:m((()=>[y(" 视频通话 ")])),_:1})],64))]),r(l("div",{ref_key:"inputRef",ref:ne,class:"input-box",contenteditable:"",onKeydown:ue,onInput:fe},null,544),[[w,c(te).id]]),l("div",Z,[ee,f(c(C),{type:"primary",round:"",disabled:c(ce),onClick:pe},{default:m((()=>[y("发送")])),_:1},8,["disabled"])])],4)),[[w,c(te).id]])}});export{ne as default};
|
@@ -29,6 +29,8 @@ declare const _default: import("vue").DefineComponent<{}, {
|
|
29
29
|
handleContextmenu: (event: MouseEvent, msgId: string) => Promise<void>;
|
30
30
|
setMenuPosition: (event: MouseEvent) => Promise<void>;
|
31
31
|
showMessage: (item: AnyObject) => boolean;
|
32
|
+
showReferenceMsg: (item: AnyObject) => any;
|
33
|
+
showBlendMsg: (item: AnyObject) => any;
|
32
34
|
showTemplateMsg: (item: AnyObject, type: 'system' | 'template') => boolean | undefined;
|
33
35
|
isTemplate3: (content: AnyObject) => boolean;
|
34
36
|
needShowTime: (item: AnyObject, index: number) => boolean;
|
@@ -1 +1 @@
|
|
1
|
-
import{defineComponent as e,ref as t,computed as n,watch as s,openBlock as o,createElementBlock as i,normalizeClass as
|
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 g,createBlock as f,createElementVNode as v,withModifiers as y,nextTick as h}from"vue";import{NImageGroup as T,NAvatar as M,NImage as k,NIcon as _,NSpace as x,NButtonGroup as w,NButton as I,NTooltip as S}from"naive-ui";import{format as C}from"date-fns";import{getHistoryRecordApi as j,readMessageApi as L}from"../api/index.js";import{useState as E}from"../hooks/useState.js";import{useSession as b}from"../hooks/useSession.js";import{MESSAGE_TYPE as z}from"../constants/index.js";import"trtc-sdk-v5";import{isAudioOrVideoMessage as A,simplifyMessage as H,getAVTime as O,downloadFile as D}from"../utils/index.js";import{first as R,last as N}from"lodash-es";import P from"./PersonProfile.vue.js";import q from"./MessageTemplate.vue.js";import{emojis as B}from"../utils/emoji.js";import J from"./ContextMenu.js";import"../../../../shared/utils/index.js";import"@vueuse/core";import"@vue/shared";import"@vueuse/shared";import"../../../../shared/hooks/selectHooks/useSearchContent.js";import{CallOutline as U,VideocamOutline as F,DocumentSharp as G,ChatbubbleEllipsesOutline as K,EllipsisHorizontal as X,ArrowDownSharp as Y}from"@vicons/ionicons5";import{useScrollLoading as $}from"../../../../shared/hooks/useScrollLoading.js";const Q={key:0,class:"time"},V={key:2,class:"message-box"},W={key:0,class:"content-box"},Z={class:"name-box"},ee=["data-time"],te=["onContextmenu"],ne={key:0,class:"reference-content"},se=["innerHTML"],oe=["src"],ie=["innerHTML"],re=["innerHTML"],ae={style:{"margin-left":"8px"}},ce={class:"size"};var le=e({__name:"ChatMain",setup(e){const le=t(),{state:ue,setMsgList:me}=E(),{setCurrentSessionItem:pe,isGroupChat:de}=b(ue),ge=t(),fe=t(!1),ve=t({left:0,top:0}),ye=t(),he={page:0,hasMore:!0,lastSendTime:C(new Date,"yyyy-MM-dd HH:mm:ss")},Te=n((()=>({"--c-tip-top":de.value?"1px":"-20px","--c-tip-gap":de.value?"10px":"0px"})));function Me({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(_,{style:"cursor: pointer",color:"rgba(255, 255, 255, 0.75",size:24,component:Y,onClick:()=>o&&D(o,"img")},null),default:()=>"下载"}),e.close]}async function ke(){try{if(!he.hasMore)return;he.page++;const e=await j({sessionKey:ue.currentSessionItem.sessionKey,page:he.page,lastSendTime:he.lastSendTime});if(!Array.isArray(e)||0===e.length)return he.hasMore=!1,console.log("接口返回不是一个数组,或者没有更多消息了");const t=R(e).id;he.lastSendTime=N(e).sendTime,me(he.page>1?[...e,...ue.msgList]:e),1===he.page&&ue.currentSessionItem.unreadNum&&(await L({chatType:ue.currentSessionItem.chatType,messageIdSet:[t],receiver:ue.userInfo.id,sender:ue.currentSessionItem.receiver}),pe({unreadNum:0}))}catch(e){console.log(e)}}async function _e(e,t){ye.value=t,async function(e){var t,n,s,o,i,r;fe.value=!0,await h();const{clientX:a,clientY:c}=e,{width:l=0,height:u=0,left:m=0,top:p=0}=(null==(t=le.value)?void 0:t.getBoundingClientRect())||{},d=null!=(o=null==(s=null==(n=ge.value)?void 0:n.$el)?void 0:s.getBoundingClientRect().height)?o:220,g=null!=(r=null==(i=le.value)?void 0:i.scrollTop)?r:0,f=5,v={};a<=m+l/2?v.left=a-m+f+"px":v.right=m+l-a-f+"px";c-p<d/2?v.top=g+f+"px":p+u-c<=d/2?v.bottom=Math.abs(g)+f+"px":v.top=g+c-p-d/2+"px";ve.value=v}(e)}function xe(e){const{chatMessageType:t,messageTemplate:n}=e.content;return t!==z.TEMPLATE||!!n}function we(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 Ie(e){const{chatMessageType:t,msg:n=""}=e.content,s=n.match(/<img[^>]*>/gi);return t===z.BLEND&&s&&s.length}function Se(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 Ce(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 je(e,t){var n;const s=new Date(e.sendTime).getTime(),o=null==(n=ue.msgList[t+1])?void 0:n.sendTime;if(o){return s-new Date(o).getTime()>3e5}return!0}function Le(e){ue.currentReferenceMsg=e,ue.currentReferenceMsg.content.referenceContent=null,Object.assign(ue.currentReferenceMsg,{chatType:ue.currentSessionItem.chatType,receiver:ue.currentSessionItem.receiver,receiverAvatar:ue.currentSessionItem.avatar,receiverName:ue.currentSessionItem.name})}function Ee(e,t){"reply"===e&&Le(t)}return $(le,(()=>{ke()}),"top",(()=>{fe.value=!1})),s((()=>ue.id),(e=>{e&&(ue.currentReferenceMsg=null,Object.assign(he,{page:0,hasMore:!0,lastSendTime:C(new Date,"yyyy-MM-dd HH:mm:ss")}),ke())}),{immediate:!0}),s((()=>ue.isAppendMsg),(e=>{e&&(me([...ue.msgList,ue.currentMsg]),async function(){var e,t,n;await h();const s=null!=(t=null==(e=le.value)?void 0:e.scrollHeight)?t:0;null==(n=le.value)||n.scrollTo({top:s,behavior:"auto"})}(),ue.isAppendMsg=!1)}),{immediate:!0}),(e,t)=>(o(),i("div",{class:r(["chat-main",{"home-bg":!a(ue).id}]),ref_key:"chatMainRef",ref:le,style:c(a(Te))},[l(a(T),{"show-toolbar-tooltip":"","render-toolbar":Me},{default:u((()=>[(o(!0),i(m,null,p(a(ue).msgList,((e,t)=>(o(),i(m,{key:e.id},[xe(e)?(o(),i("div",{key:0,class:r(["message-item",{"message-item--mine":e.sender==a(ue).userInfo.id}])},[je(e,t)?(o(),i("p",Q,d(e.__sendTime),1)):g("v-if",!0),Se(e,"system")?(o(),f(q,{key:1,data:e},null,8,["data"])):(o(),i("div",V,[l(P,{"user-id":e.sender,placement:e.sender==a(ue).userInfo.id?"left":"right"},{trigger:u((()=>[l(a(M),{round:"",size:38,src:e.senderAvatar},null,8,["src"])])),_:2},1032,["user-id","placement"]),e.content?(o(),i("div",W,[v("div",Z,[v("span",{class:"name","data-time":e.__time},d(a(de)?e.senderName:""),9,ee)]),v("div",{class:r(["content",{emoji:e.content.chatMessageType===a(z).EMOJI,template:e.content.chatMessageType===a(z).TEMPLATE,"template--3":Ce(e.content),"audio-video":a(A)(e.content),file:e.content.chatMessageType===a(z).FILE}]),onContextmenu:y((t=>_e(t,e.id)),["prevent"])},[we(e)?(o(),i(m,{key:0},[e.content.referenceContent?(o(),i("div",ne,[v("span",null,d(e.content.referenceContent.senderName)+":",1),v("pre",{innerHTML:a(H)(e.content.referenceContent.content)},null,8,se)])):g("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(B).findEmoji(e.__content)},null,10,oe)):(o(),i("pre",{key:2,innerHTML:e.__content},null,8,ie))],64)):g("v-if",!0),Ie(e)?(o(),i("pre",{key:1,innerHTML:e.__content},null,8,re)):g("v-if",!0),Se(e,"template")?(o(),f(q,{key:2,data:e},null,8,["data"])):g("v-if",!0),e.content.chatMessageType===a(z).IMAGE?(o(),f(a(k),{key:3,width:"240",src:e.__content},null,8,["src"])):g("v-if",!0),a(A)(e.content)?(o(),i(m,{key:4},[l(a(_),{class:r({"is-audio":e.content.chatMessageType===a(z).AUDIO}),component:e.content.chatMessageType===a(z).AUDIO?a(U):a(F)},null,8,["class","component"]),v("span",ae,d(a(O)(e.__content)),1)],64)):g("v-if",!0),e.content.chatMessageType===a(z).FILE?(o(),f(a(x),{key:5,"wrap-item":!1},{default:u((()=>[l(a(_),{class:"icon-file",size:"40",component:a(G)},null,8,["component"]),l(a(x),{"wrap-item":!1,vertical:"",justify:"space-between",style:{"row-gap":"0"}},{default:u((()=>[v("span",null,d(e.__content),1),v("span",ce,d(e.__size),1)])),_:2},1024)])),_:2},1024)):g("v-if",!0),l(a(w),{class:"quick-menu"},{default:u((()=>[a(A)(e.content)?g("v-if",!0):(o(),i(m,{key:0},[g(' <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(I),{quaternary:"",size:"tiny",onClick:()=>Le(e)},{icon:u((()=>[l(a(_),{size:"17",component:a(K)},null,8,["component"])])),_:2},1032,["onClick"])],64)),l(a(I),{quaternary:"",size:"tiny",onClick:t=>_e(t,e.id)},{icon:u((()=>[l(a(_),{size:"14",component:a(X)},null,8,["component"])])),_:2},1032,["onClick"])])),_:2},1024)],42,te)])):g("v-if",!0)]))],2)):g("v-if",!0)],64)))),128))])),_:1}),l(a(J),{ref_key:"contextmenuRef",ref:ge,show:fe.value,"onUpdate:show":t[0]||(t[0]=e=>fe.value=e),position:ve.value,"msg-id":ye.value,onSelect:Ee},null,8,["show","position","msg-id"])],6))}});export{le as default};
|
@@ -1 +1 @@
|
|
1
|
-
import{defineComponent as e,ref as t,computed as o,withDirectives as s,createVNode as i,vShow as n,isVNode as r}from"vue";import{NButtonGroup as a,NButton as l,NIcon as
|
1
|
+
import{defineComponent as e,ref as t,computed as o,withDirectives as s,createVNode as i,vShow as n,isVNode as r}from"vue";import{NButtonGroup as a,NButton as l,NIcon as c}from"naive-ui";import{CopyOutline as p,ChatbubbleEllipsesOutline as d,DownloadOutline as m}from"@vicons/ionicons5";import{onClickOutside as u}from"@vueuse/core";import{useState as f}from"../hooks/useState.js";import{isAudioOrVideoMessage as g,downloadFile as y}from"../utils/index.js";import"lodash-es";import{MESSAGE_TYPE as w}from"../constants/index.js";import"../api/index.js";import"trtc-sdk-v5";import{isSameMonth as h}from"date-fns";import{emojis as v}from"../utils/emoji.js";var E=e({name:"PopupMenu",inheritAttrs:!1,props:{show:{type:Boolean,default:!1},position:{type:Object},msgId:{type:String}},emits:["update:show","select"],setup(e,{attrs:E,slots:b,emit:T}){const{state:j,setMsgList:I}=f(),M=[{icon:p,label:"复制",key:"copy"},{icon:d,label:"回复",key:"reply"},{icon:m,label:"下载",key:"download"}],k=t(null),x=o((()=>j.msgList.find((({id:t})=>t===e.msgId)))),O=o((()=>{if(!e.msgId)return[];if(!(null==x?void 0:x.value))return[];const{content:t={},sendTime:o,sender:s}=x.value,{chatMessageType:i}=t,n=[];return(s!==j.userInfo.id&&h(new Date(o),new Date)||i===w.TEMPLATE)&&n.push("withdraw"),[w.TEXT,w.EMOJI,w.BLEND].includes(i)?n.push("download"):g(t)?n.push("copy","relay","reply","download"):i===w.FILE?n.push("copy"):[w.FORWARD,w.TEMPLATE].includes(i)&&n.push("copy","download"),n.length?M.filter((e=>!n.includes(e.key))):M}));return u(k,(e=>{T("update:show",!1)})),()=>{let t;return e.msgId&&O.value?s(i("div",{class:"contextmenu-wrapper",ref:k,style:e.position},[i(a,{vertical:!0},(o=t=O.value.map((e=>i(l,{onClick:()=>async function(e){T("update:show",!1);const{content:t={},sendTime:o,sender:s}=x.value||{},{chatMessageType:i}=t;switch(e){case"copy":if(!t.msg)return console.log("复制内容为空!");if(!navigator||!("clipboard"in navigator))return console.log("当前浏览器版本不支持复制!");try{if(i===w.TEXT)await navigator.clipboard.writeText(t.msg);else{let e;if([w.EMOJI,w.IMAGE].includes(i)){const o=i===w.EMOJI?v.findEmoji(t.msg):t.msg;e=`<img data-msg=${t.msg} data-type=${i} class=${i===w.EMOJI?"emoji--min":""} src=${o} />`}else e=t.msg;await navigator.clipboard.write([new window.ClipboardItem({"text/html":new Blob([e],{type:"text/html"})})])}}catch(e){console.log("复制失败!")}return;case"download":return void y(t.fileUrl,t.msg)}T("select",e,x.value)}(e.key),quaternary:!0},{default:()=>e.label,icon:()=>i(c,{component:e.icon},null)}))),"function"==typeof o||"[object Object]"===Object.prototype.toString.call(o)&&!r(o)?t:{default:()=>[t]}))]),[[n,e.show]]):null;var o}}});export{E as default};
|
@@ -1 +1 @@
|
|
1
|
-
import{isToday as e,format as t,isYesterday as n,startOfDay as r}from"date-fns";import{cloneDeep as o,isNumber as s,isNaN as
|
1
|
+
import{isToday as e,format as t,isYesterday as n,startOfDay as r}from"date-fns";import{cloneDeep as o,isNumber as s,isNaN as i,isArray as a}from"lodash-es";import{MESSAGE_TYPE as c}from"../constants/index.js";import{emojis as l}from"./emoji.js";import{uuidGenerator as u}from"../../../../shared/utils/index.js";function m(r){const o=new Date(r);let s,i;if(e(o))s=i=t(o,"HH:mm");else{s=n(o)?"昨天":t(o,"MM-dd");const e=o.getFullYear(),r=(new Date).getFullYear();i=t(o,e<r?"yyyy年M月d日 HH:mm":"M月d日 HH:mm")}return{siderMsgTime:s,msgTime:i,recordTime:function(r){const o=new Date(r),s=Date.now()-o.getTime();if(s<6e4)return"刚刚";if(s<36e5)return Math.ceil(s/1e3/60)+"分钟前";if(e(o))return"今天 "+t(o,"HH:mm");if(n(o))return"昨天 "+t(o,"HH:mm");{const e=o.getFullYear(),n=(new Date).getFullYear();return t(o,e<n?"yyyy年M月d日 HH:mm":"M月d日 HH:mm")}}(r)}}function d(e){return o(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 p(e){if(!(null==e?void 0:e.msg))return"";const{chatMessageType:t="",msg:n=""}=e;let r=n.toString();if(t===c.BLEND){const e=r.match(/\[([^\]]+)\]/g);return null==e||e.forEach((e=>{const n=e.match(/\[([^\]]+)\]/);if(n&&n.length>1){const o=l.findEmoji(n[1]);o&&(r=r.replace(e,`<img data-msg=${n[1]} data-type=${t} class="emoji--min" src=${o} />`))}})),r}const o=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(o(),"<$1 $2>").replace(o("/"),"</$1>").replace(/\n/g,"<br>"),r}function g(e){if(e&&s(+e)&&!i(+e)){const t=E(+e),n=t.split(":");let r=t;return 3===n.length&&"00"===n[0]&&(r=`${n[1]}:${n[2]}`),"通话时长 "+r}return"已取消"}function f(e){var t;if(!e)return"";const{chatMessageType:n,msg:r,messageTemplate:o}=e,s=y(e)?g(r):"";switch(n){case c.TEXT:return p(e);case c.IMAGE:return"[图片]";case c.FILE:return"[文件]";case c.EMOJI:return`<img class="emoji--min" alt=${r} src=${l.findEmoji(r)}>`;case c.TEMPLATE:return null==(t=null==o?void 0:o.setting)?void 0:t.title;case c.VIDEO:return`[视频通话]${s}`;case c.AUDIO:return`[语音通话]${s}`;default:return"[消息]"}}function h(e,t){const n=new XMLHttpRequest;n.open("GET",e,!0),n.responseType="blob",n.onload=function(r){if(200===n.status){const r=window.URL.createObjectURL(n.response),o=document.createElement("a");o.href=r,o.download=t,o.dispatchEvent(new MouseEvent("click")),window.URL.revokeObjectURL(e)}},n.send()}function w(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 o=+n;o>1048576?n=(o/1048576).toFixed(2)+"M":o>1024?n=(o/1024).toFixed(2)+"K":n+="B",t(n)}},r.send()}))}function H(e){const t=e.split(",");if(!a(t)||!t[0]||!t[1])return;const n=window.atob(t[1]);let r=n.length;const o=new Uint8Array(r);for(;r--;)o[r]=n.charCodeAt(r);return new File([o],u(),{type:"image/png"})}function y(e){return e&&[c.AUDIO,c.VIDEO].includes(e.chatMessageType)}function E(e){const n=r(new Date);return n.setSeconds(e),t(n,"HH:mm:ss")}export{H as base64ToFile,h as downloadFile,E as formatSeconds,m as formatTime,g as getAVTime,w as getFileSize,y as isAudioOrVideoMessage,d as listSort,f as simplifyMessage,p as transformMessage};
|