main.js 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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 VConsole from 'vconsole'
  23. // new VConsole();
  24. // #endif
  25. // #ifdef H5
  26. import * as recorder from './common/recorder-h5';
  27. // #endif
  28. // #ifndef H5
  29. import * as recorder from './common/recorder-app';
  30. // #endif
  31. export function createApp() {
  32. const app = createSSRApp(App)
  33. app.use(uviewPlus);
  34. app.use(pinia.createPinia());
  35. app.component('bar-group', barGroup);
  36. app.component('arrow-bar', arrowBar);
  37. app.component('btn-bar', btnBar);
  38. app.component('switch-bar', switchBar);
  39. app.config.globalProperties.$http = request;
  40. app.config.globalProperties.$wsApi = socketApi;
  41. app.config.globalProperties.$msgType = messageType;
  42. app.config.globalProperties.$emo = emotion;
  43. app.config.globalProperties.$url = url;
  44. app.config.globalProperties.$enums = enums;
  45. app.config.globalProperties.$date = date;
  46. app.config.globalProperties.$rc = recorder;
  47. // 初始化时再挂载store对象
  48. app.config.globalProperties.$mountStore = () => {
  49. app.config.globalProperties.chatStore = useChatStore();
  50. app.config.globalProperties.friendStore = useFriendStore();
  51. app.config.globalProperties.groupStore = useGroupStore();
  52. app.config.globalProperties.configStore = useConfigStore();
  53. app.config.globalProperties.userStore = useUserStore();
  54. }
  55. return {
  56. app,
  57. pinia
  58. }
  59. }