main.js 1.9 KB

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