2 lines
2.8 KiB
JavaScript
2 lines
2.8 KiB
JavaScript
"use strict";const e=require("../../../../common/vendor.js");require("../../../adapter-vue.js");const n=require("../../../../common/assets.js"),o=require("../../common/Toast/index.js"),t=require("../../../utils/lodash.js"),u=require("../utils/utils.js"),i=require("../../common/Toast/type.js");Math||a();const a=()=>"../../common/Icon.js",r=e.defineComponent({__name:"message-input-audio",props:{isEnableAudio:{type:Boolean,default:!1}},emits:["changeDisplayType"],setup(a,{emit:r}){var l;const s=r,c=a;let d,f=0,v=!1,p=-1,m=!1,h=!1;const g=null==(l=e.i)?void 0:l.getRecorderManager(),T=e.ref(!1),y=e.ref("按住说话"),I=e.ref("正在录音"),j=e.ref(!1),C=e.ref(),E={duration:6e4,sampleRate:44100,numberOfChannels:1,encodeBitRate:192e3,format:"mp3"};function b(){s("changeDisplayType",c.isEnableAudio?"editor":"audio")}function A(e){C.value=e}function R(){q(),$()}function $(){T.value=!1,y.value="按住说话",I.value="正在录音"}function q(e){clearInterval(d),d=void 0,f=0,p=-1,v=!1,(null==e?void 0:e.hasError)||g.stop()}function S(){m&&(h=!0)}function _(){m=!0,g.start(E)}e.onMounted((()=>{g.onStart(z),g.onStop(O),g.onError(P),e.Jt.watch(e.o.CONV,{currentConversation:A})})),e.onUnmounted((()=>{e.Jt.unwatch(e.o.CONV,{currentConversation:A})}));const M=t.throttle((function(e){if(T.value){const n=e.changedTouches[e.changedTouches.length-1].pageY;p<0&&(p=n);const o=p-n;o>150?(y.value="抬起取消",I.value="松开手指 取消发送",v=!0):o>50?(y.value="抬起发送",I.value="继续上滑可取消",v=!1):(y.value="抬起发送",I.value="正在录音",v=!1)}}),100);function x(){m=!1,g.stop()}function z(){if(!m)return h=!0,void g.stop();d=setInterval((()=>{f+=1}),1e3),y.value="抬起发送",T.value=!0}function O(n){var t,a,r,l,s,c;if(h)return h=!1,void R();if(v||!T.value)return void R();clearInterval(d);const p=n.tempFilePath,m=n.duration?n.duration:1e3*f,g=n.fileSize?n.fileSize:48*f/8*1024;if(m<1e3)o.Toast({message:"录音时间太短",type:i.TOAST_TYPE.NORMAL,duration:1500});else{const n={to:(null==(a=null==(t=null==C?void 0:C.value)?void 0:t.groupProfile)?void 0:a.groupID)||(null==(l=null==(r=null==C?void 0:C.value)?void 0:r.userProfile)?void 0:l.userID),conversationType:null==(s=null==C?void 0:C.value)?void 0:s.type,payload:{file:{duration:m,tempFilePath:p,fileSize:g}},needReadReceipt:u.isEnabledMessageReadReceiptGlobal()};null==(c=e.Qt)||c.sendAudioMessage(n)}R()}function P(){q({hasError:!0}),$()}return(o,t)=>e.e({a:e.o$1(b),b:e.p({file:e.unref(n.audioIcon$1),size:"23px",hotAreaSize:"3px"}),c:c.isEnableAudio},c.isEnableAudio?e.e({d:e.t(e.unref(e.Wt).t(`TUIChat.${e.unref(y)}`)),e:e.unref(T)},e.unref(T)?{f:e.t(e.unref(e.Wt).t(`TUIChat.${e.unref(I)}`))}:{},{g:e.o$1(S),h:e.o$1(_),i:e.o$1(((...n)=>e.unref(M)&&e.unref(M)(...n))),j:e.o$1(x)}):{},{k:e.unref(j)?1:""})}}),l=e._export_sfc(r,[["__scopeId","data-v-fc536242"]]);wx.createComponent(l);
|