main.js 1.7 KB

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