1
0

main.js 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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. Vue.prototype.$haloConfig = HaloConfig
  56. Vue.prototype.$baseApiUrl = HaloConfig.apiUrl
  57. import HaloAdConfig from '@/config/ad.config.js'
  58. Vue.prototype.$haloAdConfig = HaloAdConfig
  59. // 由于微信小程序的运行机制问题,需声明如下一行,H5和APP非必填
  60. Vue.prototype._i18n = i18n;
  61. Vue.config.productionTip = false;
  62. App.mpType = "app";
  63. const app = new Vue({
  64. i18n,
  65. ...App,
  66. });
  67. // app.$mount();
  68. // #ifdef H5
  69. RouterMount(app, router, '#app')
  70. // #endif
  71. // #ifndef H5
  72. app.$mount(); //为了兼容小程序及app端必须这样写才有效果
  73. // #endif