优化页面
This commit is contained in:
1
unpackage/dist/build/mp-weixin/TUIKit/components/TUIChat/utils/chatStorage.js
vendored
Normal file
1
unpackage/dist/build/mp-weixin/TUIKit/components/TUIChat/utils/chatStorage.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
"use strict";const t=require("../../../utils/env.js"),e=require("../../../../common/vendor.js"),a=class a{constructor(){this.chatStorage=null}static getInstance(){return a.instance||(a.instance=new a),a.instance}getChatStorage(t){if(this.chatStorage||(this.chatStorage=this.getChatStorageFromLocalStorage()),t)return this.chatStorage[t];throw new Error("No key provided")}setChatStorage(r,o){this.chatStorage||(this.chatStorage=this.getChatStorageFromLocalStorage()),this.chatStorage[r]=o;try{t.isUniFrameWork?e.i.setStorageSync(a.CHAT_STORAGE_KEY,JSON.stringify(this.chatStorage)):localStorage.setItem(a.CHAT_STORAGE_KEY,JSON.stringify(this.chatStorage))}catch(s){throw new Error("Fail to set chat storage")}}getChatStorageFromLocalStorage(){let r="";if(r=t.isUniFrameWork?e.i.getStorageSync(a.CHAT_STORAGE_KEY)||"":localStorage.getItem(a.CHAT_STORAGE_KEY)||"",!r)return{};try{this.chatStorage=JSON.parse(r)}catch(o){this.chatStorage={}}return this.chatStorage}};a.instance=null,a.CHAT_STORAGE_KEY="TUI_CHAT_STORAGE";const r=a.getInstance();exports.chatStorage=r;
|
||||
1
unpackage/dist/build/mp-weixin/TUIKit/components/TUIChat/utils/conversationDraft.js
vendored
Normal file
1
unpackage/dist/build/mp-weixin/TUIKit/components/TUIChat/utils/conversationDraft.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
"use strict";const e=require("../../../../common/vendor.js"),t=require("../emoji-config/index.js"),s=require("../../../utils/type-check.js"),a=class a{constructor(){this.quoteMessageMap=new Map}static getInstance(){return a.instance||(a.instance=new a),a.instance}setStore(t,s,a,o){var n,i;if(t&&(this.isEditorNotEmpty(s)||(null==(n=null==o?void 0:o.message)?void 0:n.ID))){let n={};(null==(i=null==o?void 0:o.message)?void 0:i.ID)&&(this.quoteMessageMap.set(o.message.ID,o.message),n={messageID:o.message.ID,type:o.type});const r={conversationID:t,draftInfo:{html:s,abstract:a,...n}};e.Xt.setConversationDraft(r),e.Jt.update(e.o.CHAT,"quoteMessage",{message:void 0,type:"quote"})}}getStore(t,a){const o=e.Jt.getConversationModel(t);if(o){if(o.conversationID&&o.draftText){const t=s.JSONToObject(o.draftText);e.Jt.update(e.o.CHAT,"quoteMessage",{message:this.quoteMessageMap.get(t.messageID)||void 0,type:t.type}),a(t.html)}e.Xt.setConversationDraft({conversationID:o.conversationID})}}generateAbstract(s){let a="";return null==s||s.forEach((s=>{switch(s.type){case"text":a+=t.transformTextWithKeysToEmojiNames(s.payload.text||"");break;case"image":a+=e.Wt.t("TUIChat.图片");break;case"video":a+=e.Wt.t("TUIChat.视频");break;case"file":a+=e.Wt.t("TUIChat.文件")}})),a}isEditorNotEmpty(e){return e&&!e.includes("is-empty")&&"<p></p>"!==e}};a.instance=null;const o=a.getInstance();exports.DraftManager=o;
|
||||
1
unpackage/dist/build/mp-weixin/TUIKit/components/TUIChat/utils/convertVoiceToText.js
vendored
Normal file
1
unpackage/dist/build/mp-weixin/TUIKit/components/TUIChat/utils/convertVoiceToText.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
"use strict";const e=require("../../../../common/vendor.js"),t=class t{constructor(){this.isUseCache=!0,this.convertCache=new Map}static getInstance(){return t.instance||(t.instance=new t),t.instance}async get(t){if(this.isUseCache){const e=this.convertCache.get(t.ID);if(void 0!==e)return e}const s=e.Jt.getMessageModel(t.ID);if(!s)return Promise.reject("message not found");const c=await e.Qt.convertVoiceToText({message:s});let{data:{result:n}={}}=c;return n?this.convertCache.set(s.ID,n):n="",n}clear(){this.convertCache.clear()}disableCache(){this.isUseCache=!1}enableCache(){this.isUseCache=!0}};t.instance=void 0;const s=t.getInstance();exports.convertor=s;
|
||||
1
unpackage/dist/build/mp-weixin/TUIKit/components/TUIChat/utils/sendMessage.js
vendored
Normal file
1
unpackage/dist/build/mp-weixin/TUIKit/components/TUIChat/utils/sendMessage.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
"use strict";const e=require("../../../../common/vendor.js"),a=require("../../common/Toast/index.js"),s=require("./utils.js"),t=require("../../../utils/enableSampleTaskStatus.js"),o=require("../offlinePushInfoManager/index.js"),l=require("../../common/Toast/type.js"),n=new Map([[3123,"文本包含本地审核拦截词"],[4004,"图片消息失败,无效的图片格式"],[4005,"文件消息失败,禁止发送违规封禁的文件"],[7004,"文件不存在,请检查文件路径是否正确"],[7005,"文件大小超出了限制,如果上传文件,最大限制是100MB"],[8001,"消息长度超出限制,消息长度不要超过12K"],[80001,"消息或者资料中文本存在敏感内容,发送失败"],[80004,"消息中图片存在敏感内容,发送失败"],[10017,"您已被禁止聊天"]]);exports.sendMessages=async(i,d)=>{e.Jt.getData(e.o.CHAT,"messageSource")&&e.Jt.update(e.o.CHAT,"messageSource",void 0),null==i||i.forEach((async i=>{var r,u,f,p,g,y,T;try{const a={to:(null==(r=null==d?void 0:d.groupProfile)?void 0:r.groupID)||(null==(u=null==d?void 0:d.userProfile)?void 0:u.userID),conversationType:null==d?void 0:d.type,payload:{},needReadReceipt:s.isEnabledMessageReadReceiptGlobal()};let l;const n={offlinePushInfo:{}},c={conversation:d,payload:i.payload,messageType:""};switch(null==i?void 0:i.type){case"text":if(l=JSON.parse(JSON.stringify(null==(f=i.payload)?void 0:f.text)),!l)break;a.payload={text:l},c.messageType=e.qt.TYPES.MSG_TEXT,n.offlinePushInfo=o.OfflinePushInfoManager.create(c),(null==(p=i.payload)?void 0:p.atUserList)?(a.payload.atUserList=i.payload.atUserList,await e.Qt.sendTextAtMessage(a,n)):await e.Qt.sendTextMessage(a,n);break;case"image":a.payload={file:null==(g=i.payload)?void 0:g.file},c.messageType=e.qt.TYPES.MSG_IMAGE,n.offlinePushInfo=o.OfflinePushInfoManager.create(c),await e.Qt.sendImageMessage(a,n);break;case"video":a.payload={file:null==(y=i.payload)?void 0:y.file},c.messageType=e.qt.TYPES.MSG_VIDEO,n.offlinePushInfo=o.OfflinePushInfoManager.create(c),await e.Qt.sendVideoMessage(a,n);break;case"file":a.payload={file:null==(T=i.payload)?void 0:T.file},c.messageType=e.qt.TYPES.MSG_FILE,n.offlinePushInfo=o.OfflinePushInfoManager.create(c),await e.Qt.sendFileMessage(a,n)}t.enableSampleTaskStatus("sendMessage")}catch(c){a.Toast({message:n.get(null==c?void 0:c.code)?e.Wt.t(`TUIChat.${n.get(c.code)}`):null==c?void 0:c.message,type:l.TOAST_TYPE.ERROR}),e.Jt.getData(e.o.CHAT,"quoteMessage")&&e.Jt.update(e.o.CHAT,"quoteMessage",{})}}))},exports.sendTyping=(a,s)=>{a||s?e.Qt.leaveTypingState():e.Qt.enterTypingState()};
|
||||
1
unpackage/dist/build/mp-weixin/TUIKit/components/TUIChat/utils/translation.js
vendored
Normal file
1
unpackage/dist/build/mp-weixin/TUIKit/components/TUIChat/utils/translation.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
"use strict";const t=require("../../../../common/vendor.js"),e=class e{constructor(){this.isUseCache=!0,this.translationCache=new Map}static getInstance(){return e.instance||(e.instance=new e),e.instance}async get(e){if(this.isUseCache){const t=this.translationCache.get(e.ID);if(void 0!==t)return t}const s=t.Jt.getMessageModel(e.ID);if(!s)return[];const{text:n}=s.getMessageContent()||{},a=[],i=await this.getNickList(s);for(let t=0;t<n.length;++t){const e=n[t];if("img"===e.name){a.push({type:"face",value:e.src});continue}const{transSplitingList:s,atNickList:r}=this.getSplitResult(e.text,i);for(let t=0;t<s.length;++t)a.push({type:"text",value:s[t]}),t<r.length&&a.push({type:"mention",value:r[t]})}const r=[],c=a.filter(((t,e)=>"text"===t.type&&""!==t.value.trim()&&(r.push(e),!0))).map((t=>t.value));if(0===c.length)return this.translationCache.set(s.ID,a),a;return(await this.getTranslationStandard(c)).forEach(((t,e)=>{a[r[e]].value=t})),this.translationCache.set(s.ID,a),a}clear(){this.translationCache.clear()}disableCache(){this.isUseCache=!1}enableCache(){this.isUseCache=!0}getTranslationStandard(e){return new Promise(((s,n)=>{t.Qt.translateText({sourceTextList:e,sourceLanguage:"auto"}).then((t=>{const{data:{translatedTextList:e}}=t;s(e)})).catch((t=>{n(t)}))}))}async getNickList(e){const s=[],{atUserList:n=[]}=e,a=t.qt.TYPES.MSG_AT_ALL;if(n.includes(a)&&s.push(`@${t.Wt.t("TUIChat.所有人")}`),n.length>0){const{data:e}=await t.Zt.getUserProfile({userIDList:n});e.forEach((t=>{const e=`@${t.nick||t.userID}`;s.push(e)}))}return[...new Set(s)]}getSplitResult(t,e){let s=0;const n=[],a=[];for(;s<t.length;){const i=t.indexOf("@",s);if(-1===i){n.push(t.substring(s));break}let r=!1;for(let c=0;c<e.length;++c){const h=t.indexOf(e[c],i);if(-1!==h&&h===i){n.push(t.substring(s,h)),a.push(e[c]),s=h+e[c].length,r=!0;break}}if(!r){n.push(t.substring(s));break}}return{transSplitingList:n,atNickList:a}}};e.instance=void 0;const s=e.getInstance();exports.translator=s;
|
||||
1
unpackage/dist/build/mp-weixin/TUIKit/components/TUIChat/utils/utils.js
vendored
Normal file
1
unpackage/dist/build/mp-weixin/TUIKit/components/TUIChat/utils/utils.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
"use strict";const e=require("../../../../common/vendor.js");exports.calculateTimestamp=function(t){const n=(new Date).setHours(0,0,0,0),s=new Date((new Date).getFullYear(),0,1,0,0,0,0).getTime(),r=new Date(t),o=864e5,a=n-r.getTime();function u(e){return e<10?"0"+e:e.toString()}if(a<=0)return`${u(r.getHours())}:${u(r.getMinutes())}`;if(a<=o)return`${e.Wt.t("time.昨天")} ${u(r.getHours())}:${u(r.getMinutes())}`;if(a<=5184e5){const t=["星期日","星期一","星期二","星期三","星期四","星期五","星期六"][r.getDay()];return`${e.Wt.t("time."+t)} ${u(r.getHours())}:${u(r.getMinutes())}`}return r.getTime()>=s?`${r.getMonth()+1}/${r.getDate()} ${u(r.getHours())}:${u(r.getMinutes())}`:`${r.getFullYear()}/${r.getMonth()+1}/${r.getDate()} ${u(r.getHours())}:${u(r.getMinutes())}`},exports.deepCopy=function e(t,n=new WeakMap){if("object"!=typeof t||null==t)return t;if(n.has(t))return n.get(t);const s=Object.create(Object.getPrototypeOf(t));return Object.keys(t).forEach((r=>{const o=t[r];"object"!=typeof o||null===o?s[r]=o:Array.isArray(o)?s[r]=[...o]:o instanceof Set?s[r]=new Set([...o]):o instanceof Map?s[r]=new Map([...o]):(n.set(t,t),s[r]=e(o,n))})),s},exports.isCreateGroupCustomMessage=t=>{var n;return t.type===e.qt.TYPES.MSG_CUSTOM&&"group_create"===(null==(n=null==t?void 0:t.getMessageContent())?void 0:n.businessID)},exports.isEnabledMessageReadReceiptGlobal=function(){return e.Jt.getData(e.o.USER,"displayMessageReadReceipt")&&e.Jt.getData(e.o.APP,"enabledMessageReadReceipt")},exports.shallowCopyMessage=function(e){return Object.assign({},e)};
|
||||
1
unpackage/dist/build/mp-weixin/TUIKit/components/TUIChat/utils/wordsList.js
vendored
Normal file
1
unpackage/dist/build/mp-weixin/TUIKit/components/TUIChat/utils/wordsList.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
"use strict";exports.wordsList=[{value:"在吗?在吗?在吗?重要的话说三遍。"},{value:"好久没聊天了,快来和我说说话~"},{value:"好的,就这么说定了。"},{value:"感恩的心,感谢有你。"},{value:"糟糕!是心动的感觉!"},{value:"心疼地抱抱自己,我太难了!"},{value:"没关系,别在意,事情过去就过去了。"},{value:"早上好,今天也是让人期待的一天呢!"},{value:"熬夜有什么用,又没人陪你聊天,早点休息吧。"}];
|
||||
Reference in New Issue
Block a user