tjc-sdk
Version:
TIANJI IM SDK
2 lines (1 loc) • 709 B
JavaScript
import t from"./messageContent.js";import{MessageContentType as e}from"./messageContentType.js";import s from"../client/tjc.js";class r extends t{files=[];text="";constructor(t,s=""){super(e.MESSAGE_CONTENT_TYPE_MIX_FILE_TEXT),t&&t.length>10&&(t=t.slice(0,9)),this.files=t,this.text=s}digest(){return"[文件混排组合] "+this.text}encode(){let t=super.encode();t.searchableContent=this.text,this.files.forEach((t=>t.localPath=""));let e={mu:this.files},r=JSON.stringify(e);return t.binaryContent=s.utf8_to_b64(r),t}decode(t){if(super.decode(t),this.text=t.searchableContent,t.binaryContent&&t.binaryContent.length>0){let e=s.b64_to_utf8(t.binaryContent);this.files=JSON.parse(e).mu}}}export{r as default};