main.js 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. import Vue from 'vue';
  2. import App from './App';
  3. import GoEasy from '@/uni_modules/GOEASY-IM/js_sdk/goeasy-2.13.21.esm.min.js'
  4. import GRTC from './lib/goeasy-rtc-0.3.7.esm.min.js'
  5. import request from '@/utils/request.js'
  6. Vue.prototype.$http = request.http
  7. Vue.prototype.$http2 = request.http2
  8. Vue.prototype.$request =request
  9. GoEasy.init({
  10. host:"hangzhou.goeasy.io",//应用所在的区域地址: 【hangzhou.goeasy.io |singapore.goeasy.io】
  11. appkey:"BC-729fefdf1ad7417daea8e62b9fce3f74",// common key
  12. modules: ['im'],
  13. // true表示支持通知栏提醒,false则表示不需要通知栏提醒
  14. allowNotification: true //仅有效于app,小程序和H5将会被自动忽略
  15. });
  16. GRTC.init(GoEasy);
  17. uni.$GoEasy = GoEasy;
  18. uni.$GRTC = GRTC;
  19. GoEasy.onClickNotification((message) => {
  20. let currentUrl;
  21. const routes = getCurrentPages();
  22. if (routes && routes.length) {
  23. const curRoute = routes[routes.length - 1].route;
  24. const curParam = routes[routes.length - 1].options;
  25. currentUrl = '/' + curRoute + `?to=${curParam.to}`;
  26. }
  27. let newUrl;
  28. switch (message.toType) {
  29. case GoEasy.IM_SCENE.PRIVATE:
  30. newUrl = '/pages/privateChat?to=' + message.senderId;
  31. break;
  32. case GoEasy.IM_SCENE.GROUP:
  33. newUrl = '/pages/groupChat?to=' + message.groupId;
  34. break;
  35. }
  36. if (currentUrl !== newUrl) {
  37. uni.navigateTo({
  38. url: newUrl,
  39. });
  40. }
  41. });
  42. Vue.config.productionTip = false;
  43. App.mpType = 'app';
  44. const app = new Vue({
  45. ...App
  46. });
  47. app.$mount();