main.js 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. import App from './App'
  2. import request from './common/request';
  3. import emotion from './common/emotion.js';
  4. import url from './common/url.js';
  5. import str from './common/str.js';
  6. import * as enums from './common/enums.js';
  7. import * as date from './common/date';
  8. import * as socketApi from './common/wssocket';
  9. import * as messageType from './common/messageType';
  10. import { createSSRApp } from 'vue'
  11. import uviewPlus from '@/uni_modules/uview-plus'
  12. import * as pinia from 'pinia';
  13. import useChatStore from '@/store/chatStore.js'
  14. import useFriendStore from '@/store/friendStore.js'
  15. import useGroupStore from '@/store/groupStore.js'
  16. import useConfigStore from '@/store/configStore.js'
  17. import useUserStore from '@/store/userStore.js'
  18. import barGroup from '@/components/bar/bar-group'
  19. import arrowBar from '@/components/bar/arrow-bar'
  20. import btnBar from '@/components/bar/btn-bar'
  21. import switchBar from '@/components/bar/switch-bar'
  22. // #ifdef H5
  23. import * as recorder from './common/recorder-h5';
  24. import ImageResize from "quill-image-resize-mp";
  25. import Quill from "quill";
  26. import 'default-passive-events';
  27. // 以下组件用于兼容部分手机聊天边框无法输入的问题
  28. window.Quill = Quill;
  29. window.ImageResize = { default: ImageResize };
  30. // 调试器
  31. // import VConsole from 'vconsole'
  32. // new VConsole();
  33. // #endif
  34. // #ifndef H5
  35. import * as recorder from './common/recorder-app';
  36. // #endif
  37. export function createApp() {
  38. const app = createSSRApp(App)
  39. app.use(uviewPlus);
  40. app.use(pinia.createPinia());
  41. app.component('bar-group', barGroup);
  42. app.component('arrow-bar', arrowBar);
  43. app.component('btn-bar', btnBar);
  44. app.component('switch-bar', switchBar);
  45. app.config.globalProperties.$http = request;
  46. app.config.globalProperties.$wsApi = socketApi;
  47. app.config.globalProperties.$msgType = messageType;
  48. app.config.globalProperties.$emo = emotion;
  49. app.config.globalProperties.$url = url;
  50. app.config.globalProperties.$str = str;
  51. app.config.globalProperties.$enums = enums;
  52. app.config.globalProperties.$date = date;
  53. app.config.globalProperties.$rc = recorder;
  54. // 初始化时再挂载store对象
  55. app.config.globalProperties.$mountStore = () => {
  56. app.config.globalProperties.chatStore = useChatStore();
  57. app.config.globalProperties.friendStore = useFriendStore();
  58. app.config.globalProperties.groupStore = useGroupStore();
  59. app.config.globalProperties.configStore = useConfigStore();
  60. app.config.globalProperties.userStore = useUserStore();
  61. }
  62. return {
  63. app,
  64. pinia
  65. }
  66. }