Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

vor 2 Jahren
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234
  1. // import Strophe from "../sdk/libs/strophe";
  2. //import xmldom from "../sdk/libs/xmldom/dom-parser";
  3. // import websdk from "../sdk/sdk/src/connection";
  4. import websdk from "../sdk/webimSDK3.1.1.js";
  5. import config from "./WebIMConfig";
  6. console.group = console.group || {};
  7. console.groupEnd = console.groupEnd || {};
  8. var window = {};
  9. let WebIM = window.WebIM = websdk;
  10. window.WebIM.config = config; //var DOMParser = window.DOMParser = xmldom.DOMParser;
  11. //let document = window.document = new DOMParser().parseFromString("<?xml version='1.0'?>\n", "text/xml");
  12. WebIM.isDebug = function (option) {
  13. if (option) {
  14. WebIM.config.isDebug = option.isDebug;
  15. openDebug(WebIM.config.isDebug);
  16. }
  17. function openDebug(value) {
  18. function ts() {
  19. var d = new Date();
  20. var Hours = d.getHours(); // 获取当前小时数(0-23)
  21. var Minutes = d.getMinutes(); // 获取当前分钟数(0-59)
  22. var Seconds = d.getSeconds(); // 获取当前秒数(0-59)
  23. return (Hours < 10 ? "0" + Hours : Hours) + ":" + (Minutes < 10 ? "0" + Minutes : Minutes) + ":" + (Seconds < 10 ? "0" + Seconds : Seconds) + " ";
  24. } // if (value) {
  25. // Strophe.Strophe.Connection.prototype.rawOutput = function(data){
  26. // try{
  27. // console.group("%csend # " + ts(), "color: blue; font-size: large");
  28. // console.log("%c" + data, "color: blue");
  29. // console.groupEnd();
  30. // }
  31. // catch(e){
  32. // console.log(e);
  33. // }
  34. // };
  35. // }else{
  36. // Strophe.Strophe.Connection.prototype.rawOutput = function(){};
  37. // }
  38. }
  39. };
  40. /**
  41. * Set autoSignIn as true (autoSignInName and autoSignInPwd are configured below),
  42. * You can auto signed in each time when you refresh the page in dev model.
  43. */
  44. WebIM.config.autoSignIn = false;
  45. if (WebIM.config.autoSignIn) {
  46. WebIM.config.autoSignInName = "lwz2";
  47. WebIM.config.autoSignInPwd = "1";
  48. } // var stropheConn = new window.Strophe.Connection("ws://im-api.easemob.com/ws/", {
  49. // inactivity: 30,
  50. // maxRetries: 5,
  51. // pollingTime: 4500
  52. // });
  53. //
  54. // stropheConn.connect(
  55. // '$t$' + 'YWMtmbQEBKKIEeaGmMtXyg5n1wAAAVlkQvGO2WOJGlMCEJKM4VV9GCMnb_XLCXU',
  56. // function() {
  57. // console.log(arguments, 'ggogogo');
  58. // }, stropheConn.wait, stropheConn.hold);
  59. WebIM.parseEmoji = function (msg) {
  60. if (typeof WebIM.Emoji === "undefined" || typeof WebIM.Emoji.map === "undefined") {
  61. return msg;
  62. }
  63. var emoji = WebIM.Emoji,
  64. reg = null;
  65. var msgList = [];
  66. var objList = [];
  67. for (var face in emoji.map) {
  68. if (emoji.map.hasOwnProperty(face)) {
  69. while (msg.indexOf(face) > -1) {
  70. msg = msg.replace(face, "^" + emoji.map[face] + "^");
  71. }
  72. }
  73. }
  74. var ary = msg.split("^");
  75. var reg = /^e.*g$/;
  76. for (var i = 0; i < ary.length; i++) {
  77. if (ary[i] != "") {
  78. msgList.push(ary[i]);
  79. }
  80. }
  81. for (var i = 0; i < msgList.length; i++) {
  82. if (reg.test(msgList[i])) {
  83. var obj = {};
  84. obj.data = msgList[i];
  85. obj.type = "emoji";
  86. objList.push(obj);
  87. } else {
  88. var obj = {};
  89. obj.data = msgList[i];
  90. obj.type = "txt";
  91. objList.push(obj);
  92. }
  93. }
  94. return objList;
  95. };
  96. WebIM.time = function () {
  97. var date = new Date();
  98. var Hours = date.getHours();
  99. var Minutes = date.getMinutes();
  100. var Seconds = date.getSeconds();
  101. var time = date.getFullYear() + "-" + (date.getMonth() + 1) + "-" + date.getDate() + " " + (Hours < 10 ? "0" + Hours : Hours) + ":" + (Minutes < 10 ? "0" + Minutes : Minutes) + ":" + (Seconds < 10 ? "0" + Seconds : Seconds);
  102. return time;
  103. };
  104. WebIM.Emoji = {
  105. map: {
  106. "[):]": "ee_1.png",
  107. "[:D]": "ee_2.png",
  108. "[;)]": "ee_3.png",
  109. "[:-o]": "ee_4.png",
  110. "[:p]": "ee_5.png",
  111. "[(H)]": "ee_6.png",
  112. "[:@]": "ee_7.png",
  113. "[:s]": "ee_8.png",
  114. "[:$]": "ee_9.png",
  115. "[:(]": "ee_10.png",
  116. "[:'(]": "ee_11.png",
  117. "[<o)]": "ee_12.png",
  118. "[(a)]": "ee_13.png",
  119. "[8o|]": "ee_14.png",
  120. "[8-|]": "ee_15.png",
  121. "[+o(]": "ee_16.png",
  122. "[|-)]": "ee_17.png",
  123. "[:|]": "ee_18.png",
  124. "[*-)]": "ee_19.png",
  125. "[:-#]": "ee_20.png",
  126. "[^o)]": "ee_21.png",
  127. "[:-*]": "ee_22.png",
  128. "[8-)]": "ee_23.png",
  129. "[del]": "btn_del.png",
  130. "[(|)]": "ee_24.png",
  131. "[(u)]": "ee_25.png",
  132. "[(S)]": "ee_26.png",
  133. "[(*)]": "ee_27.png",
  134. "[(#)]": "ee_28.png",
  135. "[(R)]": "ee_29.png",
  136. "[({)]": "ee_30.png",
  137. "[(})]": "ee_31.png",
  138. "[(k)]": "ee_32.png",
  139. "[(F)]": "ee_33.png",
  140. "[(W)]": "ee_34.png",
  141. "[(D)]": "ee_35.png"
  142. }
  143. };
  144. WebIM.EmojiObj = {
  145. // 相对 emoji.js 路径
  146. map1: {
  147. "[):]": "ee_1.png",
  148. "[:D]": "ee_2.png",
  149. "[;)]": "ee_3.png",
  150. "[:-o]": "ee_4.png",
  151. "[:p]": "ee_5.png",
  152. "[(H)]": "ee_6.png",
  153. "[:@]": "ee_7.png"
  154. },
  155. map2: {
  156. "[:s]": "ee_8.png",
  157. "[:$]": "ee_9.png",
  158. "[:(]": "ee_10.png",
  159. "[:'(]": "ee_11.png",
  160. "[<o)]": "ee_12.png",
  161. "[(a)]": "ee_13.png",
  162. "[8o|]": "ee_14.png"
  163. },
  164. map3: {
  165. "[8-|]": "ee_15.png",
  166. "[+o(]": "ee_16.png",
  167. "[|-)]": "ee_17.png",
  168. "[:|]": "ee_18.png",
  169. "[*-)]": "ee_19.png",
  170. "[:-#]": "ee_20.png",
  171. "[del]": "del.png"
  172. },
  173. map4: {
  174. "[^o)]": "ee_21.png",
  175. "[:-*]": "ee_22.png",
  176. "[8-)]": "ee_23.png",
  177. "[(|)]": "ee_24.png",
  178. "[(u)]": "ee_25.png",
  179. "[(S)]": "ee_26.png",
  180. "[(*)]": "ee_27.png"
  181. },
  182. map5: {
  183. "[(#)]": "ee_28.png",
  184. "[(R)]": "ee_29.png",
  185. "[({)]": "ee_30.png",
  186. "[(})]": "ee_31.png",
  187. "[(k)]": "ee_32.png",
  188. "[(F)]": "ee_33.png",
  189. "[(W)]": "ee_34.png",
  190. "[(D)]": "ee_35.png"
  191. },
  192. map6: {
  193. "[del]": "del.png"
  194. }
  195. }; // wx.connectSocket({url: WebIM.config.xmppURL, method: "GET"})
  196. WebIM.conn = new WebIM.connection({
  197. appKey: WebIM.config.appkey,
  198. isMultiLoginSessions: WebIM.config.isMultiLoginSessions,
  199. https: typeof WebIM.config.https === "boolean" ? WebIM.config.https : location.protocol === "https:",
  200. url: WebIM.config.xmppURL,
  201. apiUrl: WebIM.config.apiURL,
  202. isAutoLogin: false,
  203. heartBeatWait: WebIM.config.heartBeatWait,
  204. autoReconnectNumMax: WebIM.config.autoReconnectNumMax,
  205. autoReconnectInterval: WebIM.config.autoReconnectInterval
  206. }); // async response
  207. // WebIM.conn.listen({
  208. // onOpened: () => dispatch({type: Types.ON_OPEND})
  209. // })
  210. // export default WebIM;
  211. module.exports = {
  212. "default": WebIM
  213. };