2 lines
4.9 KiB
JavaScript
2 lines
4.9 KiB
JavaScript
import{i as b,V as D}from"./element-plus-lurTijPg.js";import{q as O}from"./@vue/runtime-dom-DDAG46FW.js";import{T as d}from"./trtc-sdk-v5-D4DbeRqz.js";import{a5 as S}from"./tcm-Cjb9ca7N.js";import{f as x,w as W,ak as y,G as P,aN as E,I as _,H as U,aP as $,J as h,a as j,O as H,A as Y}from"./@vue/runtime-core-C6bnekPw.js";import{Q as q}from"./@vue/shared-mAAVTE9n.js";import{n as v}from"./@vue/reactivity-DiY1c2vO.js";import{_ as G}from"./index-Cr_vnZ4Y.js";import"./@element-plus/icons-vue-HOEUG8sr.js";import"./lodash-es-C2A-Pj28.js";import"./@popperjs/core-C5az9QE8.js";import"./dayjs-DG77mNTn.js";import"./lodash-D3kF6u-c.js";import"./@ctrl/tinycolor-BuyEbX8F.js";import"./async-validator-CFA_igpM.js";import"./normalize-wheel-es-BQoi3Ox2.js";import"./jspdf-BsthCvR5.js";import"./@babel/runtime-BanGtE2-.js";import"./fflate-_ayOYiT1.js";import"./vue-router-QlpZ4wdW.js";import"./pinia-B8cvXbiZ.js";import"./axios-C80V62Fs.js";import"./@vueuse/core-1S4fJlii.js";import"./@vueuse/shared-Cl3lVqjz.js";import"./css-color-function-DI01JAaZ.js";import"./balanced-match-BdS7OldZ.js";import"./color-B2zxaWkI.js";import"./clone-DBZ6_OiU.js";import"./color-convert-OrFsTA_V.js";import"./color-name-Dju3oUBS.js";import"./color-string-pUQDDJII.js";import"./ms-CzQ2E3wO.js";import"./vue-clipboard3-DByT_rEQ.js";import"./clipboard-CHgxszqY.js";import"./echarts-CNLwa9wG.js";import"./tslib-BDyQ-Jie.js";import"./zrender-DRNXw7y3.js";import"./highlight.js-Bxt7hFFy.js";import"./@highlightjs/vue-plugin-C4onkBvW.js";const J={key:0,class:"watch-state"},K={key:1,class:"watch-state watch-error"},Q=x({__name:"AssistantWatchCallDialog",props:{modelValue:{type:Boolean},diagnosisId:{}},emits:["update:modelValue","closed"],setup(A,{emit:R}){const c=A,w=R,I=Y({get:()=>c.modelValue,set:e=>w("update:modelValue",e)}),s=v(null),l=v(!1),i=v(""),p=v("旁观视频通话"),n=new Map;let o=null,f=0;function g(e,t){return`${e}\0${String(t)}`}function N(e){return e.startsWith("patient_")?"患者":e.startsWith("doctor_")?"医护":e}async function V(e){if(!o||!s.value||e.streamType!==d.TYPE.STREAM_TYPE_MAIN)return;const t=g(e.userId,e.streamType);if(n.has(t))return;const a=document.createElement("div");a.className="watch-tile";const r=document.createElement("div");r.className="watch-tile-cap",r.textContent=N(e.userId);const m=document.createElement("div");m.className="watch-tile-view",a.appendChild(r),a.appendChild(m),s.value.appendChild(a),n.set(t,{wrap:a,userId:e.userId,streamType:e.streamType});try{await o.startRemoteVideo({userId:e.userId,streamType:e.streamType,view:m})}catch(M){console.warn("[AssistantWatchCall] startRemoteVideo",M)}}async function T(e){if(!o)return;const t=g(e.userId,e.streamType),a=n.get(t);if(a){try{await o.stopRemoteVideo({userId:e.userId,streamType:e.streamType})}catch{}a.wrap.remove(),n.delete(t)}}function C(){o&&(o.on(d.EVENT.REMOTE_VIDEO_AVAILABLE,V),o.on(d.EVENT.REMOTE_VIDEO_UNAVAILABLE,T))}function k(){o&&(o.off(d.EVENT.REMOTE_VIDEO_AVAILABLE,V),o.off(d.EVENT.REMOTE_VIDEO_UNAVAILABLE,T))}async function u(){if(k(),o){for(const[,e]of n){try{await o.stopRemoteVideo({userId:e.userId,streamType:e.streamType})}catch{}e.wrap.remove()}n.clear(),s.value&&(s.value.innerHTML="");try{await o.exitRoom()}catch{}try{o.destroy()}catch{}o=null}else n.clear(),s.value&&(s.value.innerHTML="")}async function L(){const e=++f;if(await u(),!c.diagnosisId){i.value="诊单无效";return}l.value=!0,i.value="",p.value="旁观视频通话";try{const t=await S({diagnosis_id:c.diagnosisId});if(e!==f)return;t.patientName&&(p.value=`旁观视频通话 · ${t.patientName}`),o=d.create(),C();const a={sdkAppId:t.sdkAppId,userId:t.userId,userSig:t.userSig,autoReceiveAudio:!0,autoReceiveVideo:!0,...t.roomId!=null&&t.roomId>0?{roomId:t.roomId}:{strRoomId:t.strRoomId}};if(!(t.roomId!=null&&t.roomId>0)&&!t.strRoomId)throw new Error("缺少房间号");if(await o.enterRoom(a),e!==f){await u();return}l.value=!1}catch(t){l.value=!1;let a="进入房间失败";if(typeof t=="string")a=t;else if(t&&typeof t=="object"){const r=t;r.msg?a=String(r.msg):r.message&&(a=String(r.message))}i.value=a,await u()}}function B(){u(),l.value=!1,i.value="",p.value="旁观视频通话",w("closed")}return W(()=>[c.modelValue,c.diagnosisId],([e,t])=>{if(!e){f++,u();return}t>0&&L()}),(e,t)=>{const a=b,r=D;return y(),P(r,{modelValue:I.value,"onUpdate:modelValue":t[1]||(t[1]=m=>I.value=m),title:p.value,width:"760px","destroy-on-close":"","append-to-body":"","close-on-click-modal":!1,class:"assistant-watch-call-dialog",onClosed:B},{footer:E(()=>[t[3]||(t[3]=h("span",{class:"watch-hint"},"仅观看,不会开启摄像头与麦克风",-1)),j(a,{type:"primary",onClick:t[0]||(t[0]=m=>I.value=!1)},{default:E(()=>[...t[2]||(t[2]=[H("离开",-1)])]),_:1})]),default:E(()=>[l.value?(y(),_("div",J,"正在连接房间…")):i.value?(y(),_("div",K,q(i.value),1)):U("",!0),$(h("div",{ref_key:"gridRef",ref:s,class:"watch-grid"},null,512),[[O,!l.value&&!i.value]])]),_:1},8,["modelValue","title"])}}}),Ot=G(Q,[["__scopeId","data-v-7aff665d"]]);export{Ot as default};
|