main.js 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. import App from './App.vue'
  2. import { createSSRApp } from 'vue'
  3. import store from './store'
  4. import uViewPlus, { props as uviewProps } from 'uview-plus'
  5. if (process.env.NODE_ENV === 'development') {
  6. console.log('%c[Mock] 开发模式已启用', 'color: green; font-weight: bold;');
  7. console.log('%c[Mock] 请启动Mock服务器: node mock-server.js', 'color: blue;');
  8. console.log('%c[Mock] 服务器地址: http://localhost:3001', 'color: blue;');
  9. }
  10. // http 拦截器与 API 需在 app 创建后注册
  11. import request from '@/utils/request.js'
  12. import httpApi from '@/utils/api.js'
  13. import hideNav from '@/utils/hideNav.js'
  14. import doubleTap from '@/utils/doubleTap.js'
  15. import common from '@/utils/common.js'
  16. import globalMinxins from '@/mixins'
  17. export function createApp() {
  18. const app = createSSRApp(App)
  19. app.use(store)
  20. app.use(uViewPlus)
  21. // 兼容依赖 uni.$u.props 的组件(如异步加载的 uview-plus 组件或 uni_modules 内旧 uview-ui)
  22. if (typeof uni !== 'undefined' && uni.$u && typeof uni.$u.props === 'undefined') {
  23. uni.$u.props = uviewProps
  24. }
  25. app.use(request)
  26. app.use(httpApi)
  27. app.use(hideNav)
  28. app.use(doubleTap)
  29. app.use(common)
  30. app.config.globalProperties.$getDicts = function (dictType, customFlag = true) {
  31. return store.dispatch('dict/getDicts', { dictType, customFlag })
  32. }
  33. app.mixin(globalMinxins)
  34. return { app }
  35. }