main.js 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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. // #ifdef H5
  17. import * as recorder from './common/recorder-h5';
  18. // #endif
  19. // #ifndef H5
  20. import * as recorder from './common/recorder-app';
  21. // #endif
  22. export function createApp() {
  23. const app = createSSRApp(App)
  24. app.use(uviewPlus);
  25. app.use(pinia.createPinia());
  26. app.config.globalProperties.$http = request;
  27. app.config.globalProperties.$wsApi = socketApi;
  28. app.config.globalProperties.$msgType = messageType;
  29. app.config.globalProperties.$emo = emotion;
  30. app.config.globalProperties.$enums = enums;
  31. app.config.globalProperties.$date = date;
  32. app.config.globalProperties.$rc = recorder;
  33. // 初始化时再挂载store对象
  34. app.config.globalProperties.$mountStore = ()=>{
  35. app.config.globalProperties.chatStore = useChatStore();
  36. app.config.globalProperties.friendStore = useFriendStore();
  37. app.config.globalProperties.groupStore = useGroupStore();
  38. app.config.globalProperties.configStore = useConfigStore();
  39. app.config.globalProperties.userStore = useUserStore();
  40. }
  41. return {
  42. app,
  43. pinia
  44. }
  45. }