untis.js 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272
  1. "use strict";
  2. var __defProp = Object.defineProperty;
  3. var __getOwnPropSymbols = Object.getOwnPropertySymbols;
  4. var __hasOwnProp = Object.prototype.hasOwnProperty;
  5. var __propIsEnum = Object.prototype.propertyIsEnumerable;
  6. var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
  7. var __spreadValues = (a, b) => {
  8. for (var prop in b || (b = {}))
  9. if (__hasOwnProp.call(b, prop))
  10. __defNormalProp(a, prop, b[prop]);
  11. if (__getOwnPropSymbols)
  12. for (var prop of __getOwnPropSymbols(b)) {
  13. if (__propIsEnum.call(b, prop))
  14. __defNormalProp(a, prop, b[prop]);
  15. }
  16. return a;
  17. };
  18. var common_vendor = require("../../../common/vendor.js");
  19. var pages_TUIKit_utils_date = require("./date.js");
  20. var pages_TUIKit_utils_decodeText = require("./decodeText.js");
  21. var pages_TUIKit_utils_emojiMap = require("./emojiMap.js");
  22. function handleTipMessageShowContext(message) {
  23. const options = {
  24. message,
  25. text: ""
  26. };
  27. const userName = message.nick || message.payload.userIDList.join(",");
  28. switch (message.payload.operationType) {
  29. case common_vendor.index.$TIM.TYPES.GRP_TIP_MBR_JOIN:
  30. options.text = `\u7FA4\u6210\u5458\uFF1A${userName} \u52A0\u5165\u7FA4\u7EC4`;
  31. break;
  32. case common_vendor.index.$TIM.TYPES.GRP_TIP_MBR_QUIT:
  33. options.text = `\u7FA4\u6210\u5458\uFF1A${userName} \u9000\u51FA\u7FA4\u7EC4`;
  34. break;
  35. case common_vendor.index.$TIM.TYPES.GRP_TIP_MBR_KICKED_OUT:
  36. options.text = `\u7FA4\u6210\u5458\uFF1A${userName} \u88AB ${message.payload.operatorID} \u8E22\u51FA\u7FA4\u7EC4`;
  37. break;
  38. case common_vendor.index.$TIM.TYPES.GRP_TIP_MBR_SET_ADMIN:
  39. options.text = `\u7FA4\u6210\u5458\uFF1A${userName} \u6210\u4E3A\u7BA1\u7406\u5458`;
  40. break;
  41. case common_vendor.index.$TIM.TYPES.GRP_TIP_MBR_CANCELED_ADMIN:
  42. options.text = `\u7FA4\u6210\u5458\uFF1A${userName} \u88AB\u64A4\u9500\u7BA1\u7406\u5458`;
  43. break;
  44. case common_vendor.index.$TIM.TYPES.GRP_TIP_GRP_PROFILE_UPDATED:
  45. options.text = handleTipGrpUpdated(message);
  46. break;
  47. case common_vendor.index.$TIM.TYPES.GRP_TIP_MBR_PROFILE_UPDATED:
  48. for (const member of message.payload.memberList) {
  49. if (member.muteTime > 0) {
  50. options.text = `\u7FA4\u6210\u5458\uFF1A${member.userID} \u88AB\u7981\u8A00`;
  51. } else {
  52. options.text = `\u7FA4\u6210\u5458\uFF1A${member.userID} \u88AB\u53D6\u6D88\u7981\u8A00`;
  53. }
  54. }
  55. break;
  56. default:
  57. options.text = `[\u7FA4\u63D0\u793A\u6D88\u606F]`;
  58. break;
  59. }
  60. return options;
  61. }
  62. function handleTipGrpUpdated(message) {
  63. const { payload } = message;
  64. const { newGroupProfile } = payload;
  65. const { operatorID } = payload;
  66. let text = "";
  67. const name = Object.keys(newGroupProfile)[0];
  68. switch (name) {
  69. case "ownerID":
  70. text = `${newGroupProfile[name]} \u6210\u4E3A\u65B0\u7684\u7FA4\u4E3B`;
  71. break;
  72. case "groupName":
  73. text = `${operatorID} \u4FEE\u6539\u7FA4\u540D\u4E3A ${newGroupProfile[name]}`;
  74. break;
  75. case "notification":
  76. text = `${operatorID} \u53D1\u5E03\u65B0\u516C\u544A`;
  77. break;
  78. }
  79. return text;
  80. }
  81. function handleTextMessageShowContext(item) {
  82. const options = {
  83. text: pages_TUIKit_utils_decodeText.decodeText(item.payload)
  84. };
  85. return options;
  86. }
  87. function handleFaceMessageShowContext(item) {
  88. const face = {
  89. message: item,
  90. name: "",
  91. url: ""
  92. };
  93. const currentEmojiList = pages_TUIKit_utils_emojiMap.bigEmojiList.filter((emoItem) => emoItem.icon === item.payload.data);
  94. if (currentEmojiList.length > 0) {
  95. face.name = currentEmojiList[0].list[item.payload.index];
  96. }
  97. if (item.payload.data.indexOf("@2x") > 0) {
  98. face.name = item.payload.data;
  99. } else {
  100. face.name = `${item.payload.data}@2x`;
  101. }
  102. face.url = `https://web.sdk.qcloud.com/im/assets/face-elem/${face.name}.png`;
  103. return face;
  104. }
  105. function handleLocationMessageShowContext(item) {
  106. const location = {
  107. lon: "",
  108. lat: "",
  109. href: "",
  110. url: "",
  111. description: "",
  112. message: item
  113. };
  114. location.lon = item.payload.longitude.toFixed(6);
  115. location.lat = item.payload.latitude.toFixed(6);
  116. location.href = `https://map.qq.com/?type=marker&isopeninfowin=1&markertype=1&pointx=${location.lon}&pointy=${location.lat}&name=${item.payload.description}`;
  117. location.url = `https://apis.map.qq.com/ws/staticmap/v2/?center=${location.lat},${location.lon}&zoom=10&size=300*150&maptype=roadmap&markers=size:large|color:0xFFCCFF|label:k|${location.lat},${location.lon}&key=UBNBZ-PTP3P-TE7DB-LHRTI-Y4YLE-VWBBD`;
  118. location.description = item.payload.description;
  119. return location;
  120. }
  121. function handleImageMessageShowContext(item) {
  122. return {
  123. progress: (item == null ? void 0 : item.status) === "unSend" && item.progress,
  124. info: item.payload.imageInfoArray,
  125. message: item
  126. };
  127. }
  128. function handleVideoMessageShowContext(item) {
  129. var _a, _b;
  130. return {
  131. progress: (item == null ? void 0 : item.status) === "unSend" && (item == null ? void 0 : item.progress),
  132. url: (_a = item == null ? void 0 : item.payload) == null ? void 0 : _a.videoUrl,
  133. snapshotUrl: (_b = item == null ? void 0 : item.payload) == null ? void 0 : _b.snapshotUrl,
  134. message: item
  135. };
  136. }
  137. function handleAudioMessageShowContext(item) {
  138. return {
  139. progress: (item == null ? void 0 : item.status) === "unSend" && item.progress,
  140. url: item.payload.url,
  141. message: item,
  142. second: item.payload.second
  143. };
  144. }
  145. function handleFileMessageShowContext(item) {
  146. let size = "";
  147. if (item.payload.fileSize >= 1024 * 1024) {
  148. size = `${(item.payload.fileSize / (1024 * 1024)).toFixed(2)} Mb`;
  149. } else if (item.payload.fileSize >= 1024) {
  150. size = `${(item.payload.fileSize / 1024).toFixed(2)} Kb`;
  151. } else {
  152. size = `${item.payload.fileSize.toFixed(2)}B`;
  153. }
  154. return {
  155. progress: (item == null ? void 0 : item.status) === "unSend" && item.progress,
  156. url: item.payload.fileUrl,
  157. message: item,
  158. name: item.payload.fileName,
  159. size
  160. };
  161. }
  162. function handleMergerMessageShowContext(item) {
  163. return __spreadValues({ message: item }, item.payload);
  164. }
  165. function extractCallingInfoFromMessage(message) {
  166. let callingmessage = {};
  167. let objectData = {};
  168. try {
  169. callingmessage = JSON.parse(message.payload.data);
  170. } catch (error) {
  171. callingmessage = {};
  172. }
  173. if (callingmessage.businessID !== 1) {
  174. return "";
  175. }
  176. try {
  177. objectData = JSON.parse(callingmessage.data);
  178. } catch (error) {
  179. objectData = {};
  180. }
  181. switch (callingmessage.actionType) {
  182. case 1: {
  183. if (objectData.call_end >= 0 && !callingmessage.groupID) {
  184. return `\u901A\u8BDD\u65F6\u957F \uFF1A${pages_TUIKit_utils_date.formatTime(objectData.call_end)}`;
  185. }
  186. if (callingmessage.groupID) {
  187. return `\u7ED3\u675F\u7FA4\u804A`;
  188. }
  189. if (objectData.data && objectData.data.cmd === "switchToAudio") {
  190. return `\u5207\u6362\u8BED\u97F3\u901A\u8BDD`;
  191. }
  192. if (objectData.data && objectData.data.cmd === "switchToVideo") {
  193. return `\u5207\u6362\u89C6\u9891\u901A\u8BDD`;
  194. }
  195. return `\u53D1\u8D77\u901A\u8BDD`;
  196. }
  197. case 2:
  198. return `\u53D6\u6D88\u901A\u8BDD`;
  199. case 3:
  200. if (objectData.data && objectData.data.cmd === "switchToAudio") {
  201. return `\u5207\u6362\u8BED\u97F3\u901A\u8BDD`;
  202. }
  203. if (objectData.data && objectData.data.cmd === "switchToVideo") {
  204. return `\u5207\u6362\u89C6\u9891\u901A\u8BDD`;
  205. }
  206. return `\u5DF2\u63A5\u542C`;
  207. case 4:
  208. return `\u62D2\u7EDD\u901A\u8BDD`;
  209. case 5:
  210. if (objectData.data && objectData.data.cmd === "switchToAudio") {
  211. return `\u5207\u6362\u8BED\u97F3\u901A\u8BDD`;
  212. }
  213. if (objectData.data && objectData.data.cmd === "switchToVideo") {
  214. return `\u5207\u6362\u89C6\u9891\u901A\u8BDD`;
  215. }
  216. return `\u65E0\u5E94\u7B54`;
  217. default:
  218. return "";
  219. }
  220. }
  221. function handleCustomMessageShowContext(item) {
  222. var _a;
  223. return {
  224. message: item,
  225. custom: extractCallingInfoFromMessage(item) || ((_a = item == null ? void 0 : item.payload) == null ? void 0 : _a.extension) || `[\u81EA\u5B9A\u4E49\u6D88\u606F]`
  226. };
  227. }
  228. function translateGroupSystemNotice(message) {
  229. var _a, _b;
  230. const groupName = ((_a = message.payload.groupProfile) == null ? void 0 : _a.name) || ((_b = message.payload.groupProfile) == null ? void 0 : _b.groupID);
  231. switch (message.payload.operationType) {
  232. case 1:
  233. return `${message.payload.operatorID} \u7533\u8BF7\u52A0\u5165\u7FA4\u7EC4\uFF1A${groupName}`;
  234. case 2:
  235. return `\u6210\u529F\u52A0\u5165\u7FA4\u7EC4\uFF1A${groupName}`;
  236. case 3:
  237. return `\u7533\u8BF7\u52A0\u5165\u7FA4\u7EC4\uFF1A${groupName} \u88AB\u62D2\u7EDD`;
  238. case 4:
  239. return `\u4F60\u88AB\u7BA1\u7406\u5458 ${message.payload.operatorID} \u8E22\u51FA\u7FA4\u7EC4\uFF1A${groupName}`;
  240. case 5:
  241. return `\u7FA4\uFF1A${groupName} \u88AB ${message.payload.operatorID} \u89E3\u6563`;
  242. case 6:
  243. return `${message.payload.operatorID} \u521B\u5EFA\u7FA4\uFF1A${groupName}`;
  244. case 7:
  245. return `${message.payload.operatorID} \u9080\u8BF7\u4F60\u52A0\u7FA4\uFF1A${groupName}`;
  246. case 8:
  247. return `\u4F60\u9000\u51FA\u7FA4\u7EC4\uFF1A${groupName}`;
  248. case 9:
  249. return `\u4F60\u88AB${message.payload.operatorID} \u8BBE\u7F6E\u4E3A\u7FA4\uFF1A${groupName} \u7684\u7BA1\u7406\u5458`;
  250. case 10:
  251. return `\u4F60\u88AB ${message.payload.operatorID} \u64A4\u9500\u7FA4\uFF1A${groupName} \u7684\u7BA1\u7406\u5458\u8EAB\u4EFD`;
  252. case 12:
  253. return `${message.payload.operatorID} \u9080\u8BF7\u4F60\u52A0\u7FA4\uFF1A${groupName}`;
  254. case 13:
  255. return `${message.payload.operatorID} \u540C\u610F\u52A0\u7FA4 \uFF1A${groupName}`;
  256. case 14:
  257. return `${message.payload.operatorID} \u62D2\u63A5\u52A0\u7FA4 \uFF1A${groupName}`;
  258. case 255:
  259. return `\u81EA\u5B9A\u4E49\u7FA4\u7CFB\u7EDF\u901A\u77E5: ${message.payload.userDefinedField}`;
  260. }
  261. }
  262. exports.handleAudioMessageShowContext = handleAudioMessageShowContext;
  263. exports.handleCustomMessageShowContext = handleCustomMessageShowContext;
  264. exports.handleFaceMessageShowContext = handleFaceMessageShowContext;
  265. exports.handleFileMessageShowContext = handleFileMessageShowContext;
  266. exports.handleImageMessageShowContext = handleImageMessageShowContext;
  267. exports.handleLocationMessageShowContext = handleLocationMessageShowContext;
  268. exports.handleMergerMessageShowContext = handleMergerMessageShowContext;
  269. exports.handleTextMessageShowContext = handleTextMessageShowContext;
  270. exports.handleTipMessageShowContext = handleTipMessageShowContext;
  271. exports.handleVideoMessageShowContext = handleVideoMessageShowContext;
  272. exports.translateGroupSystemNotice = translateGroupSystemNotice;