main.js 2.4 KB

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