main.js 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. import App from "./App";
  2. import Vue from "vue";
  3. import {
  4. router,
  5. RouterMount
  6. } from './router/router.js'
  7. Vue.use(router)
  8. // 挂载全局工具类
  9. import utils from "./utils/index.js";
  10. Vue.prototype.$utils = utils;
  11. // 全局统一样式的对话框
  12. import Fy from '@/js_sdk/fy-showModal/index.js'
  13. uni.$eShowModal = (e = {}) => {
  14. return Fy.showModal(e)
  15. };
  16. // 全局混入
  17. import AppMixin from "@/common/mixins/index.js";
  18. Vue.use(AppMixin);
  19. // 全局过滤器
  20. import AppFilters from "@/common/filters/index.js";
  21. for (let fKey in AppFilters) {
  22. Vue.filter(fKey, AppFilters[fKey]);
  23. }
  24. // 引用tmUI2.x框架
  25. import tmVuetify from "./tm-vuetify";
  26. Vue.use(tmVuetify);
  27. // i18n部分的配置
  28. // 引入语言包,注意路径
  29. import Chinese from "@/common/locales/zh.js";
  30. import English from "@/common/locales/en.js";
  31. // 引入并使用vue-i18n
  32. import VueI18n from "vue-i18n";
  33. Vue.use(VueI18n);
  34. // 构造i18n对象
  35. const i18n = new VueI18n({
  36. // 默认语言,这里的local属性,对应message中的zh、en属性
  37. locale: uni.getStorageSync("Default_Lang") || "zh",
  38. // 引入语言文件
  39. messages: {
  40. // 这里的属性名是任意的,您也可以把zh设置为cn等,只是后续切换语言时
  41. // 要标识这里的语言属性,如:this.$i18n.locale = zh|en|cn|xxx
  42. zh: Chinese,
  43. en: English,
  44. },
  45. });
  46. // 引入请求库
  47. import {
  48. http
  49. } from "./common/http/index.js";
  50. Vue.prototype.$http = http;
  51. // 全局api管理
  52. import ApiManager from '@/api/index.js'
  53. Vue.use(ApiManager);
  54. import HaloConfig from '@/config/halo.config.js'
  55. import HaloTokenConfig from '@/config/token.config.js'
  56. Vue.prototype.$haloConfig = HaloConfig
  57. Vue.prototype.$baseApiUrl = HaloTokenConfig.BASE_API
  58. import HaloAdConfig from '@/config/ad.config.js'
  59. Vue.prototype.$haloAdConfig = HaloAdConfig
  60. // 由于微信小程序的运行机制问题,需声明如下一行,H5和APP非必填
  61. Vue.prototype._i18n = i18n;
  62. Vue.config.productionTip = false;
  63. App.mpType = "app";
  64. const app = new Vue({
  65. i18n,
  66. ...App,
  67. });
  68. // app.$mount();
  69. // #ifdef H5
  70. RouterMount(app, router, '#app')
  71. // #endif
  72. // #ifndef H5
  73. app.$mount(); //为了兼容小程序及app端必须这样写才有效果
  74. // #endif