main.js 1.5 KB

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