main.js 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. import App from './App'
  2. import request from './common/request';
  3. import emotion from './common/emotion.js';
  4. import * as enums from './common/enums.js';
  5. import * as date from './common/date';
  6. import * as socketApi from './common/wssocket';
  7. import * as messageType from './common/messageType';
  8. import { createSSRApp } from 'vue'
  9. import uviewPlus from '@/uni_modules/uview-plus'
  10. import * as pinia from 'pinia';
  11. import useChatStore from '@/store/chatStore.js'
  12. import useFriendStore from '@/store/friendStore.js'
  13. import useGroupStore from '@/store/groupStore.js'
  14. import useConfigStore from '@/store/configStore.js'
  15. import useUserStore from '@/store/userStore.js'
  16. import barGroup from '@/components/bar/bar-group'
  17. import arrowBar from '@/components/bar/arrow-bar'
  18. import btnBar from '@/components/bar/btn-bar'
  19. import switchBar from '@/components/bar/switch-bar'
  20. //import VConsole from 'vconsole'
  21. //new VConsole();
  22. // #ifdef H5
  23. import * as recorder from './common/recorder-h5';
  24. // #endif
  25. // #ifndef H5
  26. import * as recorder from './common/recorder-app';
  27. // #endif
  28. export function createApp() {
  29. const app = createSSRApp(App)
  30. app.use(uviewPlus);
  31. app.use(pinia.createPinia());
  32. app.component('bar-group', barGroup);
  33. app.component('arrow-bar', arrowBar);
  34. app.component('btn-bar', btnBar);
  35. app.component('switch-bar', switchBar);
  36. app.config.globalProperties.$http = request;
  37. app.config.globalProperties.$wsApi = socketApi;
  38. app.config.globalProperties.$msgType = messageType;
  39. app.config.globalProperties.$emo = emotion;
  40. app.config.globalProperties.$enums = enums;
  41. app.config.globalProperties.$date = date;
  42. app.config.globalProperties.$rc = recorder;
  43. // 初始化时再挂载store对象
  44. app.config.globalProperties.$mountStore = () => {
  45. app.config.globalProperties.chatStore = useChatStore();
  46. app.config.globalProperties.friendStore = useFriendStore();
  47. app.config.globalProperties.groupStore = useGroupStore();
  48. app.config.globalProperties.configStore = useConfigStore();
  49. app.config.globalProperties.userStore = useUserStore();
  50. }
  51. return {
  52. app,
  53. pinia
  54. }
  55. }