main.js 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. import App from './App'
  2. // vuex
  3. import store from '@/store/index.js'
  4. // uviewPlus导入 - 注意 Vue3 的特殊导入方式
  5. // #ifdef VUE3
  6. import uviewPlus from 'uview-plus'
  7. // #endif
  8. // #ifndef VUE3
  9. import uviewPlus from '@/uni_modules/uview-plus'
  10. // #endif
  11. import bootstrap from './core/bootstrap'
  12. import { isLogin, isEmpty, navTo, getRegistrationID, parsePhone } from '@/utils/util.js'
  13. // 全局 mixin
  14. import share from './core/mixins/share.js'
  15. import mixin from './core/mixins/app'
  16. // #ifndef VUE3
  17. import Vue from 'vue'
  18. import './uni.promisify.adaptor'
  19. // 配置 uView Plus
  20. Vue.use(uviewPlus)
  21. // 配置 Vuex
  22. Vue.use(store)
  23. Vue.config.productionTip = false
  24. // 全局属性
  25. Vue.prototype.$img = {
  26. img: '/static/images/img.png',
  27. logo: '/static/images/logo.png',
  28. }
  29. Vue.prototype.$isLogin = isLogin
  30. Vue.prototype.$isEmpty = isEmpty
  31. Vue.prototype.$navTo = navTo
  32. Vue.prototype.$getRegistrationID = getRegistrationID
  33. Vue.prototype.$parsePhone = parsePhone
  34. // 全局 mixin
  35. Vue.mixin(share)
  36. Vue.mixin(mixin)
  37. App.mpType = 'app'
  38. // 初始化
  39. bootstrap().then(() => {
  40. const app = new Vue({
  41. store, // 注入 store
  42. ...App
  43. })
  44. app.$mount()
  45. })
  46. // #endif
  47. // #ifdef VUE3
  48. import { createSSRApp } from 'vue'
  49. export function createApp() {
  50. const app = createSSRApp(App)
  51. // 注册 uView Plus (Vue3 方式)
  52. app.use(uviewPlus)
  53. // 注册 Vuex
  54. app.use(store)
  55. app.config.productionTip = false
  56. // 定义全局属性
  57. app.config.globalProperties.$img = {
  58. img: '/static/images/img.png',
  59. logo: '/static/images/logo.png',
  60. }
  61. app.config.globalProperties.$isLogin = isLogin
  62. app.config.globalProperties.$isEmpty = isEmpty
  63. app.config.globalProperties.$navTo = navTo
  64. app.config.globalProperties.$getRegistrationID = getRegistrationID
  65. app.config.globalProperties.$parsePhone = parsePhone
  66. // 全局 mixin
  67. app.mixin(share)
  68. app.mixin(mixin)
  69. // 初始化
  70. return {
  71. app,
  72. created: bootstrap
  73. }
  74. }
  75. // #endif