main.js 2.1 KB

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