main.js 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. import App from './App'
  2. import Vue from 'vue'
  3. import uView from 'uview-ui';
  4. import common from "@/config/common.js";
  5. import store from '@/store/index.js'
  6. import en from '@/static/locales/en.js';
  7. import hi from '@/static/locales/hi.js';
  8. // #ifndef VUE3
  9. // main.js,注意要在use方法之后执行
  10. import jquery from 'jquery'
  11. import Videojs from 'video.js'
  12. import 'video.js/dist/video-js.css'
  13. // import 'video.js/dist/video-js.min.css'
  14. // import VueMatomo from 'vue-matomo'
  15. Vue.config.productionTip = false
  16. App.mpType = 'app';
  17. // import render from "@/pages/components/render";
  18. // Vue.prototype.$r = render;
  19. // ...
  20. // let routes = getCurrentPages()
  21. // Vue.use(VueMatomo, {
  22. // host: 'https://onecric.piwik.pro', // 这里配置你自己的piwik服务器地址和网站ID
  23. // siteId: 'fe5a55b8-bec8-4022-ab0c-b327e32cdf82',//siteId值
  24. // // 注册名称 =>this.$matomo
  25. // trackerFileName: 'matomo',
  26. // // 根据router自动注册
  27. // router: routes,
  28. // // // 是否需要在发送追踪信息之前请求许可
  29. // // // 默认false
  30. // requireConsent: false,
  31. // enableLinkTracking: true,
  32. // // // 是否追踪初始页面
  33. // // // 默认true
  34. // trackInitialView: false,
  35. // // // 最终的追踪js文件名
  36. // // // 默认 'piwik'
  37. // trackerFileName: 'piwik',
  38. // debug: false
  39. // });
  40. // 引入并使用vue-i18n
  41. import VueI18n from 'vue-i18n'
  42. Vue.use(VueI18n)
  43. // Vue.use(uView)
  44. Vue.prototype.$store = store;
  45. Vue.prototype.$video = Videojs; //使用video.js时用$video
  46. Vue.prototype.$toUrl = function navigateTo(url){
  47. uni.navigateTo({
  48. url:url
  49. })
  50. }
  51. Vue.prototype.$back = function back(num){
  52. uni.navigateBack({
  53. delta:num || 1
  54. })
  55. }
  56. Vue.prototype.$toast = function toast(title){
  57. uni.showToast({
  58. title: title,
  59. icon: 'error'
  60. });
  61. }
  62. Vue.prototype.$ = jquery
  63. // 如此配置即可
  64. uni.$u.config.unit = 'rpx'
  65. // 构造i18n对象
  66. const i18n = new VueI18n({
  67. // 默认语言,这里的local属性,对应message中的zh、en属性
  68. locale: 'en',
  69. // 引入语言文件
  70. messages: {
  71. // 这里的属性名是任意的,您也可以把zh设置为cn等,只是后续切换语言时
  72. // 要标识这里的语言属性,如:this.$i18n.locale = zh|en|zh|xxx
  73. //'zh': zh, // 这里为上面通过import引入的语言包
  74. 'en': en,
  75. 'hi': hi,
  76. }
  77. })
  78. // 由于微信小程序的运行机制问题,需声明如下一行,H5和APP非必填
  79. Vue.prototype._i18n = i18n;
  80. Vue.prototype.$common = common;
  81. const app = new Vue({
  82. i18n,
  83. ...App
  84. })
  85. // 引入请求封装,将app参数传递到配置中
  86. require('./config/request.js')(app)
  87. app.$mount()
  88. // #endif
  89. // #ifdef VUE3
  90. import { createSSRApp } from 'vue'
  91. export function createApp() {
  92. const app = createSSRApp(App)
  93. return {
  94. app
  95. }
  96. }
  97. // #endif